]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfix.sh
major GUII cleanup + Baruchs patch + Angus's patch + removed a couple of generated...
[lyx.git] / src / frontends / xforms / forms / fdfix.sh
1 #! /bin/sh
2 #
3 # NOTE: This is NOT the same fdfix.sh as in ${top_srcdir}/forms
4 #       It is a modified version to suit use for gui-indep.
5 #
6
7 if [ ! -f $1 ]; then
8     echo "Input file does not exist. Cannot continue"
9     exit 1
10 fi
11
12 FDESIGN=fdesign
13 base=`basename $1 .fd`
14
15 if [ $1 = $base ]; then
16     echo "Input file is not a .fd file. Cannot continue"
17     exit 1
18 fi
19
20 cin=$base.c
21 cout=$base.C
22 hin=$base.h
23 hout=$base.H
24
25 classname=`echo $base | cut -c6-`
26 firstchar=`echo $classname | cut -c1 | tr a-z A-Z`
27 rest=`echo $classname | cut -c2-`
28 classname=Form$firstchar$rest
29
30 # Create .c and .h files
31 $FDESIGN -convert $1
32
33 # Modify .h file for use by LyX
34 echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $hout
35 sed -f fdfixh.sed < $hin >> $hout
36
37 # Patch the .h file if a patch exists
38 if [ -f "$hout.patch" ] ; then
39     echo "Patching $hout with $hout.patch"
40     patch -s $hout < $hout.patch
41 fi
42
43 # Modify .c file for use by LyX
44 echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $cout
45 echo "#include <config.h>" >> $cout
46 echo "#include \"lyx_gui_misc.h\"" >> $cout
47 echo "#include \"gettext.h\"" >> $cout
48 echo >> $cout
49
50 sed -f fdfixc.sed < $cin | sed -e "s/CLASSNAME/$classname/" >> $cout
51
52 # Patch the .C file if a patch exists
53 if [ -f "$cout.patch" ] ; then
54     echo "Patching $cout with $cout.patch"
55     patch -s $cout < $cout.patch
56 fi
57
58 # Clean up, to leave .C and .h files
59 rm -f $cin $hin
60 mv $hout $hin