|
From: | Ronald Landheer-Cieslak |
Subject: | Re: Getting the target of an implicit rule within the rule |
Date: | Mon, 26 Jul 2004 17:19:35 -0400 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707 |
Paul D. Smith wrote:
%% Ronald Landheer-Cieslak <address@hidden> writes: rl> %.d : $(srcdir)/$(subst .d,.c,$@) rl> blah rl> $@, however, is empty here (as the docs duely indicate). >> Why not just use the obvious:>> >> %.d : $(srcdir)/%.crl> because the obvious doesn't work if there's a pathname in the rl> target filename (i.e. target == dir/file.d, prereq would become rl> dir/$(srcdir)/file.c because the stem of the pattern is "file", rl> not "dir/file"). Well sure, that won't work, but that's not the example you gave. It's hard to give solutions that work for examples that are not provided :).
OK, let me just give you a wee bit of background, then:I have a single, partly-generated Makefile that will make entire source tree. It is generated by a bootstrap & configure script in two steps: Makefile.in.in > (bootstrap) > Makefile.in > (configure) > Makefile The contents of each is available at http://cvs.sf.net/viewcvs.py/jail-ust/config/ with the Makefile.in.in itself at http://cvs.sf.net/viewcvs.py/jail-ust/config/Makefile.in.in?view=markup
The number of subdirectories to make is variable, so I can't just pre-write the rules for each: I want to reduce the re-writing to be done for each new module (directory) to the first line on which I enumerate them all as bootstrap-replaced variables.
The idea of the setup is that you can do $ bash bootstrap $ mkdir .build && cd .build $ ../configure $ make and compile everything in one go, without recursive makes.The reason for not using recursive makes is double: maintainability and make time. Maintainability because I only have to maintain a module.mk file per directory, to which I just add the name of a source file whenever there's a new source file. Speed of make for the reasons stipulated in http://cvs.sf.net/viewcvs.py/*checkout*/jail-ust/doc/auug97.pdf
Sorry about not giving this background in the original post: I guess I snipped it when I weeded out the "unnecessary" details :(
> Typically what I do is not try to install the srcdir inside the > pathname but rather have it at the top. If you have to put it inside > you'll have to write a different rule for each value of "dir". You > can use $(eval ...) (in the newest releases of GNU make) to do this > without typing it all out. Now *there's* an idea!I hadn't gotten around to linking my libraries yet, because I hadn't figured out a way to do it generically, but $(eval ...) just might do the trick - thanks :)
rlc
[Prev in Thread] | Current Thread | [Next in Thread] |