#!/bin/sh -
#
# Id: chk.code,v 1.1 2001/05/08 15:07:05 bostic Exp 
#
# Check to make sure that the code samples in the documents build.

# Run from the top-level directory.
[ -f db_config.h ] || {
	echo 'chk.code must be run from a build directory.'
	exit 1
}

t1=/tmp/__1

find ../docs_src -name '*.cs' > ${t1}

for i in `cat ${t1}`; do
	echo "$i ..."
	sed -e 's/m4_include(\(.*\))/#include <\1>/g' \
	    -e 's/m4_[a-z]*[(\[)]*//g' \
	    -e 's/(\[//g' \
	    -e '/argv/!s/])//g' \
	    -e 's/dnl//g' \
	    -e 's/__GT__/>/g' \
	    -e 's/__LB__/[/g' \
	    -e 's/__LT__/</g' \
	    -e 's/__RB__/]/g' < $i > t.c
	if cc -Wall -I. t.c libdb.a -o t; then
		:
	else
		exit 1
	fi
done
	
rm -f ${t1}
