help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Auto-checkout a file from RCS that is used to construct a prerequis


From: Philip Guenther
Subject: Re: Auto-checkout a file from RCS that is used to construct a prerequisites list
Date: Fri, 3 Jul 2009 15:38:02 -0600

On Thu, Jul 2, 2009 at 8:45 AM, Richard
Bassett<address@hidden> wrote:
> Background:  I'm bootstrapping a Domain-specific language and I'm trying to
> automate a full build, where make checks all the required files out from
> RCS.  My DSL has a simple preprocessor for textual substitution and
> currently I allow a file named _WITHTAB.PP in a source subdirectory to
> specify a list of 'preprocessor substitution tables' to apply to all the
> sources in that subdirectory.
>
> This means that the targets produced from each source file in a directory
> depend on any _WITHTAB.PP file in that directory and on the 'preprocessor
> substitution tables to apply' that are listed in the _WITHTAB.PP file.
>
> So, I tried to handle that in my makefile like this:
...
>   $(msg_dsl_targets) : msg/_WITHTAB.PP $(patsubst
>   %,$(target)%.tabo,$(subst $(comma),$(space),$(shell cat
>   msg/_WITHTAB.PP)))

Hmm, you must have .SECONDEXPANSION: in play...


> As is probably obvious, the _WITHTAB.PP file contains a commalist of simple
> names such as  "STD,T1,T2" and I'm just transforming that into a
> space-separated list of the prerequisite targets (that will be built from
> the source 'substitution tables') such as "STD.tabo T1.tabo T2.tabo"
>
> This seems just fine in my development environment where the _WITHTAB.PP
> file already exists.  My problem is that when I try and build in some other
> 'clean' environment and I want make to fetch all the source from RCS
> automatically, I get the following error:
>
>   cat: msg/_WITHTAB.PP: No such file or directory
>
>
> Now, I *think* I understand this - I'm assuming that make wants to process
> all the rules and construct its 'database' before actually taking any
> actions such as fetching something from RCS.
>
> So, if I have understood correctly, my problem is that I somehow need to get
> make to fetch the msg/_WITHTAB.PP file from RCS *before* constructing those
> dependencies in which the file itself participates.. but I'm not quite clear
> if that's possible or how one would go about it.
>
> I can see that what I'm doing is conceptually similar to include-ing another
> makefile except that my _WITHTAB.PP file is not in fact a makefile fragment.
>  So I wonder if there's some trick possible with include maybe - but again I
> can't quite see how to make it happen!
>
> I can also see there is an analogy with an #included C header file that
> #includes other header files and that leads me to think that I could
> manually maintain say a _WITHTAB.d file alongside each _WITHTAB.PP file -
> ie. _WITHTAB.d would be an includeable makefile fragment that just expressed
> the dependency of _WITHTAB.PP on the items listed therein.
>
> But then I'd have to maintain two files, sacrilege.

Well, there's always the alternate heresy of fixing the program that
generates _WITHTAB.PP to write "TABS=" at the start of it.  Then you
could include it directly and use ${TABS} where needed.  Problem
solved.


Otherwise, if you need something more complex...

It sounds like you need some tool that you could tell how to build
_WITHTAB.d from _WITHTAB.PP and that that only needed to be done if
the latter was newer than the former.  Have you considered using
'make' for that?

_WITHTAB.d: _WITHTAB.PP
        sed -e 's/^/TABS=/' -e 's/,/ /g' -e 1q <_WITHTAB.PP >$@
-include _WITHTAB.d


Philip Guenther




reply via email to

[Prev in Thread] Current Thread [Next in Thread]