dbsql/dist/s_include

112 lines
3 KiB
Text
Raw Permalink Normal View History

2007-03-10 19:04:07 +00:00
#!/bin/sh -
# DBSQL - A SQL database engine.
#
2008-05-15 23:08:18 +00:00
# Copyright (C) 2007-2008 The DBSQL Group, Inc. - All rights reserved.
2007-03-10 19:04:07 +00:00
#
2007-10-21 01:57:28 +00:00
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
2007-03-10 19:04:07 +00:00
#
# There are special exceptions to the terms and conditions of the GPL as it
# is applied to this software. View the full text of the exception in file
# LICENSE_EXCEPTIONS in the directory of this software distribution.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# Build the automatically generated function prototype files.
msgc="/* DO NOT EDIT: automatically built by dist/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.$$
2024-03-11 15:39:12 +00:00
i_sfile=/tmp/__db_e.$$
trap 'rm -f $e_dfile $e_pfile $i_dfile $i_pfile $i_sfile; exit 0' 0 1 2 3 13 15
2007-03-10 19:04:07 +00:00
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.
2024-03-11 15:39:12 +00:00
for pkg in dbsql os clib common ; do
head "_${pkg}_ext_h_" > $i_pfile
cfiles="../src/${pkg}/*.c"
[ "$cfiles" = "../src/dbsql/*.c" ] && cfiles="../src/*.c"
for file in $(ls $cfiles); do
fname="$(echo $file | sed -n 's/^\(.*\/\)*\([^.]*\)\(.*\)/\2/p')"
head "_${fname}_decl_h_" > $i_sfile
awk -f gen_inc.awk \
-v e_dfile=$e_dfile \
-v e_pfile=$e_pfile \
-v i_dfile=$i_dfile \
-v i_pfile=$i_pfile \
-v i_sfile=$i_sfile $file
tail "_${fname}_decl_h_" >> $i_sfile
decl="../src/inc/${fname}_decl.h"
# cmp $i_sfile $decl > /dev/null 2>&1 ||
# (echo "Building $decl" && rm -f $decl && cp $i_sfile $decl && chmod 444 $decl)
done
tail "_${pkg}_ext_h_" >> $i_pfile
ext="../src/inc/${pkg}_ext.h"
cmp $i_pfile $ext > /dev/null 2>&1 ||
(echo "Building $ext" && rm -f $ext && cp $i_pfile $ext && chmod 444 $ext)
2007-03-10 19:04:07 +00:00
done