4 # Copyright 2002 the LyX Team
5 # Read the file COPYING
7 # \author Angus Leeming, leeming@lyx.org
9 # This shell script takes the dialog created with fdesign and generates the
10 # .C and .h files used by LyX from it.
11 # Note that the REAL magic is to be found in the sed scripts fdfixc.sed and
12 # fdfixh.sed used by this shell script.
18 # Note that we can't create a variable containing this and then
19 # echo it across because some machines require -e to recognize \n et al.
20 # Other machines, of course output -e, it not being an option they
23 # Set ${OUTPUT_FILE} to ${HOUT} or ${COUT} as appropriate
24 cat - > ${OUTPUT_FILE} <<EOF
25 // File generated by fdesign from ${FDFILE}
26 // and modified by fdfix.sh for use by LyX.
28 // WARNING! All changes made to this file will be lost!
30 // Copyright $DATE the LyX Team
31 // Read the file COPYING
38 echo "Input file does not exist. Cannot continue"
43 BASENAME=`basename $1 .fd`
45 if [ $1 = ${BASENAME} ]; then
46 echo "Input file is not a .fd file. Cannot continue"
50 #===================================
51 # Create the initial .c and .h files
54 (cd ${DIRNAME}; ${FDESIGN} -convert ${FDFILE})
56 #==================================
57 # Modify the .h file for use by LyX
58 HIN=${DIRNAME}/${BASENAME}.h
59 HPATCH=${DIRNAME}/${BASENAME}.h.patch
62 FDFIXH=${DIRNAME}/fdfixh.sed
67 sed -f $FDFIXH < $HIN >> ${HOUT}
69 # Patch the .h file if a patch exists
70 if [ -f "${HPATCH}" ] ; then
71 echo "Patching ${HOUT} with ${HPATCH}"
72 patch -s ${HOUT} < ${HPATCH}
75 # Clean up, to leave the finished .h file
77 mv ${HOUT} ${BASENAME}.h
79 #==================================
80 # Create the .C file for use by LyX
81 CIN=${DIRNAME}/${BASENAME}.c
82 CPATCH=${DIRNAME}/${BASENAME}.C.patch
85 FDFIXC=${DIRNAME}/fdfixc.sed
91 echo "#include <config.h>" >> ${COUT}
92 echo "#include \"forms_gettext.h\"" >> ${COUT}
93 echo "#include \"gettext.h\"" >> ${COUT}
95 grep bmtable ${CIN} > /dev/null
97 echo "#include \"bmtable.h\"" >> ${COUT}
100 # This is (I hope) a very temporary fudge.
101 # FormMathsPanel should be modified in input() to not use the data parameter.
102 # Instead, use the FL_OBJECT * parameter.
103 # Angus 12 June, 2002.
104 grep MM_ ${CIN} > /dev/null
105 if [ $? -eq 0 ]; then
106 echo "#include \"MathsSymbols.h\"" >> ${COUT}
111 sed -f ${FDFIXC} < ${CIN} >> ${COUT}
113 # Patch the .C file if a patch exists
114 if [ -f "$CPATCH" ] ; then
115 echo "Patching ${COUT} with $CPATCH"
116 patch -s ${COUT} < $CPATCH
119 # Clean up, to leave the finished .C file
122 #========================================