Changes.
[cairo/gpu.git] / src / check-preprocessor-syntax.sh
blob4e8efaa334bb004a65e3e61b4cc6f1eab13892ac
1 #!/bin/sh
3 LANG=C
5 test -z "$srcdir" && srcdir=.
6 cd "$srcdir"
7 stat=0
10 HEADERS=$all_cairo_headers
11 test "x$HEADERS" = x && HEADERS=`find . -name 'cairo*.h' ! -name 'cairo*-private.h' ! -name 'cairoint.h'`
13 PRIVATE=$all_cairo_private
14 test "x$PRIVATE" = x && PRIVATE=`find . -name 'cairo*-private.h' -or -name 'cairoint.h'`
16 SOURCES=$all_cairo_sources
17 test "x$SOURCES" = x && SOURCES=`find . -name 'cairo*.c' -or -name 'cairo*.cpp'`
19 ALL="/dev/null $HEADERS $PRIVATE $SOURCES"
21 echo 'Checking that public header files #include "cairo.h" first (or none)'
23 for x in $HEADERS; do
24 grep '#.*\<include\>' "$x" /dev/null | head -n 1
25 done |
26 grep -v '"cairo[.]h"' |
27 grep -v 'cairo[.]h:' |
28 grep . >&2 && stat=1
31 echo 'Checking that private header files #include "some cairo header" first (or none)'
33 for x in $PRIVATE; do
34 grep '#.*\<include\>' "$x" /dev/null | head -n 1
35 done |
36 grep -v '"cairo.*[.]h"' |
37 grep -v 'cairoint[.]h:' |
38 grep . >&2 && stat=1
41 echo 'Checking that source files #include "cairoint.h" first (or none)'
43 for x in $SOURCES; do
44 grep '#.*\<include\>' "$x" /dev/null | head -n 1
45 done |
46 grep -v '"cairoint[.]h"' |
47 grep . >&2 && stat=1
50 echo 'Checking that there is no #include <cairo.*.h>'
51 grep '#.*\<include\>.*<.*cairo' $ALL >&2 && stat=1
54 echo 'Checking that feature conditionals are used with #if only (not #ifdef)'
55 grep '#ifdef CAIRO_HAS_' $ALL && stat=1
56 grep '#if.*defined[ ]*(CAIRO_HAS_' $ALL && stat=1
58 exit $stat