1#!/bin/sh -
2#
3# $Id$
4#
5# Check to make sure the auto-generated utility code in the VxWorks build
6# directory compiles.
7
8d=../..
9
10[ -f $d/LICENSE ] || {
11	echo 'FAIL: cannot find source distribution directory.'
12	exit 1
13}
14[ -f ../libdb.a ] || (cd .. && make libdb.a) || {
15	echo 'FAIL: unable to find or build libdb.a'
16	exit 1
17}
18
19F="$d/clib/getopt.c $d/common/util_arg.c $d/common/util_cache.c
20	$d/common/util_log.c $d/common/util_sig.c $d/*/*_autop.c"
21
22header()
23{
24	echo "int $1(int, char *[]);"
25	echo "int"
26	echo "main(int argc, char *argv[])"
27	echo "{return ($1(argc, argv));}"
28}
29
30LIST="\
31    db_archive \
32    db_checkpoint \
33    db_deadlock \
34    db_dump \
35    db_hotbackup \
36    db_load \
37    db_printlog \
38    db_recover \
39    db_stat \
40    db_upgrade \
41    db_verify \
42    dbdemo \
43    test_micro"
44
45# Build each program individually.
46for i in $LIST; do
47	echo "	compiling Vxworks version of $i"
48	header $i > MAIN.c
49	if cc -Wall -I.. -I$d -I$d/build_vxworks/$i \
50	    $d/build_vxworks/$i/*.c MAIN.c $F ../libdb.a -o t; then
51		:
52	else
53		echo "FAIL: unable to compile VxWorks version of $i"
54		exit 1
55	fi
56done
57
58# Build all of the programs as one big binary.
59inc=`echo $LIST | sed 's/[^ ][^ ]*/-I$d\/build_vxworks\/&/g'`
60src=`echo $LIST | sed 's/[^ ][^ ]*/$d\/build_vxworks\/&\/*.c/g'`
61
62(
63for i in $LIST; do
64	echo "int ${i}_main(int, char *[]);"
65done
66echo "int"
67echo "main(int argc, char *argv[])"
68echo "{"
69echo "int r;"
70for i in $LIST; do
71	echo "r += ${i}_main(argc, argv);"
72done
73echo "return (r);"
74echo "}"
75) > MAIN.c
76
77echo "	compiling VxWorks utility composite"
78if cc -Wall -I.. -I$d $inc `eval ls $src` MAIN.c $F ../libdb.a -o t; then
79	:
80else
81	echo 'FAIL: unable to compile VxWorks utility composite'
82	exit 1
83fi
84
85exit 0
86