Paul Smith schrieb am 14.01.2012 um 09:09 (-0500):
> On Sat, 2012-01-14 at 13:46 +0100, Michael Ludwig wrote:

> > # Pattern Rule
> > %.o: %.cpp
> >     $(COMPILE.cc) $*.cpp -o $*.o
> 
> This is not right.  The $* variable matches the stem of the pattern.

Ah ... silly me. Relevant manual page:

http://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html

> The stem of the pattern here is something like "Employee", the stem is
> NOT "emp/Employee".  You can see this easily be changing your rule to
> print out the values of the various automatic variables.

Now that's useful! Will keep this snippet handy from now on:

        @echo ==   $$@ $@
        @echo ==   $$%% $%
        @echo ==   $$^< $<
        @echo ==   $$? $?
        @echo ==   $$^^ $^
        @echo ==   $$+ $+
        @echo ==   $$^| $|
        @echo ==   $$* $*

Can I define it as a function? To invoke it like: $(echoautovars)

> If you want this to work you need to use the $@ and $< variables, like
> so:
> 
>         %.o: %.cpp
>                 $(COMPILE.cc) $< -o $@

That works perfectly.

> Hope this helps...

It definitely does! Thanks a bunch.
-- 
Michael Ludwig

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to