[MITgcm-devel] genmake2 and makedepend

Jean-Michel Campin jmc at ocean.mit.edu
Wed Dec 26 11:18:20 EST 2012


Hi Oliver,

On Wed, Dec 26, 2012 at 12:08:03PM -0300, Oliver Jahn wrote:
> Hi Jean-Michel,
> 
> I put it in the makefile because I wanted to make sure cpp in this
> command is run in the same environment as when it is run to produce
> .f files.  But we assume nothing changes between genmake2 and make
> anyway, so that's fine with me.  
I think this is what we assume.

> Would you like to make the change
> or shall I?
I would not mind if you take care of this.

> I don't think there is a need to use cppmakedepend.  There is
> nothing wrong with xmakedepend (and it should actually use the
> correct paths even without genmake2 changes).  I just wanted to see
> how one can use cpp -M to generate dependencies.  It may be slightly
> faster than what is done in xmakedepend (and simpler), but not sure
> about this.  So just leave it alone.
OK. I understand better now.

> I played a little with using cpp to make .d dependency files for
> each source file which can then be updated individually (and
> automatically, without make depend) when something changes, but the
> linking of source files got in the way.  I think we would have to do
> this from genmake2. Not sure it is worth pursuing this as the
> current build process works just fine.
Not sure either. Will see if this issue comes back.

Thanks,
Jean-Michel

