help-make
[Top][All Lists]
Advanced

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

Re: a strange make rule


From: Lin George
Subject: Re: a strange make rule
Date: Sun, 27 Aug 2006 05:11:26 -0700 (PDT)

Thank you Greg,


I have tried it. Here is the output.

TARGET_DIR is /bar
SRC        is foo.c
PROC       is foo.o
TARGET     is /bar/foo.o

I think to understand the whole long makefile, I
should replace TARGET with /bar/foo.o, right?


regards,
George

--- Greg Chicares <address@hidden> wrote:

> On 2006-8-27 9:55 UTC, Lin George wrote:
> > Here is a sample make file.
> > 
> > SRC=foo.c
> > PROC=$(SRC:%.c=%.o)
> > TARGET=$(PROC:%.o=$(TARGET_DIR)/%.o)
> > 
> > I know the first two lines mean compile *.c
> defined in
> > SRC to *.o. But what does the 3rd line mean?
> Convert
> > *.o generated by PROC rule still to *.o? I am
> confused
> > that why convert *.o to *.o itself?
> 
> All three lines simply set variables.
> 
> To see exactly what each line does, add a target
> that
> displays each variable:
> 
> # 'sample.make' begins
> SRC=foo.c
> PROC=$(SRC:%.c=%.o)
> TARGET=$(PROC:%.o=$(TARGET_DIR)/%.o)
> 
> .PHONY: show_variables
> show_variables:
>       @echo 'TARGET_DIR is $(TARGET_DIR)'
>       @echo 'SRC        is $(SRC)'
>       @echo 'PROC       is $(PROC)'
>       @echo 'TARGET     is $(TARGET)'
> # 'sample.make' ends
> 
> Then run it this way:
>   make --file=sample.make
> and also this way:
>   make --file=sample.make TARGET_DIR=/bar
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




reply via email to

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