--- MITgcm/tools/genmake2 2011/09/30 20:03:10 1.226 +++ MITgcm/tools/genmake2 2012/07/06 18:55:13 1.231 @@ -1,6 +1,6 @@ #! /usr/bin/env bash # -# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.226 2011/09/30 20:03:10 jmc Exp $ +# $Header: /home/ubuntu/mnt/e9_copy/MITgcm/tools/genmake2,v 1.231 2012/07/06 18:55:13 jmc Exp $ # $Name: $ # # Makefile generator for MITgcm UV codes @@ -297,7 +297,7 @@ .F.$tfs: $LN \$< \$@ EOF - $MAKE "genmake_hello."$tfs > /dev/null 2>&1 + $MAKE -f $MAKEFILE "genmake_hello."$tfs > /dev/null 2>&1 RETVAL=$? if test "x$RETVAL" != x0 -o ! -f "genmake_hello."$tfs ; then if test "x$FS" = x ; then @@ -384,7 +384,7 @@ stop end EOF - makedepend genmake_tc.f > /dev/null 2>&1 + makedepend -f $MAKEFILE genmake_tc.f > /dev/null 2>&1 RV1=$? test -f $MAKEFILE && rm -f $MAKEFILE test -f $MAKEFILE".tst" && mv -f $MAKEFILE".tst" $MAKEFILE @@ -450,7 +450,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then echo "OK" - DEFINES="$DEFINES -DHAVE_EMBED_SRC" return 0 fi done @@ -462,7 +461,6 @@ return 1 fi echo "OK" - DEFINES="$DEFINES -DHAVE_EMBED_SRC" } # look for possible C compilers @@ -784,7 +782,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_CLOC=t - DEFINES="$DEFINES -DHAVE_CLOC" fi rm -f genmake_tc* echo " --> set HAVE_CLOC='$HAVE_CLOC'" >> $LOGFILE @@ -846,17 +843,12 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_SIGREG=t - DEFINES="$DEFINES -DHAVE_SIGREG" fi rm -f genmake_tc* echo " --> set HAVE_SIGREG='$HAVE_SIGREG'" >> $LOGFILE } check_HAVE_SETRLSTK() { - if test "x$HAVE_SETRLSTK" = xt ; then - DEFINES="$DEFINES -DHAVE_SETRLSTK" - return - fi if test ! "x$HAVE_SETRLSTK" = x ; then return fi @@ -894,7 +886,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_SETRLSTK=t - DEFINES="$DEFINES -DHAVE_SETRLSTK" fi rm -f genmake_tc* echo " --> set HAVE_SETRLSTK='$HAVE_SETRLSTK'" >> $LOGFILE @@ -941,7 +932,6 @@ RETVAL=$? if test "x$RETVAL" = x0 ; then HAVE_STAT=t - DEFINES="$DEFINES -DHAVE_STAT" fi rm -f genmake_tc* echo " --> set HAVE_STAT='$HAVE_STAT'" >> $LOGFILE @@ -1768,6 +1758,7 @@ printf " Can we call simple C routines (here, \"cloc()\") using $FC... " check_HAVE_CLOC if test "x$HAVE_CLOC" != x ; then + DEFINES="$DEFINES -DHAVE_CLOC" echo "yes" else echo "no" @@ -1782,6 +1773,7 @@ printf " Can we unlimit the stack size using $FC... " check_HAVE_SETRLSTK if test "x$HAVE_SETRLSTK" = xt ; then + DEFINES="$DEFINES -DHAVE_SETRLSTK" echo "yes" else echo "no" @@ -1791,6 +1783,7 @@ printf " Can we register a signal handler using $FC... " check_HAVE_SIGREG if test "x$HAVE_SIGREG" = xt ; then + DEFINES="$DEFINES -DHAVE_SIGREG" echo "yes" else echo "no" @@ -1800,6 +1793,7 @@ printf " Can we use stat() through C calls... " check_HAVE_STAT if test "x$HAVE_STAT" != x ; then + DEFINES="$DEFINES -DHAVE_STAT" echo "yes" else echo "no" @@ -1809,6 +1803,7 @@ printf " Can we create NetCDF-enabled binaries... " check_netcdf_libs if test "x$HAVE_NETCDF" != x ; then + DEFINES="$DEFINES -DHAVE_NETCDF" echo "yes" else echo "no" @@ -1820,6 +1815,7 @@ fi if test "x$EMBED_SRC" = xt ; then ENABLE="$ENABLE embed_files" +# DEFINES="$DEFINES -DHAVE_EMBED_SRC" fi printf "\n=== Setting defaults ===\n" @@ -2658,7 +2654,7 @@ NOOPTFLAGS = ${NOOPTFLAGS} # Flags and libraries needed for linking LIBS = ${LIBS} -# Name of the Mekfile +# Name of the makefile MAKEFILE=${MAKEFILE} EOF @@ -2696,8 +2692,8 @@ \$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS) depend: - @make links - \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) + @make -f \$(MAKEFILE) links + \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) -rm -f makedepend.out @@ -2726,8 +2722,8 @@ # remove most of the files that "make" and "make depend" generate Clean: - @make clean - @make cleanlinks + @make -f \$(MAKEFILE) clean + @make -f \$(MAKEFILE) cleanlinks -rm -f \$(SPECIAL_FILES) f90mkdepend.log $MAKEFILE.old -rm -f taf_command taf_output taf_ad.log taf_ad_flow.log -rm -f genmake_warnings genmake_errors make.log @@ -2735,7 +2731,7 @@ # remove also the executable, files that "genmake2" generates (except Makefile) # and output from a run (plus log files from testreport) CLEAN: - @make Clean + @make -f \$(MAKEFILE) Clean -rm -f \$(EXECUTABLE) \$(EXE_AD) *.bak -rm -f $LOGFILE genmake_state genmake_*optfile -rm -f SIZE.h.mpi genmake.tr_log make.tr_log @@ -2757,7 +2753,7 @@ @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bPACKAGES_CONFIG_H "Disabled packages:" \$(DISABLED_PACKAGES) " " "Enabled packages:" \$(ENABLED_PACKAGES) > \$@ AD_CONFIG.h: @echo Creating \$@ ... - @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > \$@ + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -bAD_CONFIG_H -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > \$@ FC_NAMEMANGLE.h: @echo Creating \$@ ... echo "$FC_NAMEMANGLE" > \$@ @@ -2871,11 +2867,11 @@ adtamc: ad_tamc_output.$FS ad_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) \$(AD_FLOW_FILES) - @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ad_config.template + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -DALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > ad_config.template cmp ad_config.template AD_CONFIG.h || cat ad_config.template > AD_CONFIG.h -rm -f ad_config.template - @make \$(F77_PP_SRC_FILES) - @make \$(FLOFILES) + @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) + @make -f \$(MAKEFILE) \$(FLOFILES) cat \$(FLOFILES) \$(AD_FILES) | sed -f \$(TOOLSDIR)/remove_comments_sed > ad_input_code.$FS ad_taf_output.$FS: ad_input_code.$FS @@ -2912,11 +2908,11 @@ ftltamc: ftl_tamc_output.$FS ftl_input_code.$FS: \$(AD_FILES) \$(H_SRC_FILES) - @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h -rm -f ftl_config.template - @make \$(F77_PP_SRC_FILES) - @make \$(AD_FLOW_FILES) + @make -f \$(MAKEFILE) \$(F77_PP_SRC_FILES) + @make -f \$(MAKEFILE) \$(AD_FLOW_FILES) cat \$(AD_FLOW_FILES) \$(AD_FILES) > ftl_input_code.$FS ftl_taf_output.$FS: ftl_input_code.$FS @@ -2959,7 +2955,7 @@ touch ad_taf_output.$FS ftl_taf_output.$FS \$(FC) \$(FFLAGS) \$(FOPTIM) -c ad_taf_output.$FS \$(FC) \$(FFLAGS) \$(FOPTIM) -c ftl_taf_output.$FS - @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > ftl_config.template + @$BASH\$(TOOLSDIR)/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -DALLOW_TANGENTLINEAR_RUN > ftl_config.template cmp ftl_config.template AD_CONFIG.h || cat ftl_config.template > AD_CONFIG.h -rm -f ftl_config.template @@ -3036,7 +3032,7 @@ .PHONY: adDepend adDepend: \$(ALL_LINKED_FILES) \$(addsuffix _mod.h, \$(CB2M_F90_SRC_NAMES)) \$(addsuffix _mod.FF90, \$(CB2M_F90_SRC_NAMES)) \$(F77_SRC_FILES:.F=_cb2m.FF90) - \$(MAKEDEPEND) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) + \$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES) \$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE) -rm -f makedepend.out @@ -3175,7 +3171,7 @@ # this step also creates the file postProcess.make but we cannot # name it as the target or else make will try to remake it for # the include directive above for any rule, e.g. make clean - ./postProcess.py --progress --timing --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$< + ./postProcess.py --progress --timing --infoUnitFile w2f__types.f90 --outputFormat=fixed -m r -i ../OAD_support/ad_inline.f --width 4 \$< # setup some links %.xsd: @@ -3259,7 +3255,7 @@ fi fi if test ! -f AD_CONFIG.h ; then - $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN -UALLOW_ECCO_OPTIMIZATION > AD_CONFIG.h + $BASH $TOOLSDIR/convert_cpp_cmd2defines "Warning - this file is automatically generated - do NOT edit" -UALLOW_ADJOINT_RUN -UALLOW_TANGENTLINEAR_RUN > AD_CONFIG.h fi # Write the "state" for future records