--- MITgcm/tools/genmake 2001/02/06 04:22:36 1.25 +++ MITgcm/tools/genmake 2001/02/08 18:00:24 1.29 @@ -1,6 +1,6 @@ #!/bin/csh -f # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.25 2001/02/06 04:22:36 cnh Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/Attic/genmake,v 1.29 2001/02/08 18:00:24 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 @@ -608,8 +631,8 @@ -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) # The normal chain of rules is ( .F - .f - .o )