1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
|
#!/bin/sh -
# $Id: s_vxworks,v 1.37 2002/08/19 21:27:06 bostic Exp $
#
# Build the VxWorks files.
msgc="/* DO NOT EDIT: automatically built by dist/s_vxworks. */"
. ./RELEASE
s=/tmp/__db_a
t=/tmp/__db_b
vxfilelist=/tmp/__db_c
trap 'rm -f $s $t $vxfilelist ; exit 0' 0
trap 'rm -f $s $t $vxfilelist ; exit 1' 1 2 3 13 15
# Build the VxWorks automatically generated files.
f=../build_vxworks/db.h
cat <<ENDOFSEDTEXT > $s
/extern "C" {/{
n
n
i\\
\\
/* Tornado 2 does not provide a standard C pre-processor #define. */\\
#ifndef __vxworks\\
#define __vxworks\\
#endif
}
s/@u_int8_decl@/typedef unsigned char u_int8_t;/
s/@u_int16_decl@/typedef unsigned short u_int16_t;/
s/@u_int32_decl@/typedef unsigned int u_int32_t;/
/@int16_decl@/d
/@int32_decl@/d
/@u_char_decl@/d
/@u_short_decl@/d
/@u_int_decl@/d
/@u_long_decl@/d
/@ssize_t_decl@/d
s/@DB_VERSION_MAJOR@/$DB_VERSION_MAJOR/
s/@DB_VERSION_MINOR@/$DB_VERSION_MINOR/
s/@DB_VERSION_PATCH@/$DB_VERSION_PATCH/
s/@DB_VERSION_STRING@/"$DB_VERSION_STRING"/
s/@DB_VERSION_UNIQUE_NAME@//
ENDOFSEDTEXT
(echo "$msgc" &&
sed -f $s ../dbinc/db.in &&
cat ../dbinc_auto/rpc_defs.in &&
cat ../dbinc_auto/ext_prot.in) > $t
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
f=../build_vxworks/db_int.h
cat <<ENDOFSEDTEXT > $s
s/\(PATH_SEPARATOR[^"]*"\)\/"/\1\/\\\\\\\\\\"/
s/@db_align_t_decl@/typedef unsigned long db_align_t;/
s/@db_alignp_t_decl@/typedef unsigned long db_alignp_t;/
s/@db_int_def@//
ENDOFSEDTEXT
(echo "$msgc" && sed -f $s ../dbinc/db_int.in) > $t
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
f=../build_vxworks/db_config.h
(echo "$msgc" && sed "s/__EDIT_DB_VERSION__/$DB_VERSION/" vx_config.in) > $t
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
# Build a sed script that will change a "standard" DB utility into
# VxWorks-compatible code.
transform()
{
# Build a sed script that will add argument parsing support and
# rename all of the functions to be private to this file.
cat <<ENDOFSEDTEXT
/^main(argc, argv)$/{
i\\
$1(args)\\
\\ char *args;\\
{\\
\\ int argc;\\
\\ char **argv;\\
\\
\\ __db_util_arg("$1", args, &argc, &argv);\\
\\ return ($1_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);\\
}\\
\\
#include <stdio.h>\\
#define ERROR_RETURN ERROR\\
\\
int\\
$1_main(argc, argv)
d
}
/^ while ((ch = getopt/i\\
\\ __db_getopt_reset = 1;
/^[ ]*extern int optind;/s/;/, __db_getopt_reset;/
ENDOFSEDTEXT
# Replace all function names with VxWorks safe names.
# Function names are:
# Tokens starting at the beginning of the line, immediately
# followed by an opening parenthesis.
# Replace:
# Matches preceded by a non-C-token character and immediately
# followed by an opening parenthesis.
# Matches preceded by a non-C-token character and immediately
# followed by " __P".
# Matches starting at the beginning of the line, immediately
# followed by an opening parenthesis.
for k in `sed -e 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)(.*$/\1/p' -e d $2`; do
echo "s/\([^a-zA-Z0-9_]\)\($k(\)/\1$1_\2/g"
echo "s/\([^a-zA-Z0-9_]\)\($k[ ]__P\)/\1$1_\2/g"
echo "s/^\($k(\)/$1_\1/g"
done
# There is a special case the rules above don't catch:
# a txn_compare function used as an argument to qsort(3).
# a print_app_record function used as argument to
# dbenv->set_app_dispatch).
echo "s/, txn_compare);/, db_stat_txn_compare);/"
echo "s/, print_app_record)) /, db_printlog_print_app_record)) /"
# We convert the ex_access sample into dbdemo for VxWorks.
echo 's/progname = "ex_access";/progname = "dbdemo";/'
# The example programs have to load db_int.h, not db.h -- else
# they won't have the right Berkeley DB prototypes for getopt
# and friends.
echo '/#include.*db.h/c\'
echo '#include <db_config.h>\'
echo '#include <db_int.h>'
}
PROGRAM_LIST="db_archive db_checkpoint db_deadlock db_dump db_load \
db_printlog db_recover db_stat db_upgrade db_verify ex_access"
# Build VxWorks versions of the utilities.
for i in $PROGRAM_LIST; do
if [ $i = "ex_access" ]; then
target=dbdemo
dir=../examples_c
else
target=$i
dir=../$i
fi
transform $target $dir/$i.c > $s
sed -f $s < $dir/$i.c > $t
f=../build_vxworks/$target/$target.c
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
done
# Build VxWorks Tornado 2.0 project files for the utilities.
for i in $PROGRAM_LIST; do
if [ $i = "ex_access" ]; then
target=dbdemo
dir=../examples_c
else
target=$i
dir=../$i
fi
sed "s/__DB_APPLICATION_NAME__/$target/g" < vx_2.0/wpj.in > $t
f=../build_vxworks/$target/$target.wpj
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
done
# Build the list of files VxWorks knows about.
sed -e '/^$/d' -e '/^[ #]/d' srcfiles.in |
egrep -w vx |
sed 's/[ ].*//' > $vxfilelist
# Build VxWorks Tornado 2.0 project files for the library itself.
(cat vx_2.0/BerkeleyDB.wpj
for i in `cat $vxfilelist`; do
o="<BEGIN> FILE_\$(PRJ_DIR)/../$i"
echo "${o}_dependDone"
echo "TRUE"
echo "<END>"
echo
echo "${o}_dependencies"
echo "\$(PRJ_DIR)/db_config.h \\"
echo " \$(PRJ_DIR)/db_int.h \\"
echo " \$(PRJ_DIR)/db.h"
echo "<END>"
echo
echo "${o}_objects"
echo "`basename $i .c`.o"
echo "<END>"
echo
echo "${o}_tool"
echo "C/C++ compiler"
echo "<END>"
echo
done
echo "<BEGIN> PROJECT_FILES"
sed -e '$!s/$/ \\/' \
-e 's/^/$(PRJ_DIR)\/..\//' \
-e '1!s/^/ /' < $vxfilelist
echo "<END>"
echo
echo "<BEGIN> userComments"
echo "BerkeleyDB"
echo "<END>") > $t
f=../build_vxworks/BerkeleyDB.wpj
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
# Build VxWorks Tornado 3.1 project files for the utilities.
for i in $PROGRAM_LIST; do
if [ $i = "ex_access" ]; then
target=dbdemo
dir=../examples_c
else
target=$i
dir=../$i
fi
cp vx_3.1/Makefile.custom $t
f=../build_vxworks/$target/$target/Makefile.custom
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
for j in component.cdf component.wpj; do
#
# Some parts of the component files needs to have the
# name in all capitals. Sigh.
#
z=`echo $target | tr "a-z" "A-Z"`
sed -e "s/__DB_APPLICATION_NAME__/$target/g" \
-e "s/__DB_CAPAPPL_NAME__/$z/g" < vx_3.1/$j > $t
f=../build_vxworks/$target/$target/$j
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
done
done
# Build VxWorks Tornado 3.1 project files for the library itself.
cp vx_3.1/Makefile.custom $t
f=../build_vxworks/BerkeleyDB/Makefile.custom
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
(cat vx_3.1/cdf.1
echo -n " MODULES"
for i in `cat $vxfilelist`; do
echo " `basename $i .c`.o"
done | sort | sed -e '$!s/$/ \\/'
cat vx_3.1/cdf.2
for i in `cat $vxfilelist`; do
b="`basename $i .c`.o"
echo "Module $b {"
echo
echo " NAME $b"
echo " SRC_PATH_NAME \$(PRJ_DIR)/../../$i"
echo "}"
echo
done
cat vx_3.1/cdf.3)> $t
f=../build_vxworks/BerkeleyDB/component.cdf
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
(cat vx_3.1/wpj.1
for i in `cat $vxfilelist`; do
o="<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_\$(PRJ_DIR)/../../$i"
echo "${o}_infoTags"
echo "toolMacro objects"
echo "<END>"
echo
echo "${o}_objects"
echo "`basename $i .c`.o"
echo "<END>"
echo
echo "${o}_toolMacro"
echo "CC"
echo "<END>"
echo
done
cat vx_3.1/wpj.2
for i in `cat $vxfilelist`; do
o="<BEGIN> BUILD_PENTIUM2gnu.release_FILE_\$(PRJ_DIR)/../../$i"
echo "${o}_infoTags"
echo "toolMacro objects"
echo "<END>"
echo
echo "${o}_objects"
echo "`basename $i .c`.o"
echo "<END>"
echo
echo "${o}_toolMacro"
echo "CC"
echo "<END>"
echo
done
cat vx_3.1/wpj.3
for i in `cat $vxfilelist`; do
o="<BEGIN> BUILD_PENTIUMgnu.debug_FILE_\$(PRJ_DIR)/../../$i"
echo "${o}_infoTags"
echo "toolMacro objects"
echo "<END>"
echo
echo "${o}_objects"
echo "`basename $i .c`.o"
echo "<END>"
echo
echo "${o}_toolMacro"
echo "CC"
echo "<END>"
echo
done
cat vx_3.1/wpj.4
sort $vxfilelist |
sed -e 's/^/$(PRJ_DIR)\/..\/..\//' \
-e '1!s/^/ /' \
-e '$!s/$/ \\/'
cat vx_3.1/wpj.5) > $t
f=../build_vxworks/BerkeleyDB/component.wpj
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
|