]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Don't delete SRCDIR/zconf.h when building out of tree 17/head
authorDaniel Axtens <dja@axtens.net>
Tue, 5 May 2015 12:00:53 +0000 (22:00 +1000)
committerDaniel Axtens <dja@axtens.net>
Tue, 5 May 2015 13:38:48 +0000 (23:38 +1000)
This avoids dirtying the source directory when building out of tree

Various build changes to make sure this works:
 - Includes for arch dir specify BUILDDIR before SRCDIR
 - #include <zconf.h> instead of "zconf.h": that way the include order
   takes effect.
 - Insert an #error directive in the original zconf.h that we process out.
   That way we can be sure we are including the right one when building
   out of tree.

Signed-off-by: Daniel Axtens <dja@axtens.net>
configure
zconf.h
zconf.h.cmakein
zconf.h.in
zlib.h

index 1f9aaea2634103fbc87c7c46f873ab4416613cea..ab1683c6ab2a61b470b5cbd8205ab953d9637556 100755 (executable)
--- a/configure
+++ b/configure
@@ -421,9 +421,6 @@ else
   echo "Checking for strerror... No." | tee -a configure.log
 fi
 
-# We need to remove zconf.h from source directory if building outside of it
-if [ "$SRCDIR" != "$BUILDDIR" ]; then rm -f $SRCDIR/zconf.h; fi
-
 # copy clean zconf.h for subsequent edits
 cp -p $SRCDIR/zconf.h.in zconf.h
 
@@ -465,6 +462,10 @@ if test $zprefix -eq 1; then
   echo "Using z_ prefix on all symbols." | tee -a configure.log
 fi
 
+# take out the error path that makes sure an out of tree build doesn't touch the source tree's zconf.h
+sed < zconf.h 's/#error.*//' > zconf.temp.h
+mv zconf.temp.h zconf.h
+
 # if --solo compilation was requested, save that in zconf.h and remove gz stuff from object lists
 if test $solo -eq 1; then
   sed '/#define ZCONF_H/a\
@@ -742,7 +743,7 @@ sed < $SRCDIR/Makefile.in "
 mkdir -p $ARCHDIR
 
 ARCHINCLUDES="-I$SRCDIR/$ARCHDIR -I$SRCDIR"
-if [ "$SRCDIR" != "$BUILDDIR" ]; then ARCHINCLUDES="${ARCHINCLUDES} -I$BUILDDIR"; fi
+if [ "$SRCDIR" != "$BUILDDIR" ]; then ARCHINCLUDES="-I$BUILDDIR ${ARCHINCLUDES}"; fi
 
 sed < $SRCDIR/$ARCHDIR/Makefile.in "
 /^CC *=/s#=.*#=$CC#
diff --git a/zconf.h b/zconf.h
index 4a4beaf14fe904f2246e5a32d73575f04552ae5b..bd49761f35c1e757e223f8af9f0439e8d2508366 100644 (file)
--- a/zconf.h
+++ b/zconf.h
@@ -5,6 +5,8 @@
 
 /* @(#) $Id$ */
 
+#error "Error: unprepared zconf.h included. Build system broken."
+
 #ifndef ZCONF_H
 #define ZCONF_H
 
index 92d461d079e6f9015f6fdd2ddfa9a9868d9765ea..6f70f75334f210f274d8b333356154671ecfd18f 100644 (file)
@@ -5,6 +5,8 @@
 
 /* @(#) $Id$ */
 
+#error "Error: unprepared zconf.h included. Build system broken."
+
 #ifndef ZCONF_H
 #define ZCONF_H
 #cmakedefine Z_PREFIX
index 4a4beaf14fe904f2246e5a32d73575f04552ae5b..bd49761f35c1e757e223f8af9f0439e8d2508366 100644 (file)
@@ -5,6 +5,8 @@
 
 /* @(#) $Id$ */
 
+#error "Error: unprepared zconf.h included. Build system broken."
+
 #ifndef ZCONF_H
 #define ZCONF_H
 
diff --git a/zlib.h b/zlib.h
index 5488524ff1e09a98f81d4818d62bc0e9afa5e8ec..b9672efaa9fe68f60a347f9a60aedef3f4b60162 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -31,7 +31,7 @@
 #ifndef ZLIB_H
 #define ZLIB_H
 
-#include "zconf.h"
+#include <zconf.h>
 
 #ifdef __cplusplus
 extern "C" {