4 # This file is part of LyX, the document processor.
5 # Licence details can be found in the file COPYING.
9 # Full author contact details are available in file CREDITS
11 # This shell script takes the dialog created with fdesign and generates the
12 # .C and .h files used by LyX from it.
13 # Note that the REAL magic is to be found in the sed scripts fdfixc.sed and
14 # 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 // This file is part of LyX, the document processor.
31 // Licence details can be found in 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 echo "\"${FDESIGN} -convert ${FDFILE}\" failed. Please investigate."
60 #==================================
61 # Modify the .h file for use by LyX
62 HIN=${DIRNAME}/${BASENAME}.h
63 HPATCH=${DIRNAME}/${BASENAME}.h.patch
66 FDFIXH=${DIRNAME}/fdfixh.sed
71 sed -f $FDFIXH < $HIN >> ${HOUT}
73 # Patch the .h file if a patch exists
74 if [ -f "${HPATCH}" ] ; then
75 echo "Patching ${HOUT} with ${HPATCH}"
76 patch -s ${HOUT} < ${HPATCH}
79 # Clean up, to leave the finished .h file. We can be a little tricky here
80 # testing to see if the finished file exists already and if it does
81 # testing whether there are any differences.
82 # If there are no differences, then don't overwrite to prevent unnecessary
83 # compilation in the xforms directory.
86 if [ -r ${BASENAME}.h ]; then
87 cmp -s ${HOUT} ${BASENAME}.h
92 if [ ${MOVE_H_FILE} -eq 1 ]; then
93 mv ${HOUT} ${BASENAME}.h
98 #==================================
99 # Create the .C file for use by LyX
100 CIN=${DIRNAME}/${BASENAME}.c
101 CPATCH=${DIRNAME}/${BASENAME}.C.patch
103 FINAL_COUT=${BASENAME}.C
105 FDFIXC=${DIRNAME}/fdfixc.sed
111 echo "#include <config.h>" >> ${COUT}
112 echo "#include \"forms_gettext.h\"" >> ${COUT}
113 echo "#include \"gettext.h\"" >> ${COUT}
115 grep bmtable ${CIN} > /dev/null
116 if [ $? -eq 0 ]; then
117 echo "#include \"bmtable.h\"" >> ${COUT}
120 # This is (I hope) a very temporary fudge.
121 # FormMathsPanel should be modified in input() to not use the data parameter.
122 # Instead, use the FL_OBJECT * parameter.
123 # Angus 12 June, 2002.
124 grep MM_ ${CIN} > /dev/null
125 if [ $? -eq 0 ]; then
126 echo "#include \"MathsCallbacks.h\"" >> ${COUT}
131 sed -f ${FDFIXC} < ${CIN} >> ${COUT}
133 # Patch the .C file if a patch exists
134 if [ -f "$CPATCH" ] ; then
135 echo "Patching ${COUT} with $CPATCH"
136 patch -s ${COUT} < $CPATCH
139 # Clean up, to leave the finished .C file
141 mv ${COUT} ${FINAL_COUT}
143 #========================================