--- MITgcm/tools/genmake2 2003/11/12 21:14:57 1.31 +++ MITgcm/tools/genmake2 2003/11/14 02:48:18 1.36 @@ -1,6 +1,6 @@ -#!/bin/bash +#!/bin/sh # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.31 2003/11/12 21:14:57 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.36 2003/11/14 02:48:18 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -104,6 +104,16 @@ CPP="cpp -traditional -P" fi + # makedepend is not always available + if test "x${MAKEDEPEND}" = x ; then + which makedepend >& /dev/null + RETVAL=$? + if test "x${RETVAL}" = x1 ; then + echo " makedepend was not found. Using xmakedpend instead." + MAKEDEPEND='$(TOOLSDIR)/xmakedepend' + fi + fi + # look for possible fortran compilers tmp="$MITGCM_FC $FC efc g77 f77 pgf77 pgf95 ifc f90 f95 mpif77 mpf77 mpxlf95" p_FC= @@ -206,7 +216,7 @@ cat $1 | sed -e 's/#.*$//g' \ | $AWK 'BEGIN{nn=0;} (NF>0){ for(i=2;i<=NF;i++){nn++; print "PNAME["nn"]="$1"\nDNAME["nn"]="$i} }' \ > ./.pd_tmp - source ./.pd_tmp + . ./.pd_tmp rm -f ./.pd_tmp echo -n "PNAME = "${} @@ -338,6 +348,9 @@ fi FC_NAMEMANGLE="#define FC_NAMEMANGLE(X) $nmangle" + + # cleanup the testing files + rm -f genmake_tcomp.* genmake_test.* } # Set defaults here @@ -437,14 +450,14 @@ gm_local="genmake_local" for i in . $MODS ; do if test -r $i/$gm_local ; then - source $i/$gm_local + . $i/$gm_local break fi done echo -n " getting local config information: " if test -e $gm_local ; then echo "using $gm_local" - source $gm_local + . $gm_local # echo "DISABLE=$DISABLE" # echo "ENABLE=$ENABLE" else @@ -648,7 +661,7 @@ if test "x$OPTFILE" != xNONE ; then if test -f "$OPTFILE" -a -r "$OPTFILE" ; then echo " using OPTFILE=\"$OPTFILE\"" - source "$OPTFILE" + . "$OPTFILE" RETVAL=$? if test "x$RETVAL" != x0 ; then echo -n "Error: failed to source OPTFILE \"$OPTFILE\"" @@ -675,7 +688,7 @@ if test "x${AD_OPTFILE}" != xNONE ; then if test -f "$AD_OPTFILE" -a -r "$AD_OPTFILE" ; then echo " using AD_OPTFILE=\"$AD_OPTFILE\"" - source "$AD_OPTFILE" + . "$AD_OPTFILE" RETVAL=$? if test "x$RETVAL" != x0 ; then echo -n "Error: failed to source AD_OPTFILE \"$AD_OPTFILE\"" @@ -691,8 +704,8 @@ fi fi -# Check that FC, LINK, CPP, and S64 are defined. If not, complain -# and abort! +# Check that FC, LINK, CPP, S64, and LN are defined. If not, +# complain and abort! if test "x$FC" = x ; then cat <&2 @@ -728,7 +741,22 @@ if test "x$MAKEDEPEND" = x ; then MAKEDEPEND=makedepend fi +if test "x$LN" = x ; then + LN="ln -s" +fi +echo "test" > genmake_test_ln +$LN genmake_test_ln genmake_tlink +RETVAL=$? +if test "x$RETVAL" != x0 ; then + cat <&2 + +Error: The command "ln -s" failed -- please specify a working soft-link + command in the optfile. +EOF + exit 1 +fi +rm -f genmake_test_ln genmake_tlink printf "\n=== Checking system libraries ===\n" echo -n " Do we have the system() command using $FC... " @@ -836,7 +864,7 @@ # they appear as regular source code if test -r $ROOTDIR"/eesupp/src/Makefile" ; then echo " Making source files in eesupp from templates" - $MAKE -C $ROOTDIR"/eesupp/src/" > make_eesupp.errors 2>&1 + ( cd $ROOTDIR"/eesupp/src/" && $MAKE ) > make_eesupp.errors 2>&1 RETVAL=$? if test "x${RETVAL}" = x0 ; then rm -f make_eesupp.errors @@ -873,7 +901,7 @@ echo "Error: unable to parse package dependencies -- please check PDEPEND=\"$PDEPEND\"" exit 1 fi -source ./.pd_tmp +. ./.pd_tmp rm -f ./.pd_tmp # Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups"