help-make
[Top][All Lists]
Advanced

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

Re: some questin about Makefile


From: loody
Subject: Re: some questin about Makefile
Date: Thu, 17 Sep 2009 11:13:50 +0800

Hi:
thanks for your kind help :)
2009/9/16 Paul Smith <address@hidden>:
> On Wed, 2009-09-16 at 21:46 +0800, loody wrote:
>
>> SRCDIR    = $(ROOT) ./device/display ./device/fatfs ./device/misc
>> VPATH = ${SRCDIR}
>
>> OBJ_C = cpufunc.o Interrupt.o main.o memtst.o ntsys.o Display.o
>> diskio.o FileSystem.o tff.o misc.o
>> OBJ = cpufunc.o Interrupt.o main.o memtst.o ntsys.o Display.o diskio.o
>> FileSystem.o tff.o misc.o
>>
>> .PHONY : all clear depend
>> all: $(OBJ)
>> $(OBJ_C) : %.o : %.c
>
>> my question are:
>> 1. what does the pattern rule of "OBJ_C : %.o : %.c" mean?
>
> Look up static pattern rules in the GNU make manual.
>
>> 2. I purposely assign the member of OBJ_C without directories, but why
>> the output of $< still has directories?
>
> Look up VPATH in the GNU make manual.
>
>> 3. the prerequisite of all is $(OBJ), but why make find $(OBJ_C) as
>> the prerequisite for execution?
>
> See question #1 above: these two questions have the same answer.
>
> Let us know if you read these and don't understand what's going on...
>
case a:
I purposely let the content of OBJ and OBJ_C are different as below:
OBJ_C = cpufunc.o
OBJ = misc.o
and the output is :
mipsel-unknown-linux-uclibc-gcc -g -G0 -mips32r2
-fno-omit-frame-pointer -fno-optimize-sibling-calls
-I/root/x-tools/mipsel-unknown-linux-uclibc/mipsel-unknown-linux-uclibc/sys-root/usr/include
-I./include -I./device/display -I./device/fatfs -I./device/misc
-I./device/ntstrg -I./device/ntuart -I./device/ntxsub -I./device/VPU
-c ./device/misc/misc.c

case b:
I purposely let the content of OBJ and OBJ_C are different as below:
OBJ_C = cpufunc.o misc.o
OBJ = misc.o
and the output is :
OBJ_C=cpufunc.o misc.o
preauire = ./device/misc/misc.c
target = misc.o
mipsel-unknown-linux-uclibc-gcc -g -G0 -mips32r2
-fno-omit-frame-pointer -fno-optimize-sibling-calls
-I/root/x-tools/mipsel-unknown-linux-uclibc/mipsel-unknown-linux-uclibc/sys-root/usr/include
-I./include -I./device/display -I./device/fatfs -I./device/misc
-I./device/ntstrg -I./device/ntuart -I./device/ntxsub -I./device/VPU
-c ./device/misc/misc.c

can I get the conclusion as below?
1. $(OBJ_C) : %.o : %.c will expend each member of $(OBJ_C) with the
following commands.
ex:
if OBJ_C = cpufunc.o misc.o
it will extend as

cpufunc.o : VPATH/cpufunc.c
        @echo OBJ_C=$(OBJ_C)
        @echo preauire = $<
        @echo target = $@
        $(CC) $(CFLAGS1) -c $<

misc.o : VPATH\misc.c
        @echo OBJ_C=$(OBJ_C)
        @echo preauire = $<
        @echo target = $@
        $(CC) $(CFLAGS1) -c $<

1. in case a, since "all" depends on "OBJ" and "OBJ" find no match of
the rule expand with "OBJ_C" so it use implicit rule as 10.2 Catalogue
of Implicit Rules, ‘$(CC) -c
$(CPPFLAGS) $(CFLAGS), to create *.o file.

2. in case b, the content of "OBJ" is matching the rule expanded by
"OBJ_C" so it runs
misc.o : VPATH\misc.c
        @echo OBJ_C=$(OBJ_C)
        @echo preauire = $<
        @echo target = $@
        $(CC) $(CFLAGS1) -c $<

does my assumption correct?
appreciate your kind help :)
miloody




reply via email to

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