Skip to content

Commit

Permalink
get tooling/pkgcheck.sh passing on mac. Needs tidying.
Browse files Browse the repository at this point in the history
  • Loading branch information
dankegel committed May 23, 2020
1 parent 21517b7 commit c08b979
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 11 deletions.
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@ if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()

#
# Check for unistd.h
#
check_include_file(unistd.h HAVE_UNISTD_H)

if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
Expand Down Expand Up @@ -254,14 +249,21 @@ if(NOT CYGWIN)
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
endif()

if(APPLE)
set_target_properties(zlib PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
)
elseif (UNIX)
# Makefile.in uses -lc...
set(LDSHAREDLIBC -lc)
target_link_libraries(zlib ${LDSHAREDLIBC})
endif()

if(UNIX)
# On unix-like platforms the library is almost always called libz
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
if(NOT APPLE)
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
# Makefile.in uses -lc...
set(LDSHAREDLIBC -lc)
target_link_libraries(zlib ${LDSHAREDLIBC})
endif()
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
Expand Down
37 changes: 34 additions & 3 deletions tooling/pkgcheck.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,33 @@
#!/bin/sh
# Verify that the various build systems produce identical results
# Verify that the various build systems produce identical results on a Unixlike system
set -ex

# Tell GNU's ld etc. to use Jan 1 1970 when embedding timestamps
export SOURCE_DATE_EPOCH=0

case $(uname) in
Darwin)
# Tell Apple's ar etc. to use zero timestamps
export ZERO_AR_DATE=1
# Tell configure which compiler etc. to use to match cmake
CONFIG_CC="$(xcrun --find gcc || echo gcc)"
CONFIG_CFLAGS="-DNDEBUG -O3 -isysroot $(xcrun --show-sdk-path)"
# Tell configure to pad the executable the same way cmake will
CONFIG_LDFLAGS=" -Wl,-headerpad_max_install_names"
;;
*)
CONFIG_CC=""
CONFIG_CFLAGS="-DNDEBUG -O3"
CONFIG_LDFLAGS=""
;;
esac

# Original build system
rm -rf btmp1 pkgtmp1
mkdir btmp1 pkgtmp1
export DESTDIR=$(pwd)/pkgtmp1
cd btmp1
../configure
CFLAGS="$CONFIG_CFLAGS" LDFLAGS="$CONFIG_LDFLAGS" CC="$CONFIG_CC" ../configure
make
make install
cd ..
Expand All @@ -18,10 +38,21 @@ mkdir btmp2 pkgtmp2
export DESTDIR=$(pwd)/pkgtmp2
cd btmp2
cmake -G Ninja ..
ninja
ninja -v
ninja install
cd ..

case $(uname) in
Darwin)
# Alas, dylibs still have an embedded hash or something,
# so nuke it. There's probably a better way.
dylib1=$(find pkgtmp1 -name '*.dylib*' -type f)
dylib2=$(find pkgtmp2 -name '*.dylib*' -type f)
dd conv=notrunc if=/dev/zero of=$dylib1 skip=1337 count=16
dd conv=notrunc if=/dev/zero of=$dylib2 skip=1337 count=16
;;
esac

if diff -Nur pkgtmp1 pkgtmp2
then
echo pkgcheck-cmake-bits-identical PASS
Expand Down

0 comments on commit c08b979

Please sign in to comment.