[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: .SECONDEXPAND and spaces?
From: |
Leeuwesteijn,Joost |
Subject: |
RE: .SECONDEXPAND and spaces? |
Date: |
Wed, 3 May 2006 13:27:47 +0200 |
Sorry about the messed up newlines. Quick fix to improve readability below.
Is there a big performance penalty when putting .SECONDEXPANSION at the top
of my (toplevel) makefile? Probably not in my small project, but in general.
Could it be a problem in large project? I suppose not because the files will
be loaded to memory only once; it's all done in memory which shouldn't
really make a big difference.
Could .SECONDEXPANSION have any other unwanted side-effects I should worry
about?
> -----Original Message-----
>
> 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 $@