#!/bin/sh -
msgc="/* DO NOT EDIT: automatically built by dist/s_vxworks. */"
. RELEASE
s=/tmp/__db_a
t=/tmp/__db_b
u=/tmp/__db_c
vxfilelist=/tmp/__db_d
vxsmallfiles=/tmp/__db_e
trap 'rm -f $s $t $u $vxfilelist $vxsmallfiles ; exit 0' 0
trap 'rm -f $s $t $u $vxfilelist $vxsmallfiles ; exit 1' 1 2 3 13 15
cat <<ENDOFSEDTEXT > $s
/extern "C" {/{
n
n
i\\
\\
/* Tornado 2 does not provide a standard C pre-processor }
/@inttypes_h_decl@/d
/@stddef_h_decl@/d
/@stdint_h_decl@/d
/@unistd_h_decl@/d
/@thread_h_decl@/d
s/@u_int8_decl@/typedef unsigned char u_int8_t;/
/@int16_decl@/d
s/@u_int16_decl@/typedef unsigned short u_int16_t;/
/@int32_decl@/d
s/@u_int32_decl@/typedef unsigned int u_int32_t;/
s/@int64_decl@//
s/@u_int64_decl@/typedef unsigned long long u_int64_t;/
/@u_char_decl@/d
/@u_int_decl@/d
/@u_long_decl@/d
/@u_short_decl@/d
s/@uintmax_t_decl@/typedef unsigned long uintmax_t;/
s/@uintptr_t_decl@/typedef unsigned long uintptr_t;/
/@FILE_t_decl@/d
/@off_t_decl@/d
/@pid_t_decl@/d
/@size_t_decl@/d
/@ssize_t_decl@/d
/@time_t_decl@/d
s/@db_seq_decl@/typedef int db_seq_t;/
s/@db_threadid_t_decl@/typedef uintmax_t db_threadid_t;/
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@//
s/@DB_CONST@//
s/@DB_PROTO1@/s/@DB_PROTO2@//@platform_header@/d
/@platform_footer@/d
ENDOFSEDTEXT
(echo "$msgc" &&
sed -f $s ../dbinc/db.in &&
cat ../dbinc_auto/ext_prot.in) > $t
test `egrep '@.*@' $t` && {
egrep '@.*@' $t
echo 'Unexpanded autoconf variables found in VxWorks db.h.'
exit 1
}
f=../build_vxworks/db.h
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
cat <<ENDOFSEDTEXT > $s
s/@PATH_SEPARATOR@/\/\\\\\\\\/
s/@db_int_def@//
//ENDOFSEDTEXT
(echo "$msgc" && sed -f $s ../dbinc/db_int.in) > $t
test `egrep '@.*@' $t` && {
egrep '@.*@' $t
echo 'Unexpanded autoconf variables found in VxWorks db_int.h.'
exit 1
}
f=../build_vxworks/db_int.h
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
check_config()
{
egrep '^ (egrep ' egrep '^ cmp $s $t > /dev/null || {
echo "config.hin and $1 differ"
echo "<<< config.hin >>> $1"
diff $s $t
}
}
check_config vx_config.in
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)
f=../build_vxworks/db_config_small.h
(echo "$msgc" &&
sed -e "s/__EDIT_DB_VERSION__/$DB_VERSION/" \
-e "s;^#define.*HAVE_CRYPTO.*1;/* #undef HAVE_CRYPTO */;" \
-e "s;^#define.*HAVE_HASH.*1;/* #undef HAVE_HASH */;" \
-e "s;^#define.*HAVE_QUEUE.*1;/* #undef HAVE_QUEUE */;" \
-e "s;^#define.*HAVE_REPLICATION.*1;/* #undef HAVE_REPLICATION */;" \
-e "s;^#define.*HAVE_STATISTICS.*1;/* #undef HAVE_STATISTICS */;" \
-e "s;^#define.*HAVE_VERIFY.*1;/* #undef HAVE_VERIFY */;" \
vx_config.in) > $t
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
cat <<ENDOFSEDTEXT > $s
s/@INT64_FMT@/s/@UINT64_FMT@/ENDOFSEDTEXT
sed -f $s clib_port.in > $t
test `egrep '@.*@' $t` && {
egrep '@.*@' $t
echo 'Unexpanded autoconf variables found in VxWorks clib_port.h.'
exit 1
}
f=../build_vxworks/clib_port.h
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
transform()
{
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);\\
}\\
\\
\\
int\\
$1_main(argc, argv)
d
}
/^ while ((ch = getopt/i\\
\\ __db_getopt_reset = 1;
/^[ ]*extern int optind;/s/;/, __db_getopt_reset;/
ENDOFSEDTEXT
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
echo "s/, feedback);/, db_recover_feedback);/"
echo "s/, print_app_record)) /, db_printlog_print_app_record)) /"
echo "s/, txn_compare);/, db_stat_txn_compare);/"
echo 's/progname = "ex_access";/progname = "dbdemo";/'
echo '/ echo ' echo '}
PROGRAM_LIST="db_archive db_checkpoint db_deadlock db_dump db_hotbackup \
db_load db_printlog db_recover db_stat db_upgrade db_verify ex_access"
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
util_one()
{
egrep "app=$1" srcfiles.in |
awk '{print $1}' |
sed 's/ex_access/dbdemo/' > $u
for i in `cat $u`; do
if test "$1" = "ex_access" -o "$1" = `basename $i .c`; then
i=`basename $i`
else
i="\$(PRJ_DIR)/../../$i"
fi
o="<BEGIN> FILE_$i"
echo "${o}_dependDone"
echo "FALSE"
echo "<END>"
echo
echo "${o}_dependencies"
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"
for i in `cat $u`; do
if test "$1" = "ex_access" -o "$1" = `basename $i .c`; then
i="`basename $i`"
else
i="../../$i"
fi
echo "\$(PRJ_DIR)/$i"
done |
sed -e '${' \
-e 'p' \
-e 'd' \
-e '}' \
-e 's/$/ \\/'
echo "<END>"
echo
echo "<BEGIN> userComments"
if test "$1" = "ex_access"; then
echo "dbdemo"
else
echo "$1"
fi
echo "<END>"
}
for i in $PROGRAM_LIST; do
if [ $i = "ex_access" ]; then
target=dbdemo
else
target=$i
fi
(sed -e "s/__DB_APPLICATION_NAME__/$target/g" < vx_2.0/wpj.in
util_one $i) > $t
f=../build_vxworks/$target/${target}20.wpj
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
(sed -e "s/__DB_APPLICATION_NAME__/$target/g" < vx_2.2/wpj.in
util_one $i) > $t
f=../build_vxworks/$target/${target}22.wpj
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
done
sed -e '/^$/d' -e '/^[ egrep -w vx |
sed 's/[ ].*//' > $vxfilelist
sed -e '/^$/d' -e '/^[ egrep -w vxsmall |
sed 's/[ ].*//' > $vxsmallfiles
for v in 0 2 ; do
(cat vx_2.${v}/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
(cat vx_2.${v}/BerkeleyDBsmall.wpj
for i in `cat $vxsmallfiles`; 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/^/ /' < $vxsmallfiles
echo "<END>"
echo
echo "<BEGIN> userComments"
echo "BerkeleyDB"
echo "<END>") > $u
f=../build_vxworks/BerkeleyDB2${v}.wpj
cmp $t $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $t $f && chmod 444 $f)
f=../build_vxworks/BerkeleyDB2${v}small.wpj
cmp $u $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $u $f && chmod 444 $f)
done