RE: Makefile
Posted in 2005
Here is a Korn Shell script called: "makeamake" that we use. You should be able to get it to work for your install easily enough (assuming you know something about make files). The default executable name is the name of the current directory. Jay Fellows: I need to construct a Makefile in Unix, it must contain the c4gl compiler and formbld compiler for forms, also it must contain the outpur file that must be the same of the main program. Can anybosy help me ? Thanks a lot. #!/usr/bin/ksh # # $Source: /usr/app/RCS/src/tools/makeamake,v $ # $Revision: 1.0 $ # $Date: 1999/08/05 20:42:00 $ # $Author: NAME $ # $State: Exp $ # $Locker: $ # ############################################################################### # Functions # Globals TRUE="TRUE" FALSE="" CFLAGS=-O LDFLAGS=-s #BINDIR=~/bin #FRMDIR=~/frm LIBS= # main if [ "$1" = "-h" -o "$1" = "--h" -o "$1" = "--help" ] then print "makeamake" print " General Running makeamake in a directory with source code will create a make file according to the following rules: - Target name is the name of the directory (unless there is a .maketarget file) - Install directory for executables is the \\$HOME/bin directory (unless there is a .makebindir file) Note: The templet used for creating Makefiles is appended to the end of this script. 4GL Both Informix RDS and compiled executables are created for 4GL executables. Additional rules for 4GL are: - Install directory for screen forms is the \\$HOME/frm directory (unless there is a .makefrmdir file) Only 4GL source files are currently supported. " | pg exit fi # XXX Set all defaults to TRUE #[ "$1" = "--default" ] && DEFAULTS=$TRUE || DEFAULTS=$FALSE DEFAULTS=$TRUE if [ -f Makefile ] then print "WARNING! There is already a Makefile in this directory." print print -n "Press Enter to move it to a .save and continue or 'q' to quit: " read Ans [ "$Ans" = q ] && exit mv Makefile Makefile.save fi # Default executable name if [ -f .maketarget ] then Package=$(< .maketarget) else Package=$(basename $(pwd)) fi # Install directories if [ -f .makebindir ] then BINDIR=$(< .makebindir) else BINDIR=~/bin fi if [ -f .makefrmdir ] then FRMDIR=$(< .makefrmdir) else FRMDIR=~/frm fi # Look for files to determine executable type FGL=$FALSE if ls *.4gl >/dev/null 2>&1 then FGL=$TRUE fi EC=$FALSE if ls *.ec >/dev/null 2>&1 then EC=$TRUE fi C=$FALSE if ls *.c >/dev/null 2>&1 then C=$TRUE fi F=$FALSE if ls *.per >/dev/null 2>&1 then F=$TRUE fi # Is this a Top-Level Makefile? if [ ! "${FGL}" -a ! "${C}" -a ! "${EC}" ] then for SubDir in * do [ -d $SubDir ] && SubDirs="$SubDirs$SubDir " done print "Top-Level Make. Please select the directories to include: " egrep "^G\\||^TOP\\|" $0 | cut -d\\| -f2 > Makefile ex Makefile >/dev/null 2>&1 <<-EOF_EX g?^SUBDIRS=?s??SUBDIRS=$SubDirs? w q EOF_EX for SubDir in $SubDirs do ex Makefile >/dev/null 2>&1 <<-EOF_EX /TOP_LEVEL_CLEAN a cd $SubDir; make clean . /TOP_LEVEL_CLOBBER a cd $SubDir; make clobber . /TOP_LEVEL_INSTALL a cd $SubDir; make install . w q EOF_EX done #mv Makefile.save Makefile #exit elif [ "${FGL}" -a ! "${C}" -a ! "${EC}" ] then print "Making a Makefile for 4gl (only) source..." CTARGET=${Package}.4ge PTARGET=${Package}.4gi FGLOBJS="" FGLPOBJS="" for FGL in *.4gl do FGLOBJS="${FGLOBJS}${FGL%.4gl}.o " FGLPOBJS="${FGLPOBJS}${FGL%.4gl}.4go " done if [ "$F" ] then DESTPATH=$(dirname $CTARGET) for PER in *.per do FGLFORMS="${FGLFORMS}${DESTPATH}/${PER%.per}.frm " done else FGLFORMS="" fi print "These are the defaulted values for the Makefile variables." print print "To use the value, press Enter. Otherwise, enter a value:" print if [ ! "$DEFAULTS" ] then print "BINDIR=$BINDIR" print -n "BINDIR=" read Ans && [ "$Ans" ] && BINDIR=$Ans print "FRMDIR=$FRMDIR" print -n "FRMDIR=" read Ans && [ "$Ans" ] && FRMDIR=$Ans print "CFLAGS=$CFLAGS" print -n "CFLAGS=" read Ans && [ "$Ans" ] && CFLAGS=$Ans print "LDFLAGS=$LDFLAGS" print -n "LDFLAGS=" read Ans && [ "$Ans" ] && LDFLAGS=$Ans print "LIBS=$LIBS" print -n "LIBS=" read Ans && [ "$Ans" ] && LIBS=$Ans print "CTARGET=$CTARGET" print -n "CTARGET=" read Ans && [ "$Ans" ] && CTARGET=$Ans print "PTARGET=$PTARGET" print -n "PTARGET=" read Ans && [ "$Ans" ] && PTARGET=$Ans print "FGLOBJS=$FGLOBJS" print -n "FGLOBJS=" read Ans && [ "$Ans" ] && FGLOBJS=$Ans print "FGLPOBJS=$FGLPOBJS" print -n "FGLPOBJS=" read Ans && [ "$Ans" ] && FGLPOBJS=$Ans print "FGLFORMS=$FGLFORMS" print -n "FGLFORMS=" read Ans && [ "$Ans" ] && FGLFORMS=$Ans fi if [ "$FGLFORMS" ] then egrep "^G\\||^4GL\\||^FORM\\|" $0 | cut -d\\| -f2 > Makefile else egrep "^G\\||^4GL\\|" $0 | cut -d\\| -f2 > Makefile fi elif [ "$C" ] then print C source files only EXEC=${Package} OBJS="" for OBJ in *.c do OBJS="${OBJS}${OBJ%.c}.o " done egrep "^G\\||^C\\|" $0 | cut -d\\| -f2 > Makefile else print "Sorry,