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