Commit f4755a2c authored by Tom Lane's avatar Tom Lane

Make cpluspluscheck more portable.

Teach it to scrape -I and -D switches from CPPFLAGS in Makefile.global.
This is useful for testing on, eg, FreeBSD, where you won't get far
without "-I/usr/local/include".

Also, expand the set of blacklisted-for-unportability atomics headers,
based on noting that arch-x86.h fails to compile on an ARM box.  The
other ones I'd omitted seem to compile all right on architectures they
don't belong to, but that's surely too shaky to rely on.  Let's do
like we did for the src/include/port/ headers, and ignore all except
the variant that's pulled in by the arch-independent header.
parent 032627ee
...@@ -24,14 +24,23 @@ fi ...@@ -24,14 +24,23 @@ fi
me=`basename $0` me=`basename $0`
# These switches are g++ specific, you may override if necessary.
CXXFLAGS=${CXXFLAGS:- -fsyntax-only -Wall}
# Pull some info from configure's results. # Pull some info from configure's results.
MGLOB="$builddir/src/Makefile.global" MGLOB="$builddir/src/Makefile.global"
CPPFLAGS=`sed -n 's/^CPPFLAGS[ ]*=[ ]*//p' "$MGLOB"`
CXX=`sed -n 's/^CXX[ ]*=[ ]*//p' "$MGLOB"` CXX=`sed -n 's/^CXX[ ]*=[ ]*//p' "$MGLOB"`
perl_includespec=`sed -n 's/^perl_includespec[ ]*=[ ]*//p' "$MGLOB"` perl_includespec=`sed -n 's/^perl_includespec[ ]*=[ ]*//p' "$MGLOB"`
python_includespec=`sed -n 's/^python_includespec[ ]*=[ ]*//p' "$MGLOB"` python_includespec=`sed -n 's/^python_includespec[ ]*=[ ]*//p' "$MGLOB"`
# These switches are g++ specific, you may override if necessary. # Extract any -I and -D switches from CPPFLAGS.
CXXFLAGS=${CXXFLAGS:- -fsyntax-only -Wall} # (If necessary, user can pass more switches by presetting EXTRAFLAGS.)
for flag in $CPPFLAGS; do
case $flag in
-I*|-D*) EXTRAFLAGS="$EXTRAFLAGS $flag";;
esac
done
# Create temp directory. # Create temp directory.
tmp=`mktemp -d /tmp/$me.XXXXXX` tmp=`mktemp -d /tmp/$me.XXXXXX`
...@@ -65,11 +74,16 @@ do ...@@ -65,11 +74,16 @@ do
# Likewise, these files are platform-specific, and the one # Likewise, these files are platform-specific, and the one
# relevant to our platform will be included by atomics.h. # relevant to our platform will be included by atomics.h.
test "$f" = src/include/port/atomics/arch-arm.h && continue test "$f" = src/include/port/atomics/arch-arm.h && continue
test "$f" = src/include/port/atomics/arch-hppa.h && continue
test "$f" = src/include/port/atomics/arch-ia64.h && continue
test "$f" = src/include/port/atomics/arch-ppc.h && continue
test "$f" = src/include/port/atomics/arch-x86.h && continue
test "$f" = src/include/port/atomics/fallback.h && continue test "$f" = src/include/port/atomics/fallback.h && continue
test "$f" = src/include/port/atomics/generic.h && continue test "$f" = src/include/port/atomics/generic.h && continue
test "$f" = src/include/port/atomics/generic-acc.h && continue test "$f" = src/include/port/atomics/generic-acc.h && continue
test "$f" = src/include/port/atomics/generic-gcc.h && continue test "$f" = src/include/port/atomics/generic-gcc.h && continue
test "$f" = src/include/port/atomics/generic-msvc.h && continue test "$f" = src/include/port/atomics/generic-msvc.h && continue
test "$f" = src/include/port/atomics/generic-sunpro.h && continue
test "$f" = src/include/port/atomics/generic-xlc.h && continue test "$f" = src/include/port/atomics/generic-xlc.h && continue
# rusagestub.h is also platform-specific, and will be included # rusagestub.h is also platform-specific, and will be included
...@@ -145,6 +159,6 @@ do ...@@ -145,6 +159,6 @@ do
${CXX:-g++} -I $builddir -I $srcdir \ ${CXX:-g++} -I $builddir -I $srcdir \
-I $builddir/src/include -I $srcdir/src/include \ -I $builddir/src/include -I $srcdir/src/include \
-I $builddir/src/interfaces/libpq -I $srcdir/src/interfaces/libpq \ -I $builddir/src/interfaces/libpq -I $srcdir/src/interfaces/libpq \
$EXTRAINCLUDES $CXXFLAGS -c $tmp/test.cpp $EXTRAINCLUDES $EXTRAFLAGS $CXXFLAGS -c $tmp/test.cpp
done done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment