从FreeBSD
make
手册页:
.OBJDIR A path to the directory where the targets are built. Its
value is determined by trying to chdir(2) to the follow-
ing directories in order and using the first match:
1. ${MAKEOBJDIRPREFIX}${.CURDIR}
(Only if `MAKEOBJDIRPREFIX' is set in the environ-
ment or on the command line.)
2. ${MAKEOBJDIR}
(Only if `MAKEOBJDIR' is set in the environment or
on the command line.)
3. ${.CURDIR}/obj.${MACHINE}
4. ${.CURDIR}/obj
5. /usr/obj/${.CURDIR}
6. ${.CURDIR}
Variable expansion is performed on the value before it's
used, so expressions such as
${.CURDIR:S,^/usr/src,/var/obj,}
may be used. This is especially useful with
`MAKEOBJDIR'.
`.OBJDIR' may be modified in the makefile via the special
target `.OBJDIR'. In all cases, make will chdir(2) to
the specified directory if it exists, and set `.OBJDIR'
and `PWD' to that directory before executing any targets.
在所有情况下,如果指定目录存在,则将chdir(2)设置为指定目录,并将其设置为
.OBJDIR'
相比之下
GNU make manual page
OBJDIR
解决方案是覆盖
通过伪目标的变量
.OBJDIR
.OBJDIR: ./
all:
cd src && make
clean:
cd src && make clean
另一种解决方案是在
cd
具有的目标
${CURDIR}
,在
chdir
进入
我不明白为什么
gmake
然而,他们的行为方式是一样的。对我来说,这感觉就像一个虫子。