From: Daniel Axtens Date: Tue, 5 May 2015 12:00:53 +0000 (+1000) Subject: Don't delete SRCDIR/zconf.h when building out of tree X-Git-Tag: 1.9.9-b1~865^2 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F17%2Fhead;p=thirdparty%2Fzlib-ng.git Don't delete SRCDIR/zconf.h when building out of tree 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 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 --- diff --git a/configure b/configure index 1f9aaea2..ab1683c6 100755 --- 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 4a4beaf1..bd49761f 100644 --- 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 diff --git a/zconf.h.cmakein b/zconf.h.cmakein index 92d461d0..6f70f753 100644 --- a/zconf.h.cmakein +++ b/zconf.h.cmakein @@ -5,6 +5,8 @@ /* @(#) $Id$ */ +#error "Error: unprepared zconf.h included. Build system broken." + #ifndef ZCONF_H #define ZCONF_H #cmakedefine Z_PREFIX diff --git a/zconf.h.in b/zconf.h.in index 4a4beaf1..bd49761f 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -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 5488524f..b9672efa 100644 --- a/zlib.h +++ b/zlib.h @@ -31,7 +31,7 @@ #ifndef ZLIB_H #define ZLIB_H -#include "zconf.h" +#include #ifdef __cplusplus extern "C" {