2
# $Id: s_vxworks,v 1.37 2002/08/19 21:27:06 bostic Exp $
4
# Build the VxWorks files.
6
msgc="/* DO NOT EDIT: automatically built by dist/s_vxworks. */"
12
vxfilelist=/tmp/__db_c
14
trap 'rm -f $s $t $vxfilelist ; exit 0' 0
15
trap 'rm -f $s $t $vxfilelist ; exit 1' 1 2 3 13 15
17
# Build the VxWorks automatically generated files.
18
f=../build_vxworks/db.h
19
cat <<ENDOFSEDTEXT > $s
25
/* Tornado 2 does not provide a standard C pre-processor #define. */\\
30
s/@u_int8_decl@/typedef unsigned char u_int8_t;/
31
s/@u_int16_decl@/typedef unsigned short u_int16_t;/
32
s/@u_int32_decl@/typedef unsigned int u_int32_t;/
40
s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/
41
s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/
42
s/@DB_VERSION_PATCH@/$DB_VERSION_PATCH/
43
s/@DB_VERSION_STRING@/"$DB_VERSION_STRING"/
44
s/@DB_VERSION_UNIQUE_NAME@//
47
sed -f $s ../dbinc/db.in &&
48
cat ../dbinc_auto/rpc_defs.in &&
49
cat ../dbinc_auto/ext_prot.in) > $t
50
cmp $t $f > /dev/null 2>&1 ||
51
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
53
f=../build_vxworks/db_int.h
54
cat <<ENDOFSEDTEXT > $s
55
s/\(PATH_SEPARATOR[^"]*"\)\/"/\1\/\\\\\\\\\\"/
56
s/@db_align_t_decl@/typedef unsigned long db_align_t;/
57
s/@db_alignp_t_decl@/typedef unsigned long db_alignp_t;/
60
(echo "$msgc" && sed -f $s ../dbinc/db_int.in) > $t
61
cmp $t $f > /dev/null 2>&1 ||
62
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
64
f=../build_vxworks/db_config.h
65
(echo "$msgc" && sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" vx_config.in) > $t
66
cmp $t $f > /dev/null 2>&1 ||
67
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
69
# Build a sed script that will change a "standard" DB utility into
70
# VxWorks-compatible code.
73
# Build a sed script that will add argument parsing support and
74
# rename all of the functions to be private to this file.
84
\\ __db_util_arg("$1", args, &argc, &argv);\\
85
\\ return ($1_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);\\
89
#define ERROR_RETURN ERROR\\
95
/^ while ((ch = getopt/i\\
96
\\ __db_getopt_reset = 1;
97
/^[ ]*extern int optind;/s/;/, __db_getopt_reset;/
100
# Replace all function names with VxWorks safe names.
101
# Function names are:
102
# Tokens starting at the beginning of the line, immediately
103
# followed by an opening parenthesis.
105
# Matches preceded by a non-C-token character and immediately
106
# followed by an opening parenthesis.
107
# Matches preceded by a non-C-token character and immediately
108
# followed by " __P".
109
# Matches starting at the beginning of the line, immediately
110
# followed by an opening parenthesis.
111
for k in `sed -e 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)(.*$/\1/p' -e d $2`; do
112
echo "s/\([^a-zA-Z0-9_]\)\($k(\)/\1$1_\2/g"
113
echo "s/\([^a-zA-Z0-9_]\)\($k[ ]__P\)/\1$1_\2/g"
114
echo "s/^\($k(\)/$1_\1/g"
117
# There is a special case the rules above don't catch:
118
# a txn_compare function used as an argument to qsort(3).
119
# a print_app_record function used as argument to
120
# dbenv->set_app_dispatch).
121
echo "s/, txn_compare);/, db_stat_txn_compare);/"
122
echo "s/, print_app_record)) /, db_printlog_print_app_record)) /"
124
# We convert the ex_access sample into dbdemo for VxWorks.
125
echo 's/progname = "ex_access";/progname = "dbdemo";/'
127
# The example programs have to load db_int.h, not db.h -- else
128
# they won't have the right Berkeley DB prototypes for getopt
130
echo '/#include.*db.h/c\'
131
echo '#include <db_config.h>\'
132
echo '#include <db_int.h>'
135
PROGRAM_LIST="db_archive db_checkpoint db_deadlock db_dump db_load \
136
db_printlog db_recover db_stat db_upgrade db_verify ex_access"
138
# Build VxWorks versions of the utilities.
139
for i in $PROGRAM_LIST; do
140
if [ $i = "ex_access" ]; then
148
transform $target $dir/$i.c > $s
149
sed -f $s < $dir/$i.c > $t
151
f=../build_vxworks/$target/$target.c
152
cmp $t $f > /dev/null 2>&1 ||
153
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
156
# Build VxWorks Tornado 2.0 project files for the utilities.
157
for i in $PROGRAM_LIST; do
158
if [ $i = "ex_access" ]; then
166
sed "s/__DB_APPLICATION_NAME__/$target/g" < vx_2.0/wpj.in > $t
167
f=../build_vxworks/$target/$target.wpj
168
cmp $t $f > /dev/null 2>&1 ||
169
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
172
# Build the list of files VxWorks knows about.
173
sed -e '/^$/d' -e '/^[ #]/d' srcfiles.in |
175
sed 's/[ ].*//' > $vxfilelist
177
# Build VxWorks Tornado 2.0 project files for the library itself.
178
(cat vx_2.0/BerkeleyDB.wpj
179
for i in `cat $vxfilelist`; do
180
o="<BEGIN> FILE_\$(PRJ_DIR)/../$i"
181
echo "${o}_dependDone"
185
echo "${o}_dependencies"
186
echo "\$(PRJ_DIR)/db_config.h \\"
187
echo " \$(PRJ_DIR)/db_int.h \\"
188
echo " \$(PRJ_DIR)/db.h"
192
echo "`basename $i .c`.o"
196
echo "C/C++ compiler"
200
echo "<BEGIN> PROJECT_FILES"
201
sed -e '$!s/$/ \\/' \
202
-e 's/^/$(PRJ_DIR)\/..\//' \
203
-e '1!s/^/ /' < $vxfilelist
206
echo "<BEGIN> userComments"
209
f=../build_vxworks/BerkeleyDB.wpj
210
cmp $t $f > /dev/null 2>&1 ||
211
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
213
# Build VxWorks Tornado 3.1 project files for the utilities.
214
for i in $PROGRAM_LIST; do
215
if [ $i = "ex_access" ]; then
223
cp vx_3.1/Makefile.custom $t
224
f=../build_vxworks/$target/$target/Makefile.custom
225
cmp $t $f > /dev/null 2>&1 ||
226
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
228
for j in component.cdf component.wpj; do
230
# Some parts of the component files needs to have the
231
# name in all capitals. Sigh.
233
z=`echo $target | tr "a-z" "A-Z"`
234
sed -e "s/__DB_APPLICATION_NAME__/$target/g" \
235
-e "s/__DB_CAPAPPL_NAME__/$z/g" < vx_3.1/$j > $t
236
f=../build_vxworks/$target/$target/$j
237
cmp $t $f > /dev/null 2>&1 ||
238
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
242
# Build VxWorks Tornado 3.1 project files for the library itself.
243
cp vx_3.1/Makefile.custom $t
244
f=../build_vxworks/BerkeleyDB/Makefile.custom
245
cmp $t $f > /dev/null 2>&1 ||
246
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
250
for i in `cat $vxfilelist`; do
251
echo " `basename $i .c`.o"
252
done | sort | sed -e '$!s/$/ \\/'
254
for i in `cat $vxfilelist`; do
255
b="`basename $i .c`.o"
259
echo " SRC_PATH_NAME \$(PRJ_DIR)/../../$i"
263
cat vx_3.1/cdf.3)> $t
264
f=../build_vxworks/BerkeleyDB/component.cdf
265
cmp $t $f > /dev/null 2>&1 ||
266
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
269
for i in `cat $vxfilelist`; do
270
o="<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_\$(PRJ_DIR)/../../$i"
272
echo "toolMacro objects"
276
echo "`basename $i .c`.o"
279
echo "${o}_toolMacro"
285
for i in `cat $vxfilelist`; do
286
o="<BEGIN> BUILD_PENTIUM2gnu.release_FILE_\$(PRJ_DIR)/../../$i"
288
echo "toolMacro objects"
292
echo "`basename $i .c`.o"
295
echo "${o}_toolMacro"
301
for i in `cat $vxfilelist`; do
302
o="<BEGIN> BUILD_PENTIUMgnu.debug_FILE_\$(PRJ_DIR)/../../$i"
304
echo "toolMacro objects"
308
echo "`basename $i .c`.o"
311
echo "${o}_toolMacro"
318
sed -e 's/^/$(PRJ_DIR)\/..\/..\//' \
321
cat vx_3.1/wpj.5) > $t
322
f=../build_vxworks/BerkeleyDB/component.wpj
323
cmp $t $f > /dev/null 2>&1 ||
324
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)