--- MITgcm/tools/genmake2 2003/10/01 19:33:01 1.11.2.2 +++ MITgcm/tools/genmake2 2003/10/03 18:54:16 1.11.2.9 @@ -1,6 +1,6 @@ #!/bin/bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.11.2.2 2003/10/01 19:33:01 edhill Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.11.2.9 2003/10/03 18:54:16 edhill Exp $ # # Makefile generator for MITgcm UV codes # created by cnh 03/98 @@ -39,13 +39,40 @@ fi } +# Read the $ROOTDIR/pkg/pkg_groups file and expand any references to +# the package list. +expand_pkg_groups() { + new_packages= + PKG_GROUPS=$ROOTDIR"/pkg/pkg_groups" + if test -r $PKG_GROUPS ; then + cat $PKG_GROUPS | sed -e 's/#.*$//g' | sed -e 's/:/ : /g' > ./p1.tmp + cat ./p1.tmp | awk '(NF>2 && $2==":"){ print $0 }' > ./p2.tmp + matched=0 + for i in $PACKAGES ; do + line=`grep $i ./p2.tmp` + RETVAL=$? + if test "x$RETVAL" = x0 ; then + matched=1 + replace=`echo $line | awk '{ $1=""; $2=""; print $0 }'` + echo " replacing \"$i\" with: $replace" + new_packages="$new_packages $replace" + else + new_packages="$new_packages $i" + fi + done + PACKAGES=$new_packages + rm -f ./p[1,2].tmp + else + echo "Warning: can't read package groups definition file: $PKG_GROUPS" + fi +} # Guess possible config options for this host find_possible_configs() { tmp1=`uname`"_"`uname -m` tmp2=`echo $tmp1 | sed -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'` - PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/'` + PLATFORM=`echo $tmp2 | sed -e 's/i[3-6]86/ia32/' | sed -e 's/athlon/ia32/'` OFLIST=`(cd $ROOTDIR/tools/build_options; ls | grep "^$PLATFORM")` echo " The platform appears to be: $PLATFORM" # if test "x$OFLIST" = x ; then @@ -634,8 +661,19 @@ source ./.pd_tmp rm -f ./.pd_tmp +# Search for default packages. Note that a "$ROOTDIR/pkg/pkg_groups" +# file should eventually be added so that, for convenience, one can +# specify groups of packages using names like "ocean" and "atmosphere". echo -n " checking default package list: " if test "x${PDEFAULT}" = x ; then + for i in "." $MODS ; do + if test -r $i"/packages.conf" ; then + PDEFAULT=$i"/packages.conf" + break + fi + done +fi +if test "x${PDEFAULT}" = x ; then PDEFAULT="$ROOTDIR/pkg/pkg_default" fi if test "x${PDEFAULT}" = xNONE ; then @@ -657,7 +695,9 @@ for i in $def ; do PACKAGES="$PACKAGES $i" done - echo " packages are: $PACKAGES" + echo " before group expansion packages are: $PACKAGES" + expand_pkg_groups + echo " after group expansion packages are: $PACKAGES" fi fi @@ -793,19 +833,17 @@ # echo # Create a list of #define and #undef to enable/disable packages -PACKAGES_DOT_H=PACKAGES.h -if test -e $PACKAGES_DOT_H ; then - cat $PACKAGES_DOT_H \ - | awk 'BEGIN{p=1;} ($1=="C===" && $2=="GENMAKE"){p=0;} {if (p==1) print $0}' \ - > $PACKAGES_DOT_H".tmp" -fi -cat <>$PACKAGES_DOT_H".tmp" +PACKAGES_DOT_H=PACKAGES_CONFIG.h +cat <$PACKAGES_DOT_H".tmp" C=== GENMAKE v2 === C The following defines have been set by GENMAKE, so please do not C edit anything below these comments. In general, you should C add or remove packages by re-running genmake with different C "-enable" and/or "-disable" options. +#ifndef PACKAGES_H +#define PACKAGES_H + C Packages disabled by genmake: EOF # The following UGLY HACK sets multiple "#undef"s and it needs to go @@ -865,11 +903,22 @@ #EH3 WARNING : This is an UGLY HACK that needs to be removed!!! done -cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H -RETVAL=$? -if test "x$RETVAL" = x0 ; then - mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H".bak" +cat <>$PACKAGES_DOT_H".tmp" + +#endif /* PACKAGES_H */ +EOF + +if test ! -f $PACKAGES_DOT_H ; then mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H +else + cmp $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H + RETVAL=$? + if test "x$RETVAL" = x0 ; then + rm -f $PACKAGES_DOT_H".tmp" + else + mv -f $PACKAGES_DOT_H $PACKAGES_DOT_H".bak" + mv -f $PACKAGES_DOT_H".tmp" $PACKAGES_DOT_H + fi fi echo " Adding STANDARDDIRS" @@ -1104,7 +1153,7 @@ Clean: @make clean @make cleanlinks - -rm -f Makefile.bak gm_state gm_optfile make.log PACKAGES.h* + -rm -f Makefile.bak gm_state gm_optfile make.log CLEAN: @make Clean -find \$(EXEDIR) -name "*.meta" -exec rm {} \;