help-make
[Top][All Lists]
Advanced

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

Re: Oddity with make and % macro


From: Paul D. Smith
Subject: Re: Oddity with make and % macro
Date: Mon, 26 Mar 2001 22:33:14 -0500

%% "Brian J. Murrell" <address@hidden> writes:

  >> It's simple to keep a target from being considered intermediate, if you
  >> want, by merely mentioning it as a prerequisite somewhere in the
  >> makefile.

  bjm> Well that is what made sense to me, that does not work; hence my
  bjm> posting the question about it.

  bjm> Given the make rules:

  bjm> sync%: .sync-foo-% .sync-bar-%
  bjm>         echo "all done"

  bjm> .sync-foo-%: foo
  bjm>         @DEST=$(subst .sync-foo-,,$@); \
  bjm>         echo Sending foo file to $$DEST; \
  bjm>         scp ...              
  bjm>         touch $@

Note: you can replace "$(subst .sync-foo-,,$@)" here with just "$*".

  bjm> .sync-bar-%: bar-%
  bjm>         @DEST=$(subst .sync-bar-,,$@); \
  bjm>         echo Sending bar file to $$DEST; \
  bjm>         scp ...
  bjm>         touch $@

Ditto here.

That'll probably simplify things enough that you don't even need the
temporary variable, if you don't want it, and you can make these all
separate lines in the command script instead of concatenating them.

That might save you a tiny bit of efficiency.

  bjm> and the command:

  bjm> # make synctest

  bjm> I still get:

  bjm> Sending foo file to test
  bjm> touch .sync-foo-test
  bjm> Sending bar file to test
  bjm> touch .sync-bar-test
  bjm> echo "all done"
  bjm> all done
  bjm> rm .sync-foo-test .sync-bar-test

I do not see any mention of ".sync-foo-test" or ".sync-bar-test" in the
makefile you've provided.

Since they're not mentioned anywhere in the makefile, but instead
inferred completely by make, they're considered intermediate files and
eligible for deletion.

If you don't want the auto-removal feature at all, for any files, you
can use a plain ".SECONDARY:" with no prerequisites and all intermediate
targets will be considered secondary.  Note this was broken up until
fairly recently; I _think_ it's been fixed in one of the released
versions, not just in CVS.  Try it and if it doesn't work let me know
and I'll check for a patch.


Just a question: why don't you want them deleted?  If they are needed
somewhere by some rule, then _that_ is where you should declare them a
prerequisite, which will keep make from deleting them.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://www.paulandlesley.org/gmake/
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



reply via email to

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