操作系统:FreeBSD 11.0-RELEASE
我有以下目录结构:
/xxx/obj/
/xxx/src/deep.cpp
/xxx/flat.cpp
/xxx/makefile
makefile的内容如下:
flat.out: flat.o
deep.out: src/deep.o
我建公寓没问题:
/xxx $ make flat.out
c++ -O2 -pipe -c /xxx/flat.cpp -o flat.o
cc -O2 -pipe flat.o -o flat.out
/xxx $ ls obj
flat.o flat.out
但是,当我尝试深入构建时,它失败了:
/xxx $ make deep.out
c++ -O2 -pipe -c /xxx/src/deep.cpp -o src/deep.o
error: unable to open output file 'src/deep.o': 'No such file or directory'
1 error generated.
*** Error code 1
Stop.
make: stopped in /xxx
如果我然后/xxx/obj/src
手动创建它会成功:
/xxx $ mkdir obj/src
/xxx $ make deep.out
c++ -O2 -pipe -c /xxx/src/deep.cpp -o src/deep.o
cc -O2 -pipe src/deep.o -o deep.out
/xxx $ ls obj
deep.out flat.o flat.out src
/xxx $ ls obj/src
deep.o
根据这个来源, bmake(又名 bsdmake?)支持自动创建源外 OBJDIR,但我不知道具体如何。
在一般情况下,如何配置 bmake 以自动创建相关目录?