From 42ac6d1cff6ff6f086fd6c3be8e82e121424dba8 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Thu, 21 May 2020 23:38:14 -0700 Subject: [PATCH 1/8] cmake: mimic behavior of Makefile a bit better; mostly fixes issue #497? --- CMakeLists.txt | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e0b13dfe..7163aaca8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,15 @@ set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation d set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") +# Set a default build type if none was specified +set(default_build_type "Release") +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to '${default_build_type}' as none was specified.") + set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") +endif() + include(CheckTypeSize) include(CheckFunctionExists) include(CheckIncludeFile) @@ -24,6 +33,17 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stddef.h HAVE_STDDEF_H) +# +# Check to see if compiler supports __attribute__((visibility ("hidden"))) +# +check_c_source_compiles( + "int __attribute__((visibility (\"hidden\"))) foo; int main() { return foo; }" + HAVE_HIDDEN +) +if(HAVE_HIDDEN) + add_definitions(-DHAVE_HIDDEN) +endif() + # # Check to see if we have large file support # @@ -105,22 +125,27 @@ set(ZLIB_PRIVATE_HDRS trees.h zutil.h ) + +# Note: keep these in the same order as in Makefile.in +# This allows libz.so to be identical between the two build systems. set(ZLIB_SRCS + # Makefile.in: PIC_OBJZ adler32.c - compress.c crc32.c deflate.c - gzclose.c - gzlib.c - gzread.c - gzwrite.c - inflate.c infback.c - inftrees.c inffast.c + inflate.c + inftrees.c trees.c - uncompr.c zutil.c + # Makefile.in: PIC_OBJG + compress.c + uncompr.c + gzclose.c + gzlib.c + gzread.c + gzwrite.c ) if(NOT MINGW) @@ -204,6 +229,9 @@ if(UNIX) 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 From 3e356b775335526cad5eba99efb9aaea6c2e9f4f Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Fri, 22 May 2020 11:13:47 -0700 Subject: [PATCH 2/8] Add tooling/pkgcheck.sh, make cmake install identical to Make install. Also add tooling/test-cmake.sh and tooling/test-make.sh, use at least the former in .cirrus-ci.yml. --- .cirrus.yml | 13 +++------ CMakeLists.txt | 44 ++++++++++++++++++++++++++----- tooling/cirrus/ubu1804/Dockerfile | 2 +- tooling/cirrus/ubu2004/Dockerfile | 2 +- tooling/pkgcheck.sh | 31 ++++++++++++++++++++++ tooling/test-cmake.sh | 11 ++++++++ tooling/test-make.sh | 11 ++++++++ zconf.h.cmakein | 6 ++--- zlib.pc.cmakein | 10 +++---- 9 files changed, 103 insertions(+), 27 deletions(-) create mode 100644 tooling/pkgcheck.sh create mode 100644 tooling/test-cmake.sh create mode 100644 tooling/test-make.sh diff --git a/.cirrus.yml b/.cirrus.yml index c3b471a1a..0609fdf5d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -2,8 +2,7 @@ check_ubu1804_task: container: dockerfile: tooling/cirrus/ubu1804/Dockerfile test_script: - - cc --version - - mkdir btmp; cd btmp; cmake -G Ninja .. && ninja && ctest -V + - sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh always: junit_artifacts: path: "btmp/*-results.xml" @@ -14,8 +13,7 @@ check_ubu2004_task: container: dockerfile: tooling/cirrus/ubu2004/Dockerfile test_script: - - cc --version - - mkdir btmp; cd btmp; cmake -G Ninja .. && ninja && ctest -V + - sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh always: junit_artifacts: path: "btmp/*-results.xml" @@ -28,9 +26,7 @@ check_mac_task: install_script: - brew install ninja test_script: - - cc --version - - ninja --version - - mkdir btmp; cd btmp; cmake -G Ninja .. && cmake --build . && ctest -V + - sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh always: junit_artifacts: path: "btmp/*-results.xml" @@ -43,8 +39,7 @@ check_bsd_task: install_script: - pkg install -y gcc cmake ninja test_script: - - cc --version - - mkdir btmp; cd btmp; cmake -G Ninja .. && ninja && ctest -V + - sh tooling/test-cmake.sh && sh tooling/pkgcheck.sh always: junit_artifacts: path: "btmp/*-results.xml" diff --git a/CMakeLists.txt b/CMakeLists.txt index 7163aaca8..f9e7329db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,12 @@ set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) project(zlib C) +# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) +string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" + "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) +MESSAGE("ZLIB_FULL_VERSION=${ZLIB_FULL_VERSION}") +# FIXME: parse this from ZLIB_FULL_VERSION set(VERSION "1.2.11.1") option(ASM686 "Enable building i686 assembly implementation") @@ -12,7 +18,7 @@ set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation direc set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages") -set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") +set(INSTALL_PKGCONFIG_DIR "${INSTALL_LIB_DIR}/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files") # Set a default build type if none was specified set(default_build_type "Release") @@ -32,6 +38,22 @@ enable_testing() check_include_file(sys/types.h HAVE_SYS_TYPES_H) check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stddef.h HAVE_STDDEF_H) +check_include_file(stdarg.h HAVE_STDARG_H) +check_include_file(unistd.h HAVE_UNISTD_H) + +# +# Match configure's zconf.h exactly +# +if (HAVE_STDARG_H) + SET(ZCONF_STDARG_LINE "#if 1 /* was set to #if 1 by ./configure */") +else() + SET(ZCONF_STDARG_LINE "#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */") +endif() +if (HAVE_UNISTD_H) + SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by ./configure */") +else() + SET(ZCONF_UNISTD_LINE "#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */") +endif() # # Check to see if compiler supports __attribute__((visibility ("hidden"))) @@ -77,7 +99,7 @@ endif() # # Check for unistd.h # -check_include_file(unistd.h Z_HAVE_UNISTD_H) +check_include_file(unistd.h HAVE_UNISTD_H) if(MSVC) set(CMAKE_DEBUG_POSTFIX "d") @@ -98,6 +120,19 @@ if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) endif() endif() +# Refer to prefix symbolically to ease relocation by end user, +# and match Makefile-generate .pc file exactly. +if(INSTALL_INC_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/include") + set(PC_INSTALL_INC_DIR "\${prefix}/include") +else() + set(PC_INSTALL_INC_DIR "${INSTALL_INC_DIR}") +endif() +if(INSTALL_LIB_DIR STREQUAL "${CMAKE_INSTALL_PREFIX}/lib") + set(PC_INSTALL_LIB_DIR "\${exec_prefix}/lib") +else() + set(PC_INSTALL_LIB_DIR "${INSTALL_LIB_DIR}") +endif() + set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY) @@ -187,11 +222,6 @@ if(MSVC) endif() endif() -# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION -file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) -string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" - "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) - if(MINGW) # This gets us DLL resource information when compiling on MinGW. if(NOT CMAKE_RC_COMPILER) diff --git a/tooling/cirrus/ubu1804/Dockerfile b/tooling/cirrus/ubu1804/Dockerfile index 107b374b9..ebfd25e1a 100644 --- a/tooling/cirrus/ubu1804/Dockerfile +++ b/tooling/cirrus/ubu1804/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:18.04 RUN apt-get update && \ - apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build && \ + apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \ apt-get clean diff --git a/tooling/cirrus/ubu2004/Dockerfile b/tooling/cirrus/ubu2004/Dockerfile index 17b3d5512..99f06be80 100644 --- a/tooling/cirrus/ubu2004/Dockerfile +++ b/tooling/cirrus/ubu2004/Dockerfile @@ -1,5 +1,5 @@ FROM ubuntu:20.04 RUN apt-get update && \ - apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build && \ + apt-get install --no-install-recommends -y cmake gcc libc6-dev ninja-build make && \ apt-get clean diff --git a/tooling/pkgcheck.sh b/tooling/pkgcheck.sh new file mode 100644 index 000000000..0f0aeea52 --- /dev/null +++ b/tooling/pkgcheck.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Verify that the various build systems produce identical results +set -ex + +# Original build system +rm -rf btmp1 pkgtmp1 +mkdir btmp1 pkgtmp1 +export DESTDIR=$(pwd)/pkgtmp1 +cd btmp1 + ../configure + make + make install +cd .. + +# New build system +rm -rf btmp2 pkgtmp2 +mkdir btmp2 pkgtmp2 +export DESTDIR=$(pwd)/pkgtmp2 +cd btmp2 + cmake -G Ninja .. + ninja + ninja install +cd .. + +if diff -Nur pkgtmp1 pkgtmp2 +then + echo pkgcheck-cmake-bits-identical PASS +else + echo pkgcheck-cmake-bits-identical FAIL + exit 1 +fi diff --git a/tooling/test-cmake.sh b/tooling/test-cmake.sh new file mode 100644 index 000000000..e0e8b2a22 --- /dev/null +++ b/tooling/test-cmake.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Build and test with CMake +set -ex + +rm -rf btmp +mkdir btmp +cd btmp + cmake -G Ninja .. + ninja + ctest -V +cd .. diff --git a/tooling/test-make.sh b/tooling/test-make.sh new file mode 100644 index 000000000..41a5f733b --- /dev/null +++ b/tooling/test-make.sh @@ -0,0 +1,11 @@ +#!/bin/sh +# Build and test with Make +set -ex + +rm -rf btmp +mkdir btmp +cd btmp1 + ../configure + make + make test +cd .. diff --git a/zconf.h.cmakein b/zconf.h.cmakein index a7f24cce6..83072aad7 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein @@ -7,8 +7,6 @@ #ifndef ZCONF_H #define ZCONF_H -#cmakedefine Z_PREFIX -#cmakedefine Z_HAVE_UNISTD_H /* * If you *really* need a unique prefix for all types and library functions, @@ -433,11 +431,11 @@ typedef uLong FAR uLongf; typedef unsigned long z_crc_t; #endif -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +@ZCONF_UNISTD_LINE@ # define Z_HAVE_UNISTD_H #endif -#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */ +@ZCONF_STDARG_LINE@ # define Z_HAVE_STDARG_H #endif diff --git a/zlib.pc.cmakein b/zlib.pc.cmakein index a5e642938..a46594afb 100644 --- a/zlib.pc.cmakein +++ b/zlib.pc.cmakein @@ -1,12 +1,12 @@ prefix=@CMAKE_INSTALL_PREFIX@ -exec_prefix=@CMAKE_INSTALL_PREFIX@ -libdir=@INSTALL_LIB_DIR@ -sharedlibdir=@INSTALL_LIB_DIR@ -includedir=@INSTALL_INC_DIR@ +exec_prefix=${prefix} +libdir=@PC_INSTALL_LIB_DIR@ +sharedlibdir=${libdir} +includedir=@PC_INSTALL_INC_DIR@ Name: zlib Description: zlib compression library -Version: @VERSION@ +Version: @ZLIB_FULL_VERSION@ Requires: Libs: -L${libdir} -L${sharedlibdir} -lz From 21517b75f47831adc0a0e41e659c77a4b6d41c7b Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Fri, 22 May 2020 14:35:01 -0700 Subject: [PATCH 3/8] configure: don't pull in stale zconf.h. Fixes #499. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 1cd4fe57a..fd0c33a90 100755 --- a/configure +++ b/configure @@ -25,7 +25,7 @@ if test $SRCDIR = "."; then ZINCOUT="-I." SRCDIR="" else - ZINC='-include zconf.h' + ZINC='-I. -include zconf.h' ZINCOUT='-I. -I$(SRCDIR)' SRCDIR="$SRCDIR/" fi From c08b9791bbfb8c15bbbec3ab349b94f973442bf1 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Fri, 22 May 2020 20:50:02 -0700 Subject: [PATCH 4/8] get tooling/pkgcheck.sh passing on mac. Needs tidying. --- CMakeLists.txt | 18 ++++++++++-------- tooling/pkgcheck.sh | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9e7329db..a74811323 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 diff --git a/tooling/pkgcheck.sh b/tooling/pkgcheck.sh index 0f0aeea52..237294f66 100644 --- a/tooling/pkgcheck.sh +++ b/tooling/pkgcheck.sh @@ -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 .. @@ -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 From 6da4361079863fb56c83680a1aa66f2a0c9067d3 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Fri, 22 May 2020 20:53:05 -0700 Subject: [PATCH 5/8] pkgcheck.sh: don't fiddle with cflags except on mac --- tooling/pkgcheck.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tooling/pkgcheck.sh b/tooling/pkgcheck.sh index 237294f66..ac8e5f348 100644 --- a/tooling/pkgcheck.sh +++ b/tooling/pkgcheck.sh @@ -17,7 +17,7 @@ Darwin) ;; *) CONFIG_CC="" - CONFIG_CFLAGS="-DNDEBUG -O3" + CONFIG_CFLAGS="" CONFIG_LDFLAGS="" ;; esac From bf29040f5773e8f3bcdd4be322a06b68df9ca6d8 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Fri, 22 May 2020 21:01:23 -0700 Subject: [PATCH 6/8] pkgcheck.sh: don't set even empty values for CC etc. on linux --- tooling/pkgcheck.sh | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/tooling/pkgcheck.sh b/tooling/pkgcheck.sh index ac8e5f348..49ff8ef4e 100644 --- a/tooling/pkgcheck.sh +++ b/tooling/pkgcheck.sh @@ -4,30 +4,27 @@ 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="" - CONFIG_LDFLAGS="" - ;; -esac +# Tell Apple's ar etc. to use zero timestamps +export ZERO_AR_DATE=1 # Original build system rm -rf btmp1 pkgtmp1 mkdir btmp1 pkgtmp1 export DESTDIR=$(pwd)/pkgtmp1 cd btmp1 - CFLAGS="$CONFIG_CFLAGS" LDFLAGS="$CONFIG_LDFLAGS" CC="$CONFIG_CC" ../configure + case $(uname) in + Darwin) + # Tell configure which compiler etc. to use to match cmake + # Tell configure to pad the executable the same way cmake will + CC="$(xcrun --find gcc || echo gcc)" \ + CFLAGS="-DNDEBUG -O3 -isysroot $(xcrun --show-sdk-path)" \ + LDFLAGS="-Wl,-headerpad_max_install_names" \ + ../configure + ;; + *) + ../configure + ;; + esac make make install cd .. From 70501a4d6abd711574865d6a8c56bd49d7edda13 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Sat, 23 May 2020 08:52:51 -0700 Subject: [PATCH 7/8] pkgcheck.sh: FreeBSD: configure still moping about switch to clang Probably want to be careful about using same compiler for both builds in general, but for now, hide it behind the FreeBSD conditional, since that's where I hit the problem. --- tooling/pkgcheck.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tooling/pkgcheck.sh b/tooling/pkgcheck.sh index 49ff8ef4e..d53c4cdbf 100644 --- a/tooling/pkgcheck.sh +++ b/tooling/pkgcheck.sh @@ -21,6 +21,22 @@ cd btmp1 LDFLAGS="-Wl,-headerpad_max_install_names" \ ../configure ;; + FreeBSD) + # 1) configure really doesn't like falling back to cc + # 2) Force same CC for configure and clang + if clang --version + then + export CC=clang + ../configure + elif gcc --version + then + export CC=gcc + ../configure + else + # will probably fail + ../configure + fi + ;; *) ../configure ;; From 9e26c192b1818309be3cfa90020ebb272acca0a4 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Sat, 23 May 2020 10:27:59 -0700 Subject: [PATCH 8/8] pkgcheck: bsd: don't trust ar --- tooling/pkgcheck.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tooling/pkgcheck.sh b/tooling/pkgcheck.sh index d53c4cdbf..f13116f28 100644 --- a/tooling/pkgcheck.sh +++ b/tooling/pkgcheck.sh @@ -22,8 +22,10 @@ cd btmp1 ../configure ;; FreeBSD) - # 1) configure really doesn't like falling back to cc - # 2) Force same CC for configure and clang + # 1) tell configure to tell ar to be deterministic? + # 2) configure fails with cc, so use clang or gcc + # 3) Force same CC for configure and clang + #export ARFLAGS="Drc" if clang --version then export CC=clang @@ -64,6 +66,12 @@ Darwin) dd conv=notrunc if=/dev/zero of=$dylib1 skip=1337 count=16 dd conv=notrunc if=/dev/zero of=$dylib2 skip=1337 count=16 ;; +FreeBSD) + # I had trouble passing -D to the ar inside CMakeLists.txt, + # so punt and unpack the archive before comparing. + cd pkgtmp1; ar x usr/local/lib/libz.a; rm usr/local/lib/libz.a; cd .. + cd pkgtmp2; ar x usr/local/lib/libz.a; rm usr/local/lib/libz.a; cd .. + ;; esac if diff -Nur pkgtmp1 pkgtmp2