d******e 发帖数: 143 | 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 $@
# compile cpp and put objs in OBJDIR
%.o : %.cpp
g++ -c $^ -o $(OBJDIR)/$@
################
problem:
first time run: make test, all 3 object files are created and save |
t****t 发帖数: 6806 | 2 我觉得尽量避免vpath比较好...
【在 d******e 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 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
|
d******e 发帖数: 143 | 3 then how will you do it?
files.
is
【在 t****t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 我觉得尽量避免vpath比较好...
|
t****t 发帖数: 6806 | 4 多个目录的话, 要不就把路径都列全了, 要不就搞好几个makefile(那样跨目录时也要
把路径列全了)
【在 d******e 的大作中提到】![](/moin_static193/solenoid/img/up.png) : then how will you do it? : : files. : is
|