Make test_headers more automatic.
[darkstat] / test_headers.sh
1 #!/bin/sh
2 # copyright (c) 2011 Emil Mikulic.
3
4 a="\033[31;1m"
5 z="\033[m"
6
7 # Except for the c-ify output, every header should bring in all of its
8 # dependencies, and be able to be included multiple times.
9 src=_test_hdr.c
10 obj=_test_hdr.o
11 files=`ls *.h | fgrep -v -e graphjs.h -e stylecss.h`
12
13 for f in $files; do
14 cat >$src <<EOF
15 #include "$f"
16 void test_hdr_do_nothing(void) { }
17 EOF
18 if ! gcc -c $src 2>/dev/null; then
19 echo "${a}===> $f can't be included by itself${z}"
20 gcc -c $src
21 else
22 cat >$src <<EOF
23 #include "$f"
24 #include "$f"
25 void test_hdr_do_nothing(void) { }
26 EOF
27 if ! gcc -c $src 2>/dev/null; then
28 echo "${a}===> $f can't be included twice${z}"
29 gcc -c $src
30 fi
31 fi
32 done
33
34 rm $src $obj