#!/bin/sh # # \file fdfix.sh # Copyright 2002 the LyX Team # Read the file COPYING # # \author Angus Leeming, leeming@lyx.org # # This shell script takes the dialog created with fdesign and generates the # .C and .h files used by LyX from it. # Note that the REAL magic is to be found in the sed scripts fdfixc.sed and # fdfixh.sed used by this shell script. INTRO_MESSAGE () { DATE=`date +"%Y"` # Note that we can't create a variable containing this and then # echo it across because some machines require -e to recognize \n et al. # Other machines, of course output -e, it not being an option they # recognise ;-) # Set ${OUTPUT_FILE} to ${HOUT} or ${COUT} as appropriate cat - > ${OUTPUT_FILE} <> ${HOUT} # Patch the .h file if a patch exists if [ -f "${HPATCH}" ] ; then echo "Patching ${HOUT} with ${HPATCH}" patch -s ${HOUT} < ${HPATCH} fi # Clean up, to leave the finished .h file. We can be a little tricky here # testing to see if the finished file exists already and if it does # testing whether there are any differences. # If there are no differences, then don't overwrite to prevent unnecessary # compilation in the xforms directory. rm -f ${HIN} MOVE_H_FILE=1 if [ -r ${BASENAME}.h ]; then cmp -s ${HOUT} ${BASENAME}.h if [ $? -eq 0 ]; then MOVE_H_FILE=0 fi fi if [ ${MOVE_H_FILE} -eq 1 ]; then mv ${HOUT} ${BASENAME}.h else rm -f ${HOUT} fi #================================== # Create the .C file for use by LyX CIN=${DIRNAME}/${BASENAME}.c CPATCH=${DIRNAME}/${BASENAME}.C.patch COUT=${BASENAME}.cpp FINAL_COUT=${BASENAME}.C FDFIXC=${DIRNAME}/fdfixc.sed OUTPUT_FILE=${COUT} INTRO_MESSAGE echo >> ${COUT} echo "#include " >> ${COUT} echo "#include \"forms_gettext.h\"" >> ${COUT} echo "#include \"gettext.h\"" >> ${COUT} grep bmtable ${CIN} > /dev/null if [ $? -eq 0 ]; then echo "#include \"bmtable.h\"" >> ${COUT} fi # This is (I hope) a very temporary fudge. # FormMathsPanel should be modified in input() to not use the data parameter. # Instead, use the FL_OBJECT * parameter. # Angus 12 June, 2002. grep MM_ ${CIN} > /dev/null if [ $? -eq 0 ]; then echo "#include \"MathsCallbacks.h\"" >> ${COUT} fi echo >> ${COUT} sed -f ${FDFIXC} < ${CIN} >> ${COUT} # Patch the .C file if a patch exists if [ -f "$CPATCH" ] ; then echo "Patching ${COUT} with $CPATCH" patch -s ${COUT} < $CPATCH fi # Clean up, to leave the finished .C file rm -f ${CIN} mv ${COUT} ${FINAL_COUT} #========================================