--- MITgcm/tools/genmake2 2003/08/16 14:01:08 1.1 +++ MITgcm/tools/genmake2 2003/08/22 04:07:00 1.2 @@ -1,6 +1,6 @@ #!/bin/bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.1 2003/08/16 14:01:08 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.2 2003/08/22 04:07:00 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -210,9 +210,10 @@ # Explain usage usage() { - echo "" + echo echo "Usage: "$0" [OPTIONS]" - echo " where [OPTIONS] can be:"$'\n' + echo " where [OPTIONS] can be:" + echo echo " -help | --help | -h | --h" echo " -nooptfile | --nooptfile" echo " -optfile NAME | --optfile NAME | -of NAME | --of NAME" @@ -241,11 +242,14 @@ echo " -fc=NAME | --fc=NAME" echo " -[no]ieee | --[no]ieee" echo " -[no]mpi | --[no]mpi" - echo " -[no]jam | --[no]jam"$'\n' - echo " and NAME is a string such as:"$'\n' + echo " -[no]jam | --[no]jam" + echo + echo " and NAME is a string such as:" + echo echo " --enable pkg1 --enable 'pkg1 pkg2' --enable 'pkg1 pkg2 pkg3'" echo " -mods=dir1 -mods='dir1' -mods='dir1 dir2 dir3'" - echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'"$'\n' + echo " -foptim='-Mvect=cachesize:512000,transform -xtypemap=real:64,double:64,integer:32'" + echo echo " which, depending upon your shell, may need to be single-quoted" echo " if it contains spaces, dashes, or other special characters." exit 1 @@ -298,7 +302,7 @@ PDEPEND= PDEFAULT= OPTFILE= -INCLUDES=-I. +INCLUDES="-I." FFLAGS= FOPTIM= CFLAGS= @@ -321,32 +325,143 @@ THISDATE=`date` MACHINE=`uname -a` -echo $'\n'"=== Processing options files and arguments ===" +echo +echo "=== Processing options files and arguments ===" gm_local="./gm_local" echo -n " getting local config information: " if test -e $gm_local ; then echo "using $gm_local" source $gm_local - echo "DISABLE=$DISABLE"$'\n'"ENABLE=$ENABLE" + # echo "DISABLE=$DISABLE" + # echo "ENABLE=$ENABLE" else echo "none found" fi # echo "$0::$1:$2:$3:$4:$5:$6:$7:" -OPTIONS=() -n=0 -for i ; do - setvar="OPTIONS[$n]='$i'" - # echo " $setvar" - eval "$setvar" - n=$(( $n + 1 )) +#OPTIONS= +#n=0 +#for i ; do +# echo "$i $n" +# setvar="OPTIONS[$n]='$i'" +# # echo " $setvar" +# eval "$setvar" +# n=$(( $n + 1 )) +#done +#parse_options + +ac_prev= +for ac_option ; do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + case $ac_option in + + -help | --help | -h | --h) + usage ;; + + -nooptfile | --nooptfile) + OPTFILE="NONE" ;; + -optfile | --optfile | -of | --of) + ac_prev=optfile ;; + -optfile=* | --optfile=* | -of=* | --of=*) + OPTFILE=$ac_optarg ;; + + -pdepend | --pdepend) + ac_prev=pdepend ;; + -pdepend=* | --pdepend=*) + PDEPEND=$ac_optarg ;; + + -pdefault | --pdefault) + ac_prev=pdefault ;; + -pdefault=* | --pdefault=*) + PDEFAULT=$ac_optarg ;; + + -makefile | -ma) + ac_prev=makefile ;; + --makefile=* | -ma=*) + MAKEFILE=$ac_optarg ;; + + -platform | --platform | -pl | --pl) + ac_prev=platform ;; + -platform=* | --platform=* | -pl=* | --pl=*) + PLATFORM=$ac_optarg ;; + + -rootdir | --rootdir | -rd | --rd) + ac_prev=rootdir ;; + -rootdir=* | --rootdir=* | -rd=* | --rd=*) + ROOTDIR=$ac_optarg ;; + + -mods | --mods | -mo | --mo) + ac_prev=mods ;; + -mods=* | --mods=* | -mo=* | --mo=*) + MODS=$ac_optarg ;; + + -disable | --disable) + ac_prev=disable ;; + -disable=* | --disable=*) + DISABLE=$ac_optarg ;; + + -enable | --enable) + ac_prev=enable ;; + -enable=* | --enable=*) + ENABLE=$ac_optarg ;; + + -noopt | --noopt) + ac_prev=noopt ;; + -noopt=* | --noopt=*) + NOOPT=$ac_optarg ;; + +# -cpp | --cpp) +# ac_prev=cpp ;; +# -cpp=* | --cpp=*) +# CPP=$ac_optarg ;; + + -fortran | --fortran | -fc | --fc) + ac_prev=fc ;; + -fc=* | --fc=*) + FC=$ac_optarg ;; + + -ieee | --ieee) + IEEE=1 ;; + -noieee | --noieee) + IEEE=0 ;; + + -mpi | --mpi) + MPI=1 ;; + -nompi | --nompi) + MPI=0 ;; + + -jam | --jam) + JAM=1 ;; + -nojam | --nojam) + JAM=0 ;; + + -*) + echo "Error: unrecognized option: "$ac_option + usage + ;; + + *) + echo "Error: unrecognized argument: "$ac_option + usage + ;; + + esac + done -parse_options echo " getting OPTFILE information: " if test "x${OPTFILE}" = x ; then echo "Warning: no OPTFILE specified so we'll look for possible settings" - echo $'\n'"=== Searching for possible settings for OPTFILE ===" + printf "\n=== Searching for possible settings for OPTFILE ===\n" find_possible_configs else if test "x$OPTFILE" = xNONE ; then @@ -368,11 +483,12 @@ fi fi -echo $'\n'"=== Setting defaults ===" +printf "\n=== Setting defaults ===\n" echo -n " Adding MODS directories: " for d in $MODS ; do if test ! -d $d ; then - echo $'\n\n'"Error: MODS directory \"$d\" not found!" + echo + echo "Error: MODS directory \"$d\" not found!" exit 1 else echo -n " $d" @@ -443,7 +559,7 @@ echo " Making source files in eesupp from templates" $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1 RETVAL=$? - if test "x${RETVAL}" == "x0" ; then + if test "x${RETVAL}" = x0 ; then rm -f make_eesupp.errors else echo "Error: problem encountered while building source files in eesupp:" @@ -452,7 +568,7 @@ fi fi -echo $'\n'"=== Determining package settings ===" +printf "\n=== Determining package settings ===\n" if test "x${PDEPEND}" = x ; then tmp=$ROOTDIR"/pkg/pkg_depend" if test -r $tmp ; then @@ -471,7 +587,7 @@ # Strip the comments and then convert the dependency file into # two arrays: PNAME, DNAME cat $PDEPEND | sed -e 's/#.*$//g' \ - | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ + | awk 'BEGIN{nn=-1;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME_"nn"="$1"\nDNAME_"nn"="$i}} END{print "nname="nn}' \ > ./.pd_tmp RETVAL=$? if test ! "x${RETVAL}" = x0 ; then @@ -544,11 +660,14 @@ ck= while test "x$ck" != xtt ; do i=0 - rtot=${#PNAME[@]} + # rtot=${#PNAME[@]} + rtot=$nname while test $i -lt $rtot ; do # Is $pname in the current $PACKAGES list? - pname=${PNAME[$i]} + # pname=${PNAME[$i]} + tmp="pname=\"\$PNAME_$i\"" + eval $tmp pin="f" for p in $PACKAGES ; do if test "x$p" = "x$pname" ; then @@ -557,15 +676,17 @@ done # Is the DNAME entry a (+) or (-) rule ? + tmp="dname=\"\$DNAME_$i\"" + eval $tmp plus="-" - echo "${DNAME[$i]}" | grep '^+' > /dev/null 2>&1 + echo $dname | grep '^+' > /dev/null 2>&1 RETVAL=$? if test "x$RETVAL" = x0 ; then plus="+" fi # Is $dname in the current $PACKAGES list? - dname=`echo ${DNAME[$i]} | sed -e 's/^[+-]//'` + dname=`echo $dname | sed -e 's/^[+-]//'` din="f" for p in $PACKAGES ; do if test "x$p" = "x$dname" ; then @@ -751,7 +872,8 @@ done -echo $'\n'"=== Creating the Makefile ===" +echo +echo "=== Creating the Makefile ===" echo " setting INCLUDES" for i in $INCLUDEDIRS ; do if test -d $i ; then @@ -797,9 +919,10 @@ fi done if test "x$deplist" != x ; then - echo $'\n'"# These files are linked from $d" >> srclinks.tmp + echo "" >> srclinks.tmp + echo "# These files are linked from $d" >> srclinks.tmp echo "$deplist :" >> srclinks.tmp - echo $'\t$(LN) '$d'/$@ $@' >> srclinks.tmp + printf "\t\$(LN) %s/\$@ \$@\n" $d >> srclinks.tmp fi done rm -rf .links.tmp @@ -965,7 +1088,7 @@ echo "Error: unable to add file \"$i\" to the exceptions list" fi echo "$base.o: $base.f" >> $MAKEFILE - echo $'\t$(FC) $(FFLAGS) $(NOOPTFLAGS) -c $<' >> $MAKEFILE + printf "\t\$(FC) \$(FFLAGS) \$(NOOPTFLAGS) -c \$<\n" >> $MAKEFILE done echo " Add rules for links" @@ -973,6 +1096,6 @@ rm -f srclinks.tmp echo " Adding makedepend marker" -echo $'\n\n'"# DO NOT DELETE" >> $MAKEFILE +printf "\n\n# DO NOT DELETE\n" >> $MAKEFILE -echo $'\n'"=== Done ===" +printf "\n=== Done ===\n"