2 # remove extra #include's
6 trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
7 find . \( -name CVS -a -prune \) -o -type f -name '*.[ch]' -print |
8 grep -v '\./postgres.h' |
9 grep -v '\./pg_config.h' |
13 if [ `expr $FILE : '.*\.h$'` -ne 0 ]
18 # loop through all includes
19 cat "$FILE" | grep "^#include" |
20 sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' |
24 then echo "checking $FILE $INCLUDE"
27 [ -s /usr/include/$INCLUDE ] && continue
28 [ "$INCLUDE" = postgres.h ] && continue
29 [ "$INCLUDE" = postgres_fe.h ] && continue
30 [ "$INCLUDE" = config.h ] && continue
31 [ "$INCLUDE" = c.h ] && continue
33 # preserve configure-specific includes
34 # these includes are surrounded by #ifdef's
35 grep -B1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" |
36 egrep -q '^#if|^#else' && continue
37 grep -A1 '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" |
38 egrep -q '^#else|^#endif' && continue
40 # remove defines from include files
41 if [ "$IS_INCLUDE" = "Y" ]
42 then cat "$FILE" | grep -v "^#if" | grep -v "^#else" |
43 grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a
44 else cat "$FILE" >/tmp/$$a
47 # set up initial file contents
48 grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' \
51 if [ "$IS_INCLUDE" = "Y" ]
52 then echo "#include \"postgres.h\"" >/tmp/$$.c
56 echo "#include \"/tmp/$$b\"" >>/tmp/$$.c
57 echo "void include_test(void);" >>/tmp/$$.c
58 echo "void include_test() {" >>/tmp/$$.c
59 if [ "$IS_INCLUDE" = "Y" ]
60 then pgdefine "$FILE" >>/tmp/$$.c
64 cc -fsyntax-only -Werror -Wall -Wmissing-prototypes \
65 -Wmissing-declarations -I/pg/include -I/pg/backend \
66 -I/pg/interfaces/libpq -I`dirname $FILE` $CFLAGS -c /tmp/$$.c \
67 -o /tmp/$$.o >/tmp/$$ 2>&1
69 then echo "$FILE $INCLUDE"
75 grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' \