2
# remove extra #include's
4
trap "rm -f /tmp/$$.c /tmp/$$.o /tmp/$$ /tmp/$$a /tmp/$$b" 0 1 2 3 15
5
find . \( -name CVS -a -prune \) -o -type f -print |
6
grep -v '\./postgres.h' |
7
grep -v '\./pg_config.h' |
11
if [ "`echo $FILE | sed -n 's/^.*\.\([^\.]*\)$/\1/p'`" = "h" ]
17
if [ "$IS_INCLUDE" = "Y" ]
18
then cat "$FILE" | grep -v "^#if" | grep -v "^#else" |
19
grep -v "^#endif" | sed 's/->[a-zA-Z0-9_\.]*//g' >/tmp/$$a
20
else cat "$FILE" >/tmp/$$a
23
# loop through all includes
24
cat /tmp/$$a | grep "^#include" |
25
sed 's/^#include[ ]*[<"]\([^>"]*\).*$/\1/g' |
28
[ -s /usr/include/$INCLUDE ] && continue
29
[ "$INCLUDE" = postgres.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
41
grep -v '^#include[ ]*[<"]'"$INCLUDE"'[>"]' >/tmp/$$b
42
if [ "$IS_INCLUDE" = "Y" ]
43
then echo "#include \"postgres.h\"" >/tmp/$$.c
46
echo "#include \"/tmp/$$b\"" >>/tmp/$$.c
47
echo "void include_test(void);" >>/tmp/$$.c
48
echo "void include_test() {" >>/tmp/$$.c
49
if [ "$IS_INCLUDE" = "Y" ]
50
then pgdefine "$FILE" >>/tmp/$$.c
53
cc -fsyntax-only -Werror -Wall -Wmissing-prototypes -Wmissing-declarations -I/pg/include -I/pg/backend -c /tmp/$$.c -o /tmp/$$.o >/tmp/$$ 2>&1
55
then echo "$FILE $INCLUDE"
56
if [ "$IS_INCLUDE" = "N" ]
57
then grep -v '^#include[ ][ ]*[<"]'"$INCLUDE"'[>"]' "$FILE" >/tmp/$$b