--- MITgcm/tools/genmake2 2003/08/27 22:12:31 1.5 +++ MITgcm/tools/genmake2 2003/09/26 18:47:59 1.10 @@ -1,6 +1,6 @@ #!/bin/bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.5 2003/08/27 22:12:31 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.10 2003/09/26 18:47:59 adcroft Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -109,8 +109,10 @@ echo " -pdepend=NAME | --pdepend=NAME" echo " -pdefault NAME | --pdefault NAME" echo " -pdefault=NAME | --pdefault=NAME" - echo " -makefile NAME | -ma NAME" - echo " --makefile=NAME | -ma=NAME" + echo " -make NAME | -m NAME" + echo " --make=NAME | -m=NAME" + echo " -makefile NAME | -mf NAME" + echo " --makefile=NAME | -mf=NAME" echo " -platform NAME | --platform NAME | -pl NAME | --pl NAME" echo " -platform=NAME | --platform=NAME | -pl=NAME | --pl=NAME" echo " -rootdir NAME | --rootdir NAME | -rd NAME | --rd NAME" @@ -201,6 +203,9 @@ THISCWD=`pwd` THISDATE=`date` MACHINE=`uname -a` +EXECUTABLE= +EXEHOOK= +EXEDIR= # The following state can be set directly by command-line switches gm_s1="OPTFILE PDEPEND PDEFAULT MAKEFILE PLATFORM ROOTDIR MODS DISABLE ENABLE NOOPT" @@ -210,8 +215,9 @@ gm_s3="LN S64 KPP LINK PACKAGES MAKEDEPEND PDEPEND PDEFAULT INCLUDES FFLAGS FOPTIM " gm_s4="CFLAGS KFLAGS1 KFLAGS2 LIBS KPPFILES NOOPTFILES NOOPTFLAGS" gm_s5="TOOLSDIR SOURCEDIRS INCLUDEDIRS PWD MAKE THISHOSTNAME THISDATE MACHINE" +gm_s6="EXECUTABLE EXEHOOK EXEDIR" -gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5" +gm_state="COMMANDL $gm_s1 $gm_s2 $gm_s3 $gm_s4 $gm_s5 $gm_s6" echo @@ -273,9 +279,14 @@ -pdefault=* | --pdefault=*) PDEFAULT=$ac_optarg ;; - -makefile | -ma) + -make | --make | -m | --m) + ac_prev=MAKE ;; + -make=* | --make=* | -m=* | --m=*) + MAKE=$ac_optarg ;; + + -makefile | --makefile | -ma | --ma) ac_prev=MAKEFILE ;; - --makefile=* | -ma=*) + -makefile=* | --makefile=* | -ma=* | --ma=*) MAKEFILE=$ac_optarg ;; -platform | --platform | -pl | --pl) @@ -378,6 +389,41 @@ fi fi +# Check that FC, LINK, CPP, and S64 are defined. If not, complain +# and abort! +if test "x$FC" = x ; then + cat <&2 + +Error: no Fortran compiler: please specify using one of the following: + 1) within the options file ("FC=...") as specified by "-of=OPTFILE" + 2) the "-fc=XXX" command-line option + 3) the "./gm_local" file +EOF + exit 1 +fi +if test "x$LINK" = x ; then + LINK=$FC +fi +if test "x$CPP" = x ; then + cat <&2 + +Error: no C pre-processor: please specify using one of the following: + 1) within the options file ("CPP=...") as specified by "-of=OPTFILE" + 2) the "./gm_local" file +EOF + exit 1 +fi +if test "x$S64" = x ; then + cat <&2 + +Error: no C pre-processor: please specify using one of the following: + 1) within the options file ("S64=...") as specified by "-of=OPTFILE" + 2) the "./gm_local" file +EOF + exit 1 +fi + + printf "\n=== Setting defaults ===\n" echo -n " Adding MODS directories: " for d in $MODS ; do @@ -650,9 +696,9 @@ # done # echo -echo " Setting package-specific CPP flags in CPP_OPTIONS.h:" +echo " Searching for CPP_OPTIONS.h (macros and flags for configuring the model):" CPP_OPTIONS= -spaths="$SOURCEDIRS" +spaths="$MODS ./ $SOURCEDIRS" for i in $spaths ; do try="$i/CPP_OPTIONS.h" # echo -n " trying $try : " @@ -787,7 +833,7 @@ echo -n 'CSRCFILES = ' > csrclist.inc echo -n 'F90SRCFILES = ' > f90srclist.inc echo -n 'HEADERFILES = ' > hlist.inc -alldirs=". $SOURCEDIRS $INCLUDEDIRS" +alldirs="$SOURCEDIRS $INCLUDEDIRS ." for d in $alldirs ; do deplist= sfiles=`( cd $d; echo *.[h,c,F] )` @@ -938,7 +984,7 @@ depend: @make links \$(MAKEDEPEND) -o .f \$(DEFINES) \$(INCLUDES) \$(SRCFILES) - ../../../tools/f90mkdepend >> \$(MAKEFILE) + ${TOOLSDIR}/f90mkdepend >> \$(MAKEFILE) links: \$(SRCFILES) \$(CSRCFILES) \$(HEADERFILES) \$(F90SRCFILES) @@ -986,6 +1032,10 @@ EOF +if test "x$EXEHOOK" != x ; then + printf "\nexehook:\n\t%s\n" $EXEHOOK >> $MAKEFILE +fi + echo " Making list of \"exceptions\" that need \".p\" files" for i in $KPPFILES ; do base=`echo $i | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`