avatar
d*e
1
it's GNU make3.8
if there're 3 source files in 3 sub dir:(current dir is /proj)
/proj/A/a.c
/proj/B/b.c
/proj/C/c.c
/proj/obj
makefile in /proj:
################
DIR1 = ./A
DIR2 = ./B
DIR3 = ./C
OBJDIR = ./obj
VPATH=.:$(DIR1):$(DIR2):$(DIR3):$(OBJDIR)
#default target, link all objs to exe
test: a.o b.o c.o
g++ $^ -o [email protected]
# compile cpp and put objs in OBJDIR
%.o : %.cpp
g++ -c $^ -o $(OBJDIR)/[email protected]
################
problem:
first time run: make test, all 3 object files are created and save
avatar
t*t
2
我觉得尽量避免vpath比较好...

【在 d******e 的大作中提到】
: it's GNU make3.8
: if there're 3 source files in 3 sub dir:(current dir is /proj)
: /proj/A/a.c
: /proj/B/b.c
: /proj/C/c.c
: /proj/obj
: makefile in /proj:
: ################
: DIR1 = ./A
: DIR2 = ./B

avatar
d*e
3
then how will you do it?

files.
is

【在 t****t 的大作中提到】
: 我觉得尽量避免vpath比较好...
avatar
t*t
4
多个目录的话, 要不就把路径都列全了, 要不就搞好几个makefile(那样跨目录时也要
把路径列全了)

【在 d******e 的大作中提到】
: then how will you do it?
:
: files.
: is

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。