~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to bdb/dist/s_vxworks

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -
 
2
#       $Id: s_vxworks,v 1.37 2002/08/19 21:27:06 bostic Exp $
 
3
#
 
4
# Build the VxWorks files.
 
5
 
 
6
msgc="/* DO NOT EDIT: automatically built by dist/s_vxworks. */"
 
7
 
 
8
. ./RELEASE
 
9
 
 
10
s=/tmp/__db_a
 
11
t=/tmp/__db_b
 
12
vxfilelist=/tmp/__db_c
 
13
 
 
14
trap 'rm -f $s $t $vxfilelist ; exit 0' 0
 
15
trap 'rm -f $s $t $vxfilelist ; exit 1' 1 2 3 13 15
 
16
 
 
17
# Build the VxWorks automatically generated files.
 
18
f=../build_vxworks/db.h
 
19
cat <<ENDOFSEDTEXT > $s
 
20
/extern "C" {/{
 
21
n
 
22
n
 
23
i\\
 
24
\\
 
25
/* Tornado 2 does not provide a standard C pre-processor #define. */\\
 
26
#ifndef __vxworks\\
 
27
#define __vxworks\\
 
28
#endif
 
29
}
 
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;/
 
33
/@int16_decl@/d
 
34
/@int32_decl@/d
 
35
/@u_char_decl@/d
 
36
/@u_short_decl@/d
 
37
/@u_int_decl@/d
 
38
/@u_long_decl@/d
 
39
/@ssize_t_decl@/d
 
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@//
 
45
ENDOFSEDTEXT
 
46
(echo "$msgc" &&
 
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)
 
52
 
 
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;/
 
58
s/@db_int_def@//
 
59
ENDOFSEDTEXT
 
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)
 
63
 
 
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)
 
68
 
 
69
# Build a sed script that will change a "standard" DB utility into
 
70
# VxWorks-compatible code.
 
71
transform()
 
72
{
 
73
        # Build a sed script that will add argument parsing support and
 
74
        # rename all of the functions to be private to this file.
 
75
cat <<ENDOFSEDTEXT
 
76
/^main(argc, argv)$/{
 
77
i\\
 
78
$1(args)\\
 
79
\\      char *args;\\
 
80
{\\
 
81
\\      int argc;\\
 
82
\\      char **argv;\\
 
83
\\
 
84
\\      __db_util_arg("$1", args, &argc, &argv);\\
 
85
\\      return ($1_main(argc, argv) ? EXIT_FAILURE : EXIT_SUCCESS);\\
 
86
}\\
 
87
\\
 
88
#include <stdio.h>\\
 
89
#define ERROR_RETURN    ERROR\\
 
90
\\
 
91
int\\
 
92
$1_main(argc, argv)
 
93
d
 
94
}
 
95
/^      while ((ch = getopt/i\\
 
96
\\      __db_getopt_reset = 1;
 
97
/^[     ]*extern int optind;/s/;/, __db_getopt_reset;/
 
98
ENDOFSEDTEXT
 
99
 
 
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.
 
104
        # Replace:
 
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"
 
115
        done
 
116
 
 
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)) /"
 
123
 
 
124
        # We convert the ex_access sample into dbdemo for VxWorks.
 
125
        echo 's/progname = "ex_access";/progname = "dbdemo";/'
 
126
 
 
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
 
129
        # and friends.
 
130
        echo '/#include.*db.h/c\'
 
131
        echo '#include <db_config.h>\'
 
132
        echo '#include <db_int.h>'
 
133
}
 
134
 
 
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"
 
137
 
 
138
# Build VxWorks versions of the utilities.
 
139
for i in $PROGRAM_LIST; do
 
140
        if [ $i = "ex_access" ]; then
 
141
                target=dbdemo
 
142
                dir=../examples_c
 
143
        else
 
144
                target=$i
 
145
                dir=../$i
 
146
        fi
 
147
 
 
148
        transform $target $dir/$i.c > $s
 
149
        sed -f $s < $dir/$i.c > $t
 
150
 
 
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)
 
154
done
 
155
 
 
156
# Build VxWorks Tornado 2.0 project files for the utilities.
 
157
for i in $PROGRAM_LIST; do
 
158
        if [ $i = "ex_access" ]; then
 
159
                target=dbdemo
 
160
                dir=../examples_c
 
161
        else
 
162
                target=$i
 
163
                dir=../$i
 
164
        fi
 
165
 
 
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)
 
170
done
 
171
 
 
172
# Build the list of files VxWorks knows about.
 
173
sed -e '/^$/d' -e '/^[   #]/d' srcfiles.in |
 
174
    egrep -w vx |
 
175
    sed 's/[     ].*//' > $vxfilelist
 
176
 
 
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"
 
182
        echo "TRUE"
 
