[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Odd make question
From: |
Paul D. Smith |
Subject: |
Re: Odd make question |
Date: |
Tue, 9 Jan 2001 21:08:21 -0500 |
%% "Marcus A Martin" <address@hidden> writes:
mam> What I need to do is be able to pass only the source files that
mam> have been changed into the compile command. So far I have only
mam> found a way to add in all or none. The gmake structure is basicly
mam> this this:
mam> SOURCE = foo.c bar.c
mam> $(OBJS): $(SOURCES)
mam> $(CC) $^
First, this isn't what you want. Multiple targets on the left side of
the ":" mean that each one can be built with the same rule. So, the
above line (assuming OBJS is "foo.o bar.o") is the same as writing:
foo.o: foo.c bar.c
$(CC) $^
bar.o: foo.c bar.c
$(CC) $^
which is clearly _not_ what you want. This will be even slower, since
it will recompile every .o whenever _any_ .c changes.
mam> In theory, the $^ should only get source files that have been
mam> changed since the last compile, but it always evaluates to
mam> null.
I don't see how that can be.
The "$^" does _NOT_ evaluate to the files that have changed, it
evaluates to _all_ the prerequisites defined for that target. It should
always be equal to the value of $(SOURCES). Note this assumes you're
using GNU make; some other makes don't define the automatic variables
like $<, etc. for explicit rules (for some completely incomprehensible
reason).
The variable you want is "$?", which resolves to just the files that
have changed.
See the GNU make manual section on automatic variables.
To do what you want you'll have to use a dummy file. Something like
this might work:
dummy.x: $(SOURCES)
$(CC) -c $?
touch dummy.x
foobar.a: dummy.x
$(SHARED_LIB_LINKER) $(OBJS) $(OUTFILE)
Obviously this is using UNIX syntax; I'm not familiar enough with
Windows to translate stuff like "touch".
--
-------------------------------------------------------------------------------
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
- Odd make question, Marcus A Martin, 2001/01/09
- Re: Odd make question,
Paul D. Smith <=