]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Handle HAVE_UNISTD_H defined to 0.
authorPaweł Wegner <lemourin@google.com>
Thu, 13 May 2021 15:15:37 +0000 (17:15 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sat, 29 May 2021 13:01:06 +0000 (15:01 +0200)
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 <zlib.h>
```
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 <postmaster@raasu.org>
CMakeLists.txt
configure

index a7ff3b09de4ce6a158dad2112e69b58483d1c164..f461b258a4256f14313183e2211b9f12463248ac 100644 (file)
@@ -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 */")
index 4e6645dc521b3bd5677e6dc5901e102ee433b841..353cad4d801846b78fffe8b61300bd8cfa356a68 100755 (executable)
--- 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