183
        echo "<END>"
 
184
        echo
 
185
        echo "${o}_dependencies"
 
186
        echo "\$(PRJ_DIR)/db_config.h \\"
 
187
        echo "  \$(PRJ_DIR)/db_int.h \\"
 
188
        echo "  \$(PRJ_DIR)/db.h"
 
189
        echo "<END>"
 
190
        echo
 
191
        echo "${o}_objects"
 
192
        echo "`basename $i .c`.o"
 
193
        echo "<END>"
 
194
        echo
 
195
        echo "${o}_tool"
 
196
        echo "C/C++ compiler"
 
197
        echo "<END>"
 
198
        echo
 
199
done
 
200
echo "<BEGIN> PROJECT_FILES"
 
201
sed -e '$!s/$/ \\/' \
 
202
    -e 's/^/$(PRJ_DIR)\/..\//' \
 
203
    -e '1!s/^/  /' < $vxfilelist
 
204
echo "<END>"
 
205
echo
 
206
echo "<BEGIN> userComments"
 
207
echo "BerkeleyDB"
 
208
echo "<END>") > $t
 
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)
 
212
 
 
213
# Build VxWorks Tornado 3.1 project files for the utilities.
 
214
for i in $PROGRAM_LIST; do
 
215
        if [ $i = "ex_access" ]; then
 
216
                target=dbdemo
 
217
                dir=../examples_c
 
218
        else
 
219
                target=$i
 
220
                dir=../$i
 
221
        fi
 
222
 
 
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)
 
227
 
 
228
        for j in component.cdf component.wpj; do
 
229
                #
 
230
                # Some parts of the component files needs to have the
 
231
                # name in all capitals.  Sigh.
 
232
                #
 
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)
 
239
        done
 
240
done
 
241
 
 
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)
 
247
 
 
248
(cat vx_3.1/cdf.1
 
249
echo -n "       MODULES"
 
250
for i in `cat $vxfilelist`; do
 
251
        echo "                  `basename $i .c`.o"
 
252
done | sort | sed -e '$!s/$/ \\/'
 
253
cat vx_3.1/cdf.2
 
254
for i in `cat $vxfilelist`; do
 
255
        b="`basename $i .c`.o"
 
256
        echo "Module $b {"
 
257
        echo
 
258
        echo "  NAME            $b"
 
259
        echo "  SRC_PATH_NAME   \$(PRJ_DIR)/../../$i"
 
260
        echo "}"
 
261
        echo
 
262
done
 
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)
 
267
 
 
268
(cat vx_3.1/wpj.1
 
269
for i in `cat $vxfilelist`; do
 
270
        o="<BEGIN> BUILD_PENTIUM2gnu.debug_FILE_\$(PRJ_DIR)/../../$i"
 
271
        echo "${o}_infoTags"
 
272
        echo "toolMacro objects"
 
273
        echo "<END>"
 
274
        echo
 
275
        echo "${o}_objects"
 
276
        echo "`basename $i .c`.o"
 
277
        echo "<END>"
 
278
        echo
 
279
        echo "${o}_toolMacro"
 
280
        echo "CC"
 
281
        echo "<END>"
 
282
        echo
 
283
done
 
284
cat vx_3.1/wpj.2
 
285
for i in `cat $vxfilelist`; do
 
286
        o="<BEGIN> BUILD_PENTIUM2gnu.release_FILE_\$(PRJ_DIR)/../../$i"
 
287
        echo "${o}_infoTags"
 
288
        echo "toolMacro objects"
 
289
        echo "<END>"
 
290
        echo
 
291
        echo "${o}_objects"
 
292
        echo "`basename $i .c`.o"
 
293
        echo "<END>"
 
294
        echo
 
295
        echo "${o}_toolMacro"
 
296
        echo "CC"
 
297
        echo "<END>"
 
298
        echo
 
299
done
 
300
cat vx_3.1/wpj.3
 
301
for i in `cat $vxfilelist`; do
 
302
        o="<BEGIN> BUILD_PENTIUMgnu.debug_FILE_\$(PRJ_DIR)/../../$i"
 
303
        echo "${o}_infoTags"
 
304
        echo "toolMacro objects"
 
305
        echo "<END>"
 
306
        echo
 
307
        echo "${o}_objects"
 
308
        echo "`basename $i .c`.o"
 
309
        echo "<END>"
 
310
        echo
 
311
        echo "${o}_toolMacro"
 
312
        echo "CC"
 
313
        echo "<END>"
 
314
        echo
 
315
done
 
316
cat vx_3.1/wpj.4
 
317
sort $vxfilelist |
 
318
sed -e 's/^/$(PRJ_DIR)\/..\/..\//' \
 
319
    -e '1!s/^/  /' \
 
320
    -e '$!s/$/ \\/'
 
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)