Third-party configuration scripts may produce undesirable additions to CFLAGS/CPPFLAGS
authorAlexander Bokovoy <ab@samba.org>
Sat, 15 Feb 2003 22:51:15 +0000 (22:51 +0000)
committerAlexander Bokovoy <ab@samba.org>
Sat, 15 Feb 2003 22:51:15 +0000 (22:51 +0000)
and LIBS/LDFALGS. In particular, they often don't check where the appropriate libraries
were installed and pass -I/usr/include and -L/usr/lib as part of CFLAGS/LDFLAGS.

While the latter isn't dangerous, passing system include directory through -I lead
to change of its status in CPP from system to user-defined in many cases.

This patch cleans up CFLAGS/CPPFLAGS from errorenous -I/usr/include and LIBS/LDFLAGS
from -L/usr/lib. This is done as two m4 macros which are called before AC_OUTPUT.

source/aclocal.m4
source/configure.in

index 758dfa3b3793cd4a002ca56219bd62cc54f6f1ae..5b1500106cbe437e4539ec0d44161306c0fba54b 100644 (file)
@@ -462,3 +462,26 @@ int main(int argc, char *argv[])
   rm -f conf.mysqltest
 ])
 
+dnl Removes -I/usr/include/? from given variable
+AC_DEFUN(CFLAGS_REMOVE_USR_INCLUDE,[
+  ac_new_flags=""
+  for i in [$]$1; do
+    case [$]i in
+    -I/usr/include|-I/usr/include/) ;;
+    *) ac_new_flags="[$]ac_new_flags [$]i" ;;
+    esac
+  done
+  $1=[$]ac_new_flags
+])
+    
+dnl Removes -L/usr/lib/? from given variable
+AC_DEFUN(LIB_REMOVE_USR_LIB,[
+  ac_new_flags=""
+  for i in [$]$1; do
+    case [$]i in
+    -L/usr/lib|-L/usr/lib/) ;;
+    *) ac_new_flags="[$]ac_new_flags [$]i" ;;
+    esac
+  done
+  $1=[$]ac_new_flags
+])
index c999326b153c1f7d7f25cee69d4ac23bc6f7c39a..25cc8bd250ae35a230ea67c7821d0effb8b4dd31 100644 (file)
@@ -3373,6 +3373,14 @@ AC_TRY_RUN([#include "${srcdir-.}/tests/summary.c"],
 builddir=`pwd`
 AC_SUBST(builddir)
 
+dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
+LIB_REMOVE_USR_LIB(LDFLAGS)
+LIB_REMOVE_USR_LIB(LIBS)
+
+dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
+CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
+CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
+
 AC_OUTPUT(include/stamp-h Makefile script/findsmb)
 
 #################################################