1#!/bin/sh -
2#
3# $Id: chk.inc,v 12.1 2008/05/07 12:46:43 bschmeck Exp $
4#
5# Check for inclusion of db_config.h after "const" or other includes.
6
7d=../..
8
9# Test must be run from the top-level directory, not from a test directory.
10[ -f $d/LICENSE ] || {
11	echo 'FAIL: cannot find source distribution directory.'
12	exit 1
13}
14
15t1=__1
16t2=__2
17
18(cd $d && find . -name '*.[chys]' -o -name '*.cpp' |
19    xargs egrep -l '#include.*db_config.h') | tee /tmp/o |
20    sed -e '/dbdemo.c$/d' \
21        -e '/db_java_wrap.c$/d' \
22	-e '/ex_apprec.c$/d' > $t1
23
24(for i in `cat $t1`; do
25	egrep -w 'db_config.h|const' /dev/null $d/$i | head -1
26done) > $t2
27
28if egrep const $t2 > /dev/null; then
29	echo 'FAIL: found const before include of db_config.h'
30	egrep const $t2
31	exit 1
32fi
33
34:> $t2
35for i in `cat $t1`; do
36	egrep -w '#include' /dev/null $d/$i | head -1 >> $t2
37done
38
39if egrep -v db_config.h $t2 > /dev/null; then
40	echo 'FAIL: found includes before include of db_config.h'
41	egrep -v db_config.h $t2
42	exit 1
43fi
44
45exit 0
46