help-make
[Top][All Lists]
Advanced

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

Re: urgent help on Makefile


From: Paul D. Smith
Subject: Re: urgent help on Makefile
Date: Tue, 8 May 2001 23:58:20 -0400

%% Yin Lei <address@hidden> writes:

  yl> Above method for making all targets at one time doesn't work, except
  yl> by typing "make all"

You should read the GNU make manual; this is all explained there in the
chapter "Writing Rules".

If you don't specify a target on the command line, the default target is
built.  The default target is the first explicit target that appears in
the makefile.

  yl> PROJECT_LIST      = proj1 proj2

  yl> include $(PROJECT_LIST:%=%.mk)

  yl> all:      $(PROJECT_LIST)

You include all the sub-makefiles before you define the "all" rule; that
means that the first explicit target found during the read of those
makefiles, if there is one, will be the default target.  There is an
explicit target in each of them, so the one in the first makefile
(proj1.mk) is the default target.

You should _always_ put the target you want to be the default target
early in the makefile, definitely before you include any other rules.
You don't even have to give it prerequisites if you don't know them yet,
just specifying it as a target is sufficient; like this:

  PROJECT_LIST          = proj1 proj2

  .PHONY: all
  all:

  include $(PROJECT_LIST:%=%.mk)

  all: $(PROJECT_LIST)

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