--- MITgcm/tools/genmake 2001/02/05 18:46:14 1.24 +++ MITgcm/tools/genmake 2001/03/05 19:57:31 1.32 @@ -1,6 +1,6 @@ #!/bin/csh -f # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.24 2001/02/05 18:46:14 adcroft Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.32 2001/03/05 19:57:31 adcroft Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -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 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 # 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) > \$@