From: Paweł Wegner Date: Thu, 13 May 2021 15:15:37 +0000 (+0200) Subject: Handle HAVE_UNISTD_H defined to 0. X-Git-Tag: 2.0.4~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b295830835bb51da3b2dd5f733b040b315d5464a;p=thirdparty%2Fzlib-ng.git Handle HAVE_UNISTD_H defined to 0. FFmpeg during the configure stage generates a config.h file with ``` #define HAVE_UNISTD_H 0 ``` on windows. Then somewhere in FFmpeg's code there is: ``` #include "config.h" // FFmpeg's config.h #include ``` which causes zlib.h to include unistd.h on windows. It is way easier to handle the issue here than in FFmpeg. Co-authored-by: Mika Lindqvist --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a7ff3b09d..f461b258a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1055,7 +1055,7 @@ endif() if(HAVE_UNISTD_H) SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") else() - SET(ZCONF_UNISTD_LINE "#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */") + SET(ZCONF_UNISTD_LINE "#if 0 /* was set to #if 0 by configure/cmake/etc */") endif() if(NEED_PTRDIFF_T) SET(ZCONF_PTRDIFF_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") diff --git a/configure b/configure index 4e6645dc5..353cad4d8 100755 --- a/configure +++ b/configure @@ -777,6 +777,8 @@ if try $CC -c $CFLAGS $test.c; then mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h echo "Checking for unistd.h... Yes." | tee -a configure.log else + sed < zconf${SUFFIX}.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be set to #if 1/ 0\1 was set to #if 0/" > zconf${SUFFIX}.temp.h + mv zconf${SUFFIX}.temp.h zconf${SUFFIX}.h echo "Checking for unistd.h... No." | tee -a configure.log fi