--- MITgcm/tools/genmake 2001/02/02 21:36:30 1.23 +++ MITgcm/tools/genmake 2001/05/14 22:04:44 1.34 @@ -1,6 +1,6 @@ #!/bin/csh -f # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.23 2001/02/02 21:36:30 adcroft Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.34 2001/05/14 22:04:44 heimbach Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -8,7 +8,7 @@ # modified by aja 01/00 # Default lists -set DISABLE = ( aim ) +set DISABLE = ( aim autodiff cal cost ctrl ecco exf ) set ENABLE = ( ) set MODS = ( ) @@ -58,7 +58,7 @@ exit breaksw case -mods=*: - set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /' `) + set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /g' `) breaksw case -disable: case -disable=: @@ -67,7 +67,7 @@ exit breaksw case -disable=*: - set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /' `) + set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /g' `) breaksw case -enable: case -enable=: @@ -77,7 +77,7 @@ exit breaksw case -enable=*: - set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /' `) + set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `) breaksw case -mpi: echo "Enabling MPI options" @@ -118,9 +118,25 @@ # If -rootdir wasn't specified then assume script is being run from bin # but if it was supplied then we should place the executable in the build dir if (! $?ROOTDIR) then - set ROOTDIR = ( .. ) -else - if (! $?EXEDIR) set EXEDIR = ( . ) + set pwd=`pwd` + if ($pwd:t == bin & -d ../model & -d ../eesupp & -d ../pkg) then + set ROOTDIR = ( .. ) + endif +endif +# Scan for logical ROOTDIR +if (! $?ROOTDIR) then + foreach dr (. .. ../.. ../../.. ../../../.. ../../../../..) + if (-d $dr/model & -d $dr/eesupp & -d $dr/pkg) then + set ROOTDIR = $dr + echo ROOTDIR was not specified. Setting ROOTDIR = \"$ROOTDIR\" + break + endif + end +endif +if (! $?ROOTDIR) then + echo Root directory was not specified and could not be determined. + echo Specify the root location of the model source with -rootdir=dir + exit 1 endif if (! -d $ROOTDIR) then echo Root directory $ROOTDIR not found.;exit 1 @@ -138,7 +154,14 @@ if (! -d $BUILDDIR) then echo Build directory $BUILDDIR not found.;exit 1 endif -if (! $?EXEDIR) set EXEDIR = ( $ROOTDIR/exe ) +if (! $?EXEDIR) then + set pwd=`pwd` + if ($pwd:t == bin & -d ../exe & $ROOTDIR == ..) then + set EXEDIR = ( ../exe ) + else + set EXEDIR = ( . ) + endif +endif if (! -d $EXEDIR) then echo Executable directory $EXEDIR not found.;exit 1 endif @@ -156,23 +179,16 @@ endif echo Adding mods directory $adr end -if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model diags) -foreach dr ($STANDARDDIRS) - set adr=$ROOTDIR/$dr/src - if (! -d $adr) then - echo Source directory $adr not found.; exit 1 - endif - echo Adding source directory $adr - set SOURCEDIRS = ($SOURCEDIRS $adr) - set idr = `echo $adr | sed 's/src/inc/'` - set INCLUDEDIRS = ($INCLUDEDIRS $idr) -end if (! $?PACKAGES) then set PACKAGES=(`cd $ROOTDIR/pkg; ls -1 | grep -v CVS`) endif foreach dr ($PACKAGES) set enable foreach p ($DISABLE) + if ($p != 'all' & ! -d $ROOTDIR/pkg/$p) then + echo Specified package \"$p\" does not exist. + exit 1 + endif if ($dr == $p) unset enable if ($p == 'all') unset enable end @@ -191,6 +207,17 @@ echo "*" Package \"$dr\" has not been enabled. endif end +if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model) +foreach dr ($STANDARDDIRS) + set adr=$ROOTDIR/$dr/src + if (! -d $adr) then + echo Source directory $adr not found.; exit 1 + endif + echo Adding source directory $adr + set SOURCEDIRS = ($SOURCEDIRS $adr) + set idr = `echo $adr | sed 's/src/inc/'` + set INCLUDEDIRS = ($INCLUDEDIRS $idr) +end # This is the generic configuration. # Platform specific options are chosen below @@ -231,7 +258,7 @@ set KPPFILES = ( 'main.F' ) set KFLAGS1 = ( '-scan=132 -noconc -cmp=' ) set FC = ( 'f77' ) - set FFLAGS = ( '-convert big_endian -r8 -extend_source -u -automatic -call_shared -notransform_loops -align dcommons' ) + set FFLAGS = ( '-convert big_endian -r8 -extend_source -automatic -call_shared -notransform_loops -align dcommons' ) set FOPTIM = ( '-O5 -fast -tune host -inline all' ) set NOOPTFLAGS = ( '-O0' ) set LIBS = ( '-lfmpi -lmpi -lkmp_osfp10 -pthread' ) @@ -596,6 +623,7 @@ depend: @make links makedepend -o .f \$(INCLUDES) \$(SRCFILES) + links: \$(SRCFILES) small_f: \$(F77FILES) @@ -604,14 +632,19 @@ -rm -rf *.o *.f *.p ${RMFILES} Clean: @make clean - -find . -type l -exec rm {} \; + @make cleanlinks -rm -f Makefile.bak CLEAN: @make Clean - -find \$(ROOTDIR) -name "*.meta" -exec rm {} \; - -find \$(ROOTDIR) -name "*.data" -exec rm {} \; + -find \$(EXEDIR) -name "*.meta" -exec rm {} \; + -find \$(EXEDIR) -name "*.data" -exec rm {} \; -rm -f \$(EXECUTABLE) +makefile: + ${0} $argv +cleanlinks: + -find . -type l -exec rm {} \; + # The normal chain of rules is ( .F - .f - .o ) .F.f: \$(CPP) \$(DEFINES) \$(INCLUDES) > \$@