[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: a strange make rule
From: |
Greg Chicares |
Subject: |
Re: a strange make rule |
Date: |
Sun, 27 Aug 2006 11:54:51 +0000 |
User-agent: |
Thunderbird 1.5.0.4 (Windows/20060516) |
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