|
|
|
|
| 请问Makefile的隐含规则在"cd subdir && make"能用吗? |
 请问Makefile的隐含规则在"cd subdir && make"能用吗? - dswei [ 2005-06-19 17:16 | 270 byte(s)]
 Re: 请问Makefile的隐含规则在"cd subdir && make"能用吗? - dswei [ 2005-06-20 15:24 | 306 byte(s)]
|
|
|
|
[Original]
[Print]
[Top]
|
我在顶层目录建了一个Makefile,比如:
%.o:%.c
gcc -c -o $@ $<
all:
cd subdir && make
请问如何处理才能让这个隐含规则也能在subdir中的Makefile上使用?
|
|
|
[Original]
[Print]
[Top]
|
|
[Original]
[Print]
[Top]
|
问题解决:
1、将下面2行放在一个顶层目录Rules.make文件中:
%.o:%.c
gcc -c -o $@ $<
2、顶层目录的Makefile:
CURDIR := $(shell pwd)
export CURDIR
3、在subdir下的Makefile中增加一行
include $(CURDIR)/Rules.make
|
|
|
[Original]
[Print]
[Top]
|
|
|