1#!/bin/sh -
2#	$Id: s_include,v 12.8 2007/02/22 17:52:51 bostic Exp $
3#
4# Build the automatically generated function prototype files.
5
6msgc="/* DO NOT EDIT: automatically built by dist/s_include. */"
7
8. ./RELEASE
9
10head()
11{
12	defonly=0
13	while :
14		do case "$1" in
15		space)
16			echo ""; shift;;
17		defonly)
18			defonly=1; shift;;
19		*)
20			name="$1"; break;;
21		esac
22	done
23
24	echo "$msgc"
25	echo "#ifndef	$name"
26	echo "#define	$name"
27	echo ""
28	if [ $defonly -eq 0 ]; then
29		echo "#if defined(__cplusplus)"
30		echo "extern \"C\" {"
31		echo "#endif"
32		echo ""
33	fi
34}
35
36tail()
37{
38	defonly=0
39	while :
40		do case "$1" in
41		defonly)
42			defonly=1; shift;;
43		*)
44			name="$1"; break;;
45		esac
46	done
47
48	echo ""
49	if [ $defonly -eq 0 ]; then
50		echo "#if defined(__cplusplus)"
51		echo "}"
52		echo "#endif"
53	fi
54	echo "#endif /* !$name */"
55}
56
57# We are building several files:
58#	1 external #define file
59#	1 external prototype file
60#	1 internal #define file
61#	N internal prototype files
62e_dfile=/tmp/__db_c.$$
63e_pfile=/tmp/__db_a.$$
64i_dfile=/tmp/__db_d.$$
65i_pfile=/tmp/__db_b.$$
66trap 'rm -f $e_dfile $e_pfile $i_dfile $i_pfile; exit 0' 0 1 2 3 13 15
67
68head defonly space _DB_EXT_DEF_IN_ > $e_dfile
69head space _DB_EXT_PROT_IN_ > $e_pfile
70head defonly _DB_INT_DEF_IN_ > $i_dfile
71
72# Process the standard directories, creating per-directory prototype
73# files and adding to the external prototype and #define files.
74for i in db btree clib common crypto dbreg env fileops hash hmac \
75    lock log mp mutex os qam rep repmgr rpc_client rpc_server \
76    sequence tcl txn xa; do
77	head "_${i}_ext_h_" > $i_pfile
78
79	if [ $i = os ] ; then
80		f=`ls ../$i/*.c \
81	    ../os_brew/*.c ../os_qnx/*.c ../os_vxworks/*.c ../os_windows/*.c`
82	elif [ $i = rpc_server ] ; then
83		f=`ls ../$i/c/*.c`
84	elif [ $i = crypto ] ; then
85		f=`ls ../$i/*.c ../$i/*/*.c`
86	elif [ $i = env ] ; then
87		f=`ls ../$i/*.c ../repmgr/repmgr_stub.c`
88	else
89		f=`ls ../$i/*.c`
90	fi
91	awk -f gen_inc.awk \
92	    -v db_version_unique_name=$DB_VERSION_UNIQUE_NAME \
93	    -v e_dfile=$e_dfile \
94	    -v e_pfile=$e_pfile \
95	    -v i_dfile=$i_dfile \
96	    -v i_pfile=$i_pfile $f
97
98	tail "_${i}_ext_h_" >> $i_pfile
99
100	f=../dbinc_auto/${i}_ext.h
101	cmp $i_pfile $f > /dev/null 2>&1 ||
102	    (echo "Building $f" && rm -f $f && cp $i_pfile $f && chmod 444 $f)
103done
104
105# Process directories which only add to the external prototype and #define
106# files.
107for i in dbm hsearch; do
108	f=`ls ../$i/*.c`
109	awk -f gen_inc.awk \
110	    -v db_version_unique_name=$DB_VERSION_UNIQUE_NAME \
111	    -v e_dfile=$e_dfile \
112	    -v e_pfile=$e_pfile \
113	    -v i_dfile="" \
114	    -v i_pfile="" $f
115done
116
117# There are a few globals in DB -- add them to the external/internal
118# #define files.
119(echo "#define	__db_global_values __db_global_values@DB_VERSION_UNIQUE_NAME@";
120    echo "#define	__db_jump __db_jump@DB_VERSION_UNIQUE_NAME@") >> $i_dfile
121(echo "#define	db_xa_switch db_xa_switch@DB_VERSION_UNIQUE_NAME@") >> $e_dfile
122
123# Wrap up the external #defines/prototypes, and internal #defines.
124tail defonly _DB_EXT_DEF_IN_ >> $e_dfile
125f=../dbinc_auto/ext_def.in
126cmp $e_dfile $f > /dev/null 2>&1 ||
127    (echo "Building $f" && rm -f $f && cp $e_dfile $f && chmod 444 $f)
128
129tail _DB_EXT_PROT_IN_ >> $e_pfile
130f=../dbinc_auto/ext_prot.in
131cmp $e_pfile $f > /dev/null 2>&1 ||
132    (echo "Building $f" && rm -f $f && cp $e_pfile $f && chmod 444 $f)
133
134tail defonly _DB_INT_DEF_IN_ >> $i_dfile
135f=../dbinc_auto/int_def.in
136cmp $i_dfile $f > /dev/null 2>&1 ||
137    (echo "Building $f" && rm -f $f && cp $i_dfile $f && chmod 444 $f)
138
139# DB185 compatibility support.
140head space defonly _DB_EXT_185_DEF_IN_ > $e_dfile
141head space _DB_EXT_185_PROT_IN_ > $e_pfile
142
143f=`ls ../db185/*.c`
144awk -f gen_inc.awk \
145    -v db_version_unique_name=$DB_VERSION_UNIQUE_NAME \
146    -v e_dfile=$e_dfile \
147    -v e_pfile=$e_pfile \
148    -v i_dfile="" \
149    -v i_pfile="" $f
150
151tail defonly _DB_EXT_185_DEF_IN_ >> $e_dfile
152f=../dbinc_auto/ext_185_def.in
153cmp $e_dfile $f > /dev/null 2>&1 ||
154    (echo "Building $f" && rm -f $f && cp $e_dfile $f && chmod 444 $f)
155
156tail _DB_EXT_185_PROT_IN_ >> $e_pfile
157f=../dbinc_auto/ext_185_prot.in
158cmp $e_pfile $f > /dev/null 2>&1 ||
159    (echo "Building $f" && rm -f $f && cp $e_pfile $f && chmod 444 $f)
160