help-make
[Top][All Lists]
Advanced

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

Re: Request for help in setting a variable in GNU Make.


From: Paul D. Smith
Subject: Re: Request for help in setting a variable in GNU Make.
Date: Thu, 6 Apr 2006 08:18:49 -0400

%% Greg Chicares <address@hidden> writes:

  >> $(PROG): $(SRC)
  >>        gcc -c $?
  >>        gcc -o $@ $(^:.c=.o)

  gc> I think that does more work than is needed.
  gc> That would execute

  gc>   gcc -c a.c b.c c.c

Nope.  Check out the definition of the $? automatic variable in the GNU
make manual.

Using the $? variable is definitely what the OP wants.  That's what it's
there for.


Another option (untested) that might be a tiny bit faster (but maybe not
enough to matter):

 $(PROG): $(SRC)
        gcc -o $@ $? $(patsubst %.c,%.o,$(filter-out $?,$^))

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "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]