gambas-source-code/TEMPLATE/make-component
Benoît Minisini ba19f3c1dd * Copy https://gambas.svn.sourceforge.net/svnroot/gambas/2.0 to https://gambas.svn.sourceforge.net/svnroot/gambas/gambas
git-svn-id: svn://localhost/gambas/trunk@893 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2007-12-30 16:41:49 +00:00

61 lines
2 KiB
Bash
Executable file

#!/bin/sh
if test -d ../$1; then
echo "$0: error: This component already exists";
exit 1;
fi
if test ! -e ./conf/$1.conf; then
echo "$0: error: The configuration file for this component does not exist";
exit 1;
fi
if test x`which cpp` == x; then
echo "$0: error: cpp was not found";
exit 1;
fi
echo "Creating component directory $1..."
cp -R template ../$1
pushd . > /dev/null
cd ../$1
rm -f `find . -name \*~`
for i in ../acinclude.m4 ../component.am ../config.guess ../config.sub ../main/share/gambas.h ../main/share/gb_common.h ../ltmain.sh ../reconf ../INSTALL ../COPYING; do
ln -s $i;
done
popd > /dev/null
echo "Applying template..."
for i in ../$1/* ../$1/.* ../$1/*/* ../$1/*/.*; do
if test ! -h $i && test ! -d $i; then
cpp -P -include ./conf/$1.conf -o $i.out $i;
rm -f $i;
cat $i.out | sed s/"\\$\/\\$"/"\/"/g | sed s/"\\$'\\$"/"\""/g | sed s/"\\$:\\$"/"\""/g | sed s/"\\$\#\\$"/"\#"/g | sed s/"\#@\#"/"@"/g | sed s/"\#\#"/""/g > $i;
rm -f $i.out;
fi
done
echo "Creating source files..."
for i in `cat ../$1/SOURCES`; do
BASENAME=`basename $i`;
SOURCE=../$1/src/$i;
if test ! `basename $i .h` = $BASENAME; then
cpp -P -include ./conf/$1.conf -D__SOURCE_NAME=`basename $i .h` -D__SOURCE_UNAME=`basename $i .h | tr '[:lower:]' '[:upper:]'` -o $SOURCE TEMPLATE.h;
elif test ! `basename $i .c` = $BASENAME; then
cpp -P -include ./conf/$1.conf -D__SOURCE_NAME=`basename $i .c` -D__SOURCE_UNAME=`basename $i .c | tr '[:lower:]' '[:upper:]'` -o $SOURCE TEMPLATE.c;
elif test ! `basename $i .cpp` = $BASENAME; then
cpp -P -include ./conf/$1.conf -D__SOURCE_NAME=`basename $i .cpp` -D__SOURCE_UNAME=`basename $i .cpp | tr '[:lower:]' '[:upper:]'` -o $SOURCE TEMPLATE.cpp;
fi
cat $SOURCE | sed s/"\\$\/\\$"/"\/"/g | sed s/"\\$'\\$"/"\""/g | sed s/"\\$:\\$"/"\""/g | sed s/"\\$\#\\$"/"\#"/g | sed s/"\#@\#"/"@"/g | sed s/"\#\#"/""/g > $SOURCE.tmp;
rm -f $SOURCE;
mv $SOURCE.tmp $SOURCE;
done
rm -f ../$1/SOURCES
pushd . > /dev/null
cd ../$1
(source ./make-component)
rm -f make-component
popd > /dev/null