Commits

king  committed dc314a0

ENH: Improved selection of options for GCC. Now includes all options, including macro definitions.

  • Participants
  • Parent commits 270e85d

Comments (0)

Files changed (1)

File GCC_XML/find_gcc_options

 #!/bin/sh
 
 # These options are always needed.
-echo -n "-quiet -o /dev/null -nostdinc -fsyntax-only "
+STANDARD="-quiet -o /dev/null -nostdinc -fsyntax-only"
 
 # Find the include path options.
-echo "" | gcc -v -x c++ -E ${CXXFLAGS} -o /dev/null - 2>&1 |
+INCLUDES=`
+echo "" | gcc -v -x c++ -E -o /dev/null - 2>&1 |
  awk '/^\#include <.*$/   {f=1}
       /^ \/.*$/           { if (f) { printf("-I%s ",$0) } }
-      /^End of search.*$/ {exit}' -
+      /^End of search.*$/ {exit}' - | sed 's/^-I /-I/;s/ -I / -I/g'`
 
-# Find the GCC version options.
+# See if extra -fno-honor-std is needed.
+EXTRA=`
 gcc --version |
   sed 's/[^0-9.]*//g' |
-  awk -F "\." '{ printf("-D__GNUG__=%d -D__GNUC__=%d -D__GNUC_MINOR__=%d ",$1,$1,$2);
-                 if ($1 < 3) {print "-fno-honor-std "}
-                 else {print "-D_GNU_SOURCE "} }'
+  awk -F "\." '{ if ($1 < 3) {printf("-fno-honor-std ") } }'`
+
+# Find the macro definition options.
+MACROS=`
+echo "" |gcc -v -x c++ -E -o /dev/null - 2>&1 | sed -n '
+/__GNUC__/{
+  s/^.*-lang-c++ -v//
+  s/ -isystem.*$//
+  s/ - -o.*$//
+  s/ -undef//
+  s/ -A[^ ]*//g
+  s/ -D\([^=]*\)=\([^ -]\{1,\} [^ -]\{1,\}\)/ -D\1='\''\2'\''/g
+ p
+}
+'`
+
+echo $STANDARD $MACROS $INCLUDES $EXTRA