aboutsummaryrefslogtreecommitdiff
path: root/src/tools/pginclude/cpluspluscheck
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2019-06-02 13:45:01 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2019-06-02 13:45:01 -0400
commitf4755a2c01486519cfce5b21ab04529ad26f5ed1 (patch)
treecf2064aa302dedcdc6c50c86d9053db2be609afa /src/tools/pginclude/cpluspluscheck
parent032627ee7837f0baa539df7247e003dbaded2c90 (diff)
downloadpostgresql-f4755a2c01486519cfce5b21ab04529ad26f5ed1.tar.gz
postgresql-f4755a2c01486519cfce5b21ab04529ad26f5ed1.zip
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.
Diffstat (limited to 'src/tools/pginclude/cpluspluscheck')
-rwxr-xr-xsrc/tools/pginclude/cpluspluscheck20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/tools/pginclude/cpluspluscheck b/src/tools/pginclude/cpluspluscheck
index b3fc75de48a..b2060f3f538 100755
--- a/src/tools/pginclude/cpluspluscheck
+++ b/src/tools/pginclude/cpluspluscheck
@@ -24,14 +24,23 @@ fi
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.
MGLOB="$builddir/src/Makefile.global"
+CPPFLAGS=`sed -n 's/^CPPFLAGS[ ]*=[ ]*//p' "$MGLOB"`
CXX=`sed -n 's/^CXX[ ]*=[ ]*//p' "$MGLOB"`
perl_includespec=`sed -n 's/^perl_includespec[ ]*=[ ]*//p' "$MGLOB"`
python_includespec=`sed -n 's/^python_includespec[ ]*=[ ]*//p' "$MGLOB"`
-# These switches are g++ specific, you may override if necessary.
-CXXFLAGS=${CXXFLAGS:- -fsyntax-only -Wall}
+# Extract any -I and -D switches from CPPFLAGS.
+# (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.
tmp=`mktemp -d /tmp/$me.XXXXXX`
@@ -65,11 +74,16 @@ do
# Likewise, these files are platform-specific, and the one
# 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-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/generic.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-msvc.h && continue
+ test "$f" = src/include/port/atomics/generic-sunpro.h && continue
test "$f" = src/include/port/atomics/generic-xlc.h && continue
# rusagestub.h is also platform-specific, and will be included
@@ -145,6 +159,6 @@ do
${CXX:-g++} -I $builddir -I $srcdir \
-I $builddir/src/include -I $srcdir/src/include \
-I $builddir/src/interfaces/libpq -I $srcdir/src/interfaces/libpq \
- $EXTRAINCLUDES $CXXFLAGS -c $tmp/test.cpp
+ $EXTRAINCLUDES $EXTRAFLAGS $CXXFLAGS -c $tmp/test.cpp
done