/[MITgcm]/MITgcm/tools/genmake
ViewVC logotype

Diff of /MITgcm/tools/genmake

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.22.2.3 by adcroft, Thu Jan 25 17:56:33 2001 UTC revision 1.24 by adcroft, Mon Feb 5 18:46:14 2001 UTC
# Line 3  Line 3 
3  # $Header$  # $Header$
4  #  #
5  # Makefile generator for MITgcm UV codes  # Makefile generator for MITgcm UV codes
6  #   created by cnh 03/98  #   created  by cnh 03/98
7  #   adapted by aja 06/98  #   adapted  by aja 06/98
8    #   modified by aja 01/00
9    
10    # Default lists
11    set DISABLE = ( aim )
12    set ENABLE  = ( )
13    set MODS  = ( )
14    
15    # Grab variables/lists from .genmakerc
16    if (-r .genmakerc) source .genmakerc
17    
18  # Process command-line arguments  # Process command-line arguments
19  set allargs=( $argv )  set allargs=( $argv )
# Line 24  while ($#allargs) Line 33  while ($#allargs)
33     exit     exit
34     breaksw     breaksw
35   case -platform*:   case -platform*:
36       if ($?platform) then
37        echo Option -platform=dir can only be specified once.; exit 1
38       endif
39     set platform = ( `echo $arg | sed 's/-platform=//' `)     set platform = ( `echo $arg | sed 's/-platform=//' `)
40     breaksw     breaksw
41     case -rootdir:
42     case -rootdir=:
43       echo "To specify root directory you must specify one with -rootdir=dir"
44       echo "with NO space eg. -rootdir=../../..  or  -rootdir=/usr/people/joe/src"
45       exit
46       breaksw
47   case -rootdir=*:   case -rootdir=*:
48       if ($?ROOTDIR) then
49        echo "***" Warning: variable \$ROOTDIR is already set to $ROOTDIR
50        echo "***" Command line \"$arg\" will override this.
51       endif
52     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)     set ROOTDIR = ( `echo $arg | sed 's/-rootdir=//' `)
53     breaksw     breaksw
54   case -mymods=*:   case -mods:
55     set MYMODS = ( `echo $arg | sed 's/-mymods=//' `)   case -mods=:
56       echo "To specify an additional source directory you must specify one with -mods=dir"
57       echo "with NO space eg. -mods=../code  or  -mods=/usr/people/joe/src"
58       exit
59       breaksw
60     case -mods=*:
61       set MODS = ( $MODS `echo $arg | sed 's/-mods=//' | sed 's/,/ /g' `)
62       breaksw
63     case -disable:
64     case -disable=:
65       echo "To disable packages from compilation use -disable=pkg1,pkg2"
66       echo "with NO spaces eg. -disable=kpp,gmredi or -disable=all (to enable all packages)"
67       exit
68       breaksw
69     case -disable=*:
70       set DISABLE = ( $DISABLE `echo $arg | sed 's/-disable=//' | sed 's/,/ /g' `)
71       breaksw
72     case -enable:
73     case -enable=:
74       echo "To enable packages from compilation use -enable=pkg1,pkg2"
75       echo "with NO spaces eg. -enable=aim or -enable=all (to enable all packages)"
76       echo "-enable overrides -disable, ie. a package listed in both is enabled"
77       exit
78       breaksw
79     case -enable=*:
80       set ENABLE = ( $ENABLE `echo $arg | sed 's/-enable=//' | sed 's/,/ /g' `)
81     breaksw     breaksw
82   case -mpi:   case -mpi:
83     echo "Enabling MPI options"     echo "Enabling MPI options"
# Line 56  end Line 103  end
103  # Default actions/options  # Default actions/options
104    
105  # If platform wasn't specified then determine platform type of the host  # If platform wasn't specified then determine platform type of the host
106  if ($?platform == 0) then  if (! $?platform) then
107   set platform = (`uname`)   set platform = (`uname`)
108  endif  endif
109  # If name of makefile wasn't specified then use default "Makefile"  # If name of makefile wasn't specified then use default "Makefile"
110  if ($?mfile == 0) set mfile = ( Makefile )  if (! $?mfile) set mfile = ( Makefile )
111    
112  set mach  = ( `uname -a` )  set mach  = ( `uname -a` )
113  echo Operating system: $mach  echo Operating system: $mach
114    
115    
116  # Directories for source, includes, binaries and executables  # Directories for source, includes, binaries and executables
 # Note  
 # o If you prefer/need everything under a single directory  
 #   copy everything in ../eesupp/src, ../model/src,  
 #   ../eesupp/inc and ../model/inc into a directory and then  
 #   edit the paths below to ./  
117  #  #
118  # If -rootdir wasn't specified then assume script is being run from bin  # If -rootdir wasn't specified then assume script is being run from bin
119  # but if it was supplied then we should place the executable in the build dir  # but if it was supplied then we should place the executable in the build dir
120  if ($?ROOTDIR == 0) then  if (! $?ROOTDIR) then
121    set ROOTDIR = ( .. )    set ROOTDIR = ( .. )
122  else  else
123    if ($?EXEDIR == 0) set EXEDIR = ( ./ )    if (! $?EXEDIR) set EXEDIR = ( . )
124    endif
125    if (! -d $ROOTDIR) then
126      echo Root directory $ROOTDIR not found.;exit 1
127  endif  endif
128  if ($?MYMODS == 0) then  # If -mods wasn't specified then we will assume that we can find all the
129   set SOURCEDIRS  = ( $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )  # source code in the standard directories
130   set INCLUDEDIRS = ( ./ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )  if (! $?MODS) then
131     set SOURCEDIRS  = ( )
132     set INCLUDEDIRS = ( . )
133  else  else
134   set SOURCEDIRS  = ( $MYMODS/ $ROOTDIR/{eesupp,model,diags}/src/ $ROOTDIR/pkg/[a-z]*/ )   set SOURCEDIRS  = ( $MODS )
135   set INCLUDEDIRS = ( ./ $MYMODS/ $ROOTDIR/{eesupp,model,diags}/inc/ $ROOTDIR/pkg/[a-z]*/ )   set INCLUDEDIRS = ( . $MODS )
136  endif  endif
137  if ($?BUILDDIR == 0) set BUILDDIR = ( ./ )  if (! $?BUILDDIR) set BUILDDIR = ( . )
138  if ($?EXEDIR == 0) set EXEDIR = ( $ROOTDIR/exe/ )  if (! -d $BUILDDIR) then
139  if ($?EXECUTABLE == 0) set EXECUTABLE  = ( mitgcmuv )    echo Build directory $BUILDDIR not found.;exit 1
140  if ($?TOOLSDIR == 0) set TOOLSDIR = ( $ROOTDIR/tools/ )  endif
141    if (! $?EXEDIR) set EXEDIR = ( $ROOTDIR/exe )
142    if (! -d $EXEDIR) then
143      echo Executable directory $EXEDIR not found.;exit 1
144    endif
145    if (! $?TOOLSDIR) set TOOLSDIR = ( $ROOTDIR/tools )
146    if (! -d $TOOLSDIR) then
147      echo Tools directory $TOOLSDIR not found.;exit 1
148    endif
149    if (! $?EXECUTABLE) set EXECUTABLE  = ( mitgcmuv )
150    
151    # Now scan the standard source code tree
152    foreach dr ($SOURCEDIRS)
153      set adr=$dr
154      if (! -d $adr) then
155        echo mods directory $adr not found.; exit 1
156      endif
157      echo Adding mods directory $adr
158    end
159    if (! $?STANDARDDIRS) set STANDARDDIRS=(eesupp model diags)
160    foreach dr ($STANDARDDIRS)
161      set adr=$ROOTDIR/$dr/src
162      if (! -d $adr) then
163        echo Source directory $adr not found.; exit 1
164      endif
165      echo Adding source directory $adr
166      set SOURCEDIRS = ($SOURCEDIRS $adr)
167      set idr = `echo $adr | sed 's/src/inc/'`
168      set INCLUDEDIRS = ($INCLUDEDIRS $idr)
169    end
170    if (! $?PACKAGES) then
171      set PACKAGES=(`cd $ROOTDIR/pkg; ls -1 | grep -v CVS`)
172    endif
173    foreach dr ($PACKAGES)
174      set enable
175      foreach p ($DISABLE)
176       if ($dr == $p) unset enable
177       if ($p == 'all') unset enable
178      end
179      foreach p ($ENABLE)
180       if ($dr == $p) set enable
181      end
182      if ($?enable) then
183        set adr=$ROOTDIR/pkg/$dr
184        if (! -d $adr) then
185          echo Source directory $adr not found.; exit 1
186        endif
187        echo Adding package directory $adr
188        set SOURCEDIRS = ($SOURCEDIRS $adr)
189        set INCLUDEDIRS = ($INCLUDEDIRS $adr)
190      else
191        echo "*" Package \"$dr\" has not been enabled.
192      endif
193    end
194    
195  # This is the generic configuration.  # This is the generic configuration.
196  # Platform specific options are chosen below  # Platform specific options are chosen below
# Line 269  switch ($platform$USEMPI) Line 369  switch ($platform$USEMPI)
369      set CPP        = ( '/lib/cpp -traditional -P' )      set CPP        = ( '/lib/cpp -traditional -P' )
370      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )      set DEFINES    = ( ${DEFINES} '-DWORDLENGTH=4' )
371      set FC         = ( 'pgf77' )      set FC         = ( 'pgf77' )
372      set FFLAGS     = ( '-byteswapio' )      set FFLAGS     = ( '-byteswapio -r8 -Mnodclchk -Mextend' )
373      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )      set FOPTIM     = ( '-tp p6 -v -O2 -Munroll -Mvect=cachesize:512000,transform -Kieee' )
374      set LINK       = ( 'pgf77' )      set LINK       = ( 'pgf77' )
375      breaksw      breaksw
# Line 361  foreach dr ($SOURCEDIRS) Line 461  foreach dr ($SOURCEDIRS)
461   if ($#deplist != 0) then   if ($#deplist != 0) then
462    echo "# These files are linked from $dr" >> srclinks.tmp    echo "# These files are linked from $dr" >> srclinks.tmp
463    echo $deplist':' >> srclinks.tmp    echo $deplist':' >> srclinks.tmp
464    echo '\t$(LN) '$dr'$@ $@' >> srclinks.tmp    echo '        $(LN) '$dr'/$@ $@' >> srclinks.tmp
465   endif   endif
466  end  end
467  rm -rf .links.tmp  rm -rf .links.tmp
# Line 373  set THISHOSTNAME = ( `hostname` ) Line 473  set THISHOSTNAME = ( `hostname` )
473  set THISCWD = ( `pwd` )  set THISCWD = ( `pwd` )
474  set THISDATE = ( `date` )  set THISDATE = ( `date` )
475    
476    if (-r $mfile) mv -f $mfile $mfile.bak
477  ###########################################  ###########################################
478  ## This is the template for the makefile ##  ## This is the template for the makefile ##
479  ###########################################  ###########################################
480  echo Creating makefile: $mfile  echo Creating makefile: $mfile
481  echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}  echo "# Multithreaded + multi-processing makefile for $mach" > ${mfile}
482  echo "# This makefile was generated automatically pn" >> ${mfile}  echo "# This makefile was generated automatically on" >> ${mfile}
483  echo "#    $THISDATE" >> ${mfile}  echo "#    $THISDATE" >> ${mfile}
484  echo "# by the command:" >> ${mfile}  echo "# by the command:" >> ${mfile}
485  echo "#    ${0} $argv" >> ${mfile}  echo "#    ${0} $argv" >> ${mfile}
# Line 408  BUILDDIR    = ${BUILDDIR} Line 509  BUILDDIR    = ${BUILDDIR}
509  SOURCEDIRS  = ${SOURCEDIRS}  SOURCEDIRS  = ${SOURCEDIRS}
510  INCLUDEDIRS = ${INCLUDEDIRS}  INCLUDEDIRS = ${INCLUDEDIRS}
511  EXEDIR      = ${EXEDIR}  EXEDIR      = ${EXEDIR}
512  EXECUTABLE  = \$(EXEDIR)${EXECUTABLE}  EXECUTABLE  = \$(EXEDIR)/${EXECUTABLE}
513  TOOLSDIR    = ${TOOLSDIR}  TOOLSDIR    = ${TOOLSDIR}
514    
515  EOF  EOF
# Line 504  clean: Line 605  clean:
605  Clean:  Clean:
606          @make clean          @make clean
607          -find . -type l -exec rm {} \;          -find . -type l -exec rm {} \;
608          -rm Makefile.bak          -rm -f Makefile.bak
609  CLEAN:  CLEAN:
610          @make Clean          @make Clean
611          -find \$(ROOTDIR)/verification/*/input/ -name "*.meta" -exec rm {} \;          -find \$(ROOTDIR) -name "*.meta" -exec rm {} \;
612          -find \$(ROOTDIR)/verification/*/input/ -name "*.data" -exec rm {} \;          -find \$(ROOTDIR) -name "*.data" -exec rm {} \;
613          -rm \$(EXECUTABLE)          -rm -f \$(EXECUTABLE)
614    
615  # The normal chain of rules is (  .F - .f - .o  )  # The normal chain of rules is (  .F - .f - .o  )
616  .F.f:  .F.f:

Legend:
Removed from v.1.22.2.3  
changed lines
  Added in v.1.24

  ViewVC Help
Powered by ViewVC 1.1.22