1#!/bin/sh -
2#
3# $Id: chk.code,v 12.2 2007/04/20 13:50:31 bostic Exp $
4#
5# Check to make sure that the code samples in the documents build.
6
7d=../../docs_src
8
9[ -d $d ] || {
10	echo 'FAIL: cannot find source distribution directory.'
11	exit 1
12}
13[ -f ../libdb.a ] || (cd .. && make libdb.a) || {
14	echo 'FAIL: unable to find or build libdb.a'
15	exit 1
16}
17
18exitv=0
19for i in `find $d -name '*.cs' | sed '/\/ref_xml\//d'`; do
20	echo "	compiling $i"
21	sed -e 's/m4_include(\(.*\))/#include <\1>/g' \
22	    -e 's/m4_[a-z]*[(\[)]*//g' \
23	    -e 's/(\[//g' \
24	    -e '/argv/!s/])//g' \
25	    -e 's/dnl//g' \
26	    -e 's/__GT__/>/g' \
27	    -e 's/__LB__/[/g' \
28	    -e 's/__LT__/</g' \
29	    -e 's/__RB__/]/g' < $i > t.c
30	if cc -pthread -Wall -Werror -I.. t.c ../libdb.a -o t; then
31		:
32	else
33		echo "FAIL: unable to compile $i"
34		exitv=1
35	fi
36done
37
38exit $exitv
39