dbsql/test/scr050/s_include

89 lines
1.7 KiB
Text
Raw Permalink Normal View History

2007-03-10 19:04:07 +00:00
#!/bin/sh -
# $Id: s_include 7 2007-02-03 13:34:17Z gburd $
#
# Build the automatically generated function prototype files.
msgc="/* DO NOT EDIT: automatically built by test/scr050/s_include. */"
head()
{
defonly=0
while :
do case "$1" in
space)
echo ""; shift;;
defonly)
defonly=1; shift;;
*)
name="$1"; break;;
esac
done
echo "$msgc"
echo "#ifndef $name"
echo "#define $name"
echo ""
if [ $defonly -eq 0 ]; then
echo "#if defined(__cplusplus)"
echo "extern \"C\" {"
echo "#endif"
echo ""
fi
}
tail()
{
defonly=0
while :
do case "$1" in
defonly)
defonly=1; shift;;
*)
name="$1"; break;;
esac
done
echo ""
if [ $defonly -eq 0 ]; then
echo "#if defined(__cplusplus)"
echo "}"
echo "#endif"
fi
echo "#endif /* !$name */"
}
# We are building several files:
# 1 external #define file
# 1 external prototype file
# 1 internal #define file
# N internal prototype files
e_dfile=/tmp/__db_c.$$
e_pfile=/tmp/__db_a.$$
i_dfile=/tmp/__db_d.$$
i_pfile=/tmp/__db_b.$$
trap 'rm -f $e_dfile $e_pfile $i_dfile $i_pfile; exit 0' 0 1 2 3 13 15
head defonly space _DBSQL_EXT_DEF_IN_ > $e_dfile
head space _DBSQL_EXT_PROT_IN_ > $e_pfile
head defonly _DBSQL_INT_DEF_IN_ > $i_dfile
# Process the standard directories, creating per-directory prototype
# files and adding to the external prototype and #define files.
i="tcl"
f="./*.c"
head "_${i}_ext_h_" > $i_pfile
awk -f ../../dist/gen_inc.awk \
-v e_dfile=$e_dfile \
-v e_pfile=$e_pfile \
-v i_dfile=$i_dfile \
-v i_pfile=$i_pfile $f
tail "_${i}_ext_h_" >> $i_pfile
f="./${i}_ext.h"
cmp $i_pfile $f > /dev/null 2>&1 ||
(echo "Building $f" && rm -f $f && cp $i_pfile $f && chmod 444 $f)