help-make
[Top][All Lists]
Advanced

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

Re: cmd-line goal modification


From: Paul D. Smith
Subject: Re: cmd-line goal modification
Date: Wed, 28 Mar 2001 23:56:55 -0500

%% "Asperheim, Eric" <address@hidden> writes:

  ae> Is it possible to modify a command line goal before gmake tries to do
  ae> anything? 

No.

  ae> Currently, my Makefile has 

  ae> DB := dbs/        # location of gmake outputs - .db files
  ae> SRC := src/       # location of gmake source files - .vhdl files
  ae> $(DB)c.db : $(SRC)c.vhdl $(DB)csfa.db $(DB)csfb.db
  ae> $(DB)csfa.db : $(SRC)csfa.vhdl 
  ae> $(DB)csfb.db : $(SRC)csfb.vhdl

  ae> and I have a pattern rule to build the .db from the .vhdl
  ae> $(DB)%.db : $(SRC)%.vhdl
  ae>   @cmds

  ae> If the user types "gmake", everything works and all 3 targets are
  ae> made. But if the user only wants a lower level target,
  ae> e.g. dbs/cfsa.db, the user would have to type

  ae> "gmake dbs/cfsa.db"

  ae> It would be convenient if the user only had to type
  ae> "gmake csfa.db" 

  ae> I've tried a couple of things

  ae> Try #1 - modify Makefile
  ae> $(DB)csfa.db csfa.db : $(SRC)csfa.vhdl 
  ae> and add another pattern rule
  ae> %.db : $(SRC)%.vhdl
  ae> PROLBEM: I'll get a dbs/csfa.db file. However, it always appears stall to
  ae> gmake since csfa.db doesn't really exist in the current work directory.

No, this isn't what you want.

  ae> Try #2 - edit the $(MAKECMDGOALS) variable. 
  ae> ifeq ($(MAKECMDGOALS), csfa.db)
  ae> override MAKECMDGOALS := dbs/csfa.db
  ae> endif

This won't work.  The GNU make manual specifically states that ``setting
this variable has no effect on the operation of `make'''.


I thought this up a few months ago and have been using it, but I haven't
had time to update the docs on my site.

Anyway, think about what you want to do, then express it as a make rule:
if the user requests a target csfa.db, you want to build a target
dbs/cfsa.db.  No problem:

  %.db : $(DB)%.db ;

Note we use an empty command here (trailing semicolon) because otherwise
we're removing the rule instead of defining it (see the GNU make
manual).

Also, in this case you should probably only do this if DB is not empty,
otherwise you'll get an error from make.

-- 
-------------------------------------------------------------------------------
 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]