[PATCH 3 of 3] auto/lib/*: prepend include location with sysroot path

Samuel Martin s.martin49 at gmail.com
Sun May 4 19:33:55 UTC 2014


# HG changeset patch
# User Samuel Martin <s.martin49 at gmail.com>
# Date 1399231473 -7200
#      Sun May 04 21:24:33 2014 +0200
# Node ID b9787fdc8bac3559fd9da679dc04e8fc50cb74f3
# Parent  03617a96c528d1f02abf829df964fcb29b06c942
auto/lib/*: prepend include location with sysroot path

This patch introduce a new NGX_SYSROOT variable used when
cross-compiling with gcc.

When cross-compiling nginx, the gcc-based cross-compiler will
automatically set the NGX_SYSROOT value to the right value. This
variable remains empty if not cross-compiling or no gcc compiler is
detected.
This NGX_SYSROOT is prepended to the ngx_feature_path content when
additional location should be added to the include directory list.

This is necessary to prevent gcc from complaining about unsafe include
location for cross-compilation (-Wpoision-system-directories), currently
only triggered by libxslt.

diff -r 03617a96c528 -r b9787fdc8bac auto/cc/gcc
--- a/auto/cc/gcc	Sun May 04 00:40:49 2014 +0200
+++ b/auto/cc/gcc	Sun May 04 21:24:33 2014 +0200
@@ -15,6 +15,10 @@
 
 have=NGX_COMPILER value="\"gcc $NGX_GCC_VER\"" . auto/define
 
+# set sysroot in case of cross-compilation
+if [ x$NGX_CROSSBUILD = xcrossbuild ]; then
+    NGX_SYSROOT=`$CC -print-sysroot`
+fi
 
 # Solaris 7's /usr/ccs/bin/as does not support "-pipe"
 
diff -r 03617a96c528 -r b9787fdc8bac auto/lib/libxslt/conf
--- a/auto/lib/libxslt/conf	Sun May 04 00:40:49 2014 +0200
+++ b/auto/lib/libxslt/conf	Sun May 04 21:24:33 2014 +0200
@@ -12,7 +12,7 @@
                       #include <libxslt/xsltInternals.h>
                       #include <libxslt/transform.h>
                       #include <libxslt/xsltutils.h>"
-    ngx_feature_path="/usr/include/libxml2"
+    ngx_feature_path="$NGX_SYSROOT/usr/include/libxml2"
     ngx_feature_libs="-lxml2 -lxslt"
     ngx_feature_test="xmlParserCtxtPtr    ctxt = NULL;
                       xsltStylesheetPtr   sheet = NULL;
diff -r 03617a96c528 -r b9787fdc8bac auto/options
--- a/auto/options	Sun May 04 00:40:49 2014 +0200
+++ b/auto/options	Sun May 04 21:24:33 2014 +0200
@@ -33,6 +33,7 @@
 NGX_TEST_BUILD_SOLARIS_SENDFILEV=NO
 
 NGX_CROSSBUILD=
+NGX_SYSROOT=
 NGX_PLATFORM=
 NGX_WINE=
 



More information about the nginx-devel mailing list