help-make
[Top][All Lists]
Advanced

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

.SECONDEXPAND and spaces?


From: Leeuwesteijn,Joost
Subject: .SECONDEXPAND and spaces?
Date: Wed, 3 May 2006 12:36:09 +0200


When I try to do secondary expansion, it seems to work. Adding a simple
string to the target name:
    $(MOD1.OBJECTS) : address@hidden
gives a make -p output of:
    OUTPUT/MOD1/mod1file2.o: OUTPUT/MOD1/mod1file2.o-fubar
Which is OK.


When I try to mangle the prerequisite a bit more (just a test) it doesn't
seem to work:
    $(MOD1.OBJECTS) : $(MOD1.SOURCEDIR)/$$(notdir $$@)
gives a make -p output of:
    OUTPUT/MOD1/mod1file1.o: MOD1/$(notdir) MOD1/$($@)
Which is not what I expected.


The example from the manual (slightly modified):
    $(MOD1.OBJECTS) : $$(patsubst %.o,%.c,$$@)
Results in a make -p of:
    OUTPUT/MOD1/mod1file1.o: $(patsubst) $(%.o,%.c,OUTPUT/MOD1/mod1file1.o)


The next line:
    $(MOD1.OBJECTS) : $(MOD1.OBJECTS) : $$(@:.o=.c)
Even results in a:
    *** target pattern contains no `%'.  Stop.

Am I missing something? Do the spaces mess things up? But the manual uses
patsubst though...

--
Joost Leeuwesteijn

##########################################
#
# Test makefile
#
##########################################

MOD1.SOURCEDIR:=./MOD1
MOD1.OUTPUTDIR:=./OUTPUT/MOD1

# force immediate expansion of += lines
MOD1.OBJECTS :=
MOD1.OBJECTS += $(MOD1.OUTPUTDIR)/mod1file1.o
MOD1.OBJECTS += $(MOD1.OUTPUTDIR)/mod1file2.o

# ----------------------------------------

$(MOD1.OUTPUTDIR)/module1.a : $(MOD1.OBJECTS)

.SECONDEXPANSION :
$(MOD1.OBJECTS) : $(MOD1.SOURCEDIR)/$$(notdir $$@)
#$(MOD1.OBJECTS) : address@hidden
#$(MOD1.OBJECTS) : $$(@:.o=.c)
#$(MOD1.OBJECTS) : $$(patsubst %.o,%.c,$$@)

# ----------------------------------------

%.a :
        @echo "Linking $@"
        @echo "     $?"
        @touch $@

%.o : %.c
        @echo "Compiling $@"
        @touch $@




reply via email to

[Prev in Thread] Current Thread [Next in Thread]