> 
> Oliver
> 
> On 2012-12-26 10:20, Jean-Michel Campin wrote:
> >Hi Oliver,
> >
> >I guess it's just a detail, but I would prefer genmake2 to
> >run this command (which define CPPINC), and then have the
> >the setting of CPPINC= [list of include dir] copied in the
> >Makefile. I think this way would be little bit more clear what
> >makedepend command is used at the end.
> >
> >And regarding the new "cppmakedepend", it's intended to replace
> >"xmakedepend", right ? I don't remember what was the issue with
> >xmakedepend, so it did not try cppmakedepend yet.
> >
> >Cheers,
> >Jean-Michel
> >
> >On Thu, Dec 20, 2012 at 06:23:40PM -0300, Oliver Jahn wrote:
> >>My 2 cents for a one liner to extract the cpp search path:
> >>
> >>cat /dev/null | cpp -v 2>&1 | awk '/^End of
> >>search/{f=0}!/^#/{if(f){print "-I"$1}}/^#include "..." search
> >>start/{f=1}'
> >>
> >>The attached modif to genmake2 does this (in the makefile) and adds
> >>it to the makedepend command line.  I've tested it on the analogous
> >>problem we've been having with mpi on acesgrid.  This is with
> >>cyrus-makedepend (but shouldn't depend on this as it only adds -I
> >>options) and gnu cpp. If it doesn't find appropriate output, it will
> >>not add anything.  Seems the only way it could fail badly is if cpp
> >>doesn't have a -v option. Want to give it a try?
> >>
> >>Oliver
> >>
> >>On 2012-12-18 18:00, Jean-Michel Campin wrote:
> >>>Hi Martin,
> >>>
> >>>I agreee that it would be good to fix this (and check that it works with
> >>>our xmakedepend, with the cyrus-makedepend and with some default makedepend),
> >>>but would be nicer to put the true path that cpp uses, rather than a list of
> >>>potential location for the include (on my laptop, /usr/local/include
> >>>  is empty but /usr/include is not).
> >>>I guess the next question is, "is there a simple way to find
> >>>'the standard system include directories' ?"
> >>>I can see that "cpp -v" (among many things) give a list include dirs,
> >>>but don't know how standard it is (and how easy it is to extract this
> >>>list).
> >>>
> >>>Cheers,
> >>>Jean-Michel
> >>>
> >>>On Tue, Dec 18, 2012 at 04:36:43PM +0100, Martin Losch wrote:
> >>>>Hi Jean-Michel,
> >>>>
> >>>>you are right, the compilation still works, it just means that the corresponding files, e.g. mmc_file.f do not depend on netcdf.inc anymore, which one can probably live with.
> >>>>
> >>>>I guess one can fix this by enlarging the default search for make depend, e.g. always add -I/usr/local/include (or the typical search paths of cpp) to the arguments of $(MAKEDEPEND). It's not very nice because the list is likely to expand, but should be safe, because the actual paths have been checked with the test in genmake2. What do you think?
> >>>>
> >>>>Martin
> >>>>
> >>>>On Dec 18, 2012, at 2:56 PM, Jean-Michel Campin <jmc at ocean.mit.edu> wrote:
> >>>>
> >>>>>Hi Martin,
> >>>>>
> >>>>>It happens manay times to me that "make depend" return some warning/error,
> >>>>>but this does not prevent me to compile (with a successful "make").
> >>>>>Are you in this situation ?
> >>>>>
> >>>>>Otherwise, I find your suggestion little bit tricky, since it might
> >>>>>prevent to use NetCDF in cases where it is available.
> >>>>>My impression is that we should try to fix the makedepend step.
> >>>>>
> >>>>>Cheers,
> >>>>>Jean-Michel
> >>>>>
> >>>>>On Tue, Dec 18, 2012 at 02:04:54PM +0100, Martin Losch wrote:
> >>>>>>Hi there,
> >>>>>>my version of Murphy's law: Whenever you want to show how great everything is, it turns against you and does not work.
> >>>>>>
> >>>>>>I was trying to show to my group in a presentation, how makefiles are generated by genmake2 and how you compile the model etc, when "make depend" returned errors that it cannot find "netcdf.inc". This happened after the genmake_tnc.F test passed. I used darwin_amd64_gfortran with OS X 10.8 (mountain lion).
> >>>>>>
> >>>>>>The problem is that (on my PowerBook), /usr/bin/cpp finds files in /usr/local/include by default, and gfortran finds libraries in /usr/local/lib by default (that's where my netcdf installation is), so that the test passes without problems (-DHAVE_NETCDF), and more importantly without INCLUDES or INCLUDEPATH being set (I have NETCDF_ROOT unset by default). However, when make depend tries to build the dependencies, the include files are no longer found because apparently, my makedepend (/opt/X11/bin/makedepend) does not search /usr/local/include by default.
> >>>>>>
> >>>>>>I can easily fix this by specifying a proper NETCDF_ROOT (=/usr/local), but it shows that the netcdf test is not fool-proof. Do you have a suggestion how we can improve the test? E.g. tell cpp not to search anywhere that is not explicitly specified in the INCLUDEPATH?
> >>>>>>
> >>>>>>Martin
> >>>>>>
> >>>>>>
> >>>>>>_______________________________________________
> >>>>>>MITgcm-devel mailing list
> >>>>>>MITgcm-devel at mitgcm.org
> >>>>>>http://mitgcm.org/mailman/listinfo/mitgcm-devel
> >>>>>
> >>>>>_______________________________________________
> >>>>>MITgcm-devel mailing list
> >>>>>MITgcm-devel at mitgcm.org
> >>>>>http://mitgcm.org/mailman/listinfo/mitgcm-devel
> >>>>
> >>>>
> >>>>_______________________________________________
> >>>>MITgcm-devel mailing list
> >>>>MITgcm-devel at mitgcm.org
> >>>>http://mitgcm.org/mailman/listinfo/mitgcm-devel
> >>>
> >>>_______________________________________________
> >>>MITgcm-devel mailing list
> >>>MITgcm-devel at mitgcm.org
> >>>http://mitgcm.org/mailman/listinfo/mitgcm-devel
> >>>
> >>
> >
> >>diff --git a/tools/genmake2 b/tools/genmake2
> >>index f318d16..9440d8f 100755
> >>--- a/tools/genmake2
> >>+++ b/tools/genmake2
> >>@@ -2850,9 +2850,12 @@ fwd_exe_target:
> >>  	@echo Creating \$@ ...
> >>  	\$(LINK) -o \$@ \$(FFLAGS) \$(FOPTIM) \$(OBJFILES) \$(LIBS)
> >>
> >>+# extract CPP search path for makedepend
> >>+CPPINC = \`cat /dev/null | ${CPP} -v 2>&1 | awk '/^End of search/{f=0}!/^\\#/{if(f){print "-I"\$\$1}}/^\\#include "..." search start/{f=1}'\`
> >>+
> >>  depend:
> >>  	@\$(MAKE) -f \$(MAKEFILE) links
> >>-	\$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(F77_SRC_FILES)
> >>+	\$(MAKEDEPEND) -f \$(MAKEFILE) -o .$FS \$(DEFINES) \$(INCLUDES) \$(CPPINC) \$(F77_SRC_FILES)
> >>  	\$(TOOLSDIR)/f90mkdepend >> \$(MAKEFILE)
> >>  	-rm -f makedepend.out
> >>
> >>
> >
> >>_______________________________________________
> >>MITgcm-devel mailing list
> >>MITgcm-devel at mitgcm.org
> >>http://mitgcm.org/mailman/listinfo/mitgcm-devel
> >
> >
> >_______________________________________________
> >MITgcm-devel mailing list
> >MITgcm-devel at mitgcm.org
> >http://mitgcm.org/mailman/listinfo/mitgcm-devel
> >
> 
> _______________________________________________
> MITgcm-devel mailing list
> MITgcm-devel at mitgcm.org
> http://mitgcm.org/mailman/listinfo/mitgcm-devel



More information about the MITgcm-devel mailing list