1#!/bin/sh -
2#
3# $Id: chk.build,v 12.10 2007/05/21 13:14:20 bostic Exp $
4#
5# Build a program that calls the run-time API configuration functions.
6
7trap 'rm -rf scr030 ; exit 0' 0
8trap 'rm -rf scr030 ; exit 1' 1 2 3 13 15
9
10[ -d ../../dist ] || {
11	echo 'FAIL: unable to find top-level dist directory'
12	exit 1
13}
14
15# Flags to build Java.
16JAVA_INC=/usr/local/diablo-jdk1.5.0/include
17JAVA_FLAGS="-I$JAVA_INC -I$JAVA_INC/linux -I$JAVA_INC/freebsd"
18
19# Configure and build.
20#	$1: config flags
21config()
22{
23	(echo `date`; echo "run: $1: $dir") | tee CONFIGURATION
24
25	../../../dist/configure $1 > config.OUT 2>&1
26	if test $? -ne 0; then
27		echo "$i: FAILED in configure"
28		return 1
29	fi
30
31	if `echo "$1" | grep disable-statistics > /dev/null`; then
32		echo '#define __TEST_DB_NO_STATISTICS 1' >> db_config.h
33	fi
34
35	(echo /^CFLAGS=/ &&
36	# Configure gcc to complain about everything, and make warnings fatal
37	# errors.
38	echo \
39	's/-c /-c -W -Werror -Wall -Wpointer-arith -Wmissing-prototypes /' &&
40	# Warnings are fatal errors, so don't set gcc warning flags for files
41	# where we can't avoid warnings.
42	echo '/^db_server_svc.*: .*db_server_svc.c$/' &&
43	echo '+1s/\$(CFLAGS)/-c \$(CPPFLAGS)/' &&
44	echo '/^db_server_util.*: .*db_server_util.c$/' &&
45	echo '+1s/\$(CFLAGS)/-c \$(CPPFLAGS)/' &&
46	echo '/^db_server_xdr.*: .*db_server_xdr.c$/' &&
47	echo '+1s/\$(CFLAGS)/-c \$(CPPFLAGS)/' &&
48	echo '/^gen_db_server.*: .*gen_db_server.c$/' &&
49	echo '+1s/\$(CFLAGS)/-c \$(CPPFLAGS)/' &&
50	echo '/^db_java_wrap.*: .*db_java_wrap.c$/' &&
51	echo '+1s/\$(CFLAGS)/-c \$(CPPFLAGS)/' &&
52	echo '/^tcl_db_pkg.*: .*tcl_db_pkg.c$/' &&
53	echo '+1s/\$(CFLAGS)/-c \$(CPPFLAGS)/' &&
54	echo w &&
55	echo q) | ed Makefile > /dev/null
56
57	# If we're compiling Java, we'll need to set up the path.
58	echo "$1" | grep enable-java > /dev/null
59	if test $? -eq 0; then
60		(echo /^CPPFLAGS=/ &&
61		echo "s;\$; $JAVA_FLAGS;" &&
62		echo w &&
63		echo q) | ed Makefile > /dev/null
64	fi
65
66	make > mklog 2>&1 && make ex_access >> mklog 2>&1
67	if test $? -ne 0; then
68		echo "$i: FAILED in make"
69		return 1
70	fi
71
72	(echo a; echo b; echo c) | ./ex_access > /dev/null 2>&1
73	return $?
74}
75
76# Run a test.
77#	$1: config flags
78count=0
79r()
80{
81	count=$(expr $count + 1)
82	dir="scr030.$count"
83	(rm -rf $dir && mkdir $dir && cd $dir && config "$1")
84	if test $? -eq 0; then
85		rm -rf $dir
86	else
87		echo "$1: FAILED to build"
88	fi
89}
90
91# Run through all of the standard single options.
92s="\
93--disable-cryptography \
94--disable-hash \
95--disable-largefile \
96--disable-mutexsupport \
97--disable-queue \
98--disable-replication \
99--disable-statistics \
100--disable-verify \
101--enable-compat185 \
102--enable-debug \
103--enable-debug_rop \
104--enable-debug_wop \
105--enable-diagnostic \
106--enable-dump185 \
107--enable-posixmutexes \
108--enable-rpc \
109--enable-smallbuild \
110--enable-umrw \
111--with-mutex=UNIX/fcntl \
112--with-mutex=x86/gcc-assembly \
113--with-uniquename=__KEITH__"
114for i in $s; do
115	r "$i --disable-shared"
116done
117
118# Build specific runs of interest.
119r
120r "--disable-static"
121r "--enable-cxx"
122r "--enable-java"
123r "--with-tcl=/usr/local/lib/tcl8.4"
124r "--enable-test --with-tcl=/usr/local/lib/tcl8.4"
125r "--enable-cxx --enable-java --with-tcl=/usr/local/lib/tcl8.4"
126