]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/forms/fdfix.sh
d381dede0aaf8ee8554fe63a4904eed0a88f44d0
[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
14 # names of the files generated by fdesign and by running the sed scripts
15 BASE=`basename $1 .fd`
16
17 if [ $1 = $BASE ]; then
18     echo "Input file is not a .fd file. Cannot continue"
19     exit 1
20 fi
21
22 CIN=$BASE.c
23 COUT=$BASE.C
24 HIN=$BASE.h
25 HOUT=$BASE.H
26
27 # Ascertain the class name from the name of the file
28 # eg form_my_new_dialog -> FormMyNewDialog
29 CLASSNAME=""
30 SECTION="start"
31 i=1
32 while :
33 do
34     SECTION=`echo $BASE | cut -d_ -f$i`
35     i=`expr $i + 1 `
36
37     if [ $SECTION ]
38     then
39         FIRST=`echo $SECTION | cut -c1 | tr a-z A-Z`
40         SECOND=`echo $SECTION | cut -c2-`
41         CLASSNAME=$CLASSNAME$FIRST$SECOND
42     else
43         break
44     fi
45 done
46
47 # Create .c and .h files
48 $FDESIGN -convert $1
49 FDFIXH=fdfixh.sed
50 FDFIXC=fdfixc.sed
51
52 # Modify .h file for use by LyX
53 echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $HOUT
54 sed -f $FDFIXH < $HIN >> $HOUT
55
56 # Patch the .h file if a patch exists
57 if [ -f "$HOUT.patch" ] ; then
58     echo "Patching $HOUT with $HOUT.patch"
59     patch -s $HOUT < $HOUT.patch
60 fi
61
62 # Modify .c file for use by LyX
63 echo "// File modified by fdfix.sh for use by lyx (with xforms >= 0.88) and gettext" > $COUT
64 echo "#include <config.h>" >> $COUT
65 echo "#include \"lyx_gui_misc.h\"" >> $COUT
66 echo "#include \"gettext.h\"" >> $COUT
67 echo >> $COUT
68
69 sed -f $FDFIXC < $CIN | sed -e "s/CLASSNAME/$CLASSNAME/" >> $COUT
70
71 # Patch the .C file if a patch exists
72 if [ -f "$COUT.patch" ] ; then
73     echo "Patching $COUT with $COUT.patch"
74     patch -s $COUT < $COUT.patch
75 fi
76
77 # Clean up, to leave .C and .h files
78 rm -f $CIN $HIN
79 mv $HOUT $HIN