From bc0048e6ef4e19a563d756ecef73a1589f56acd6 Mon Sep 17 00:00:00 2001 From: bdrewery Date: Sun, 5 Nov 2017 00:11:58 +0000 Subject: [PATCH] AUTO_OBJ: Set .OBJDIR=.CURDIR earlier for NO_OBJ Makefiles. auto.obj.mk is loaded before the Makefile which may have NO_OBJ set inside of it. In that case we can't avoid creating the OBJDIR but we do need to avoid using it. Fixing .OBJDIR in bsd.init.mk at least fixes all of the build .mk files to have a proper .OBJDIR. It does not fix the Makefile itself but usually if they have NO_OBJ set they are not inspecting ${.OBJDIR} anyhow. It is ideal to only have this in bsd.init.mk and to remove it from bsd.obj.mk, but then bsd.obj.mk would need to include bsd.init.mk. Doing something like that would require more testing. It has been proposed that bsd.obj.mk not be included directly but it has been possible for too long to do so to change it at this point. Note too that it may make sense to fix .OBJDIR even when AUTO_OBJ is not enabled but the historical behavior has always been that NO_OBJ just avoids running 'make obj', so .OBJDIR should already be .CURDIR. Also while NO_OBJ seems like it should be removed at this point, it is not always possible to fix Makefiles to properly use an .OBJDIR. The cost of keeping NO_OBJ support is minimal. Sponsored by: Dell EMC Isilon --- share/mk/bsd.init.mk | 8 ++++++++ share/mk/bsd.obj.mk | 1 + 2 files changed, 9 insertions(+) diff --git a/share/mk/bsd.init.mk b/share/mk/bsd.init.mk index 407d71c0161e..681a25b5ac97 100644 --- a/share/mk/bsd.init.mk +++ b/share/mk/bsd.init.mk @@ -10,6 +10,14 @@ ____: .include .-include "local.init.mk" + +.if ${MK_AUTO_OBJ} == "yes" +# This is also done in bsd.obj.mk +.if defined(NO_OBJ) +.OBJDIR: ${.CURDIR} +.endif +.endif + .if exists(${.CURDIR}/../Makefile.inc) .include "${.CURDIR}/../Makefile.inc" .endif diff --git a/share/mk/bsd.obj.mk b/share/mk/bsd.obj.mk index 8283f6c809f1..d93e970af8a5 100644 --- a/share/mk/bsd.obj.mk +++ b/share/mk/bsd.obj.mk @@ -47,6 +47,7 @@ ____: objwarn: obj: CANONICALOBJDIR= ${.OBJDIR} +# This is also done in bsd.init.mk .if defined(NO_OBJ) # but this makefile does not want it! .OBJDIR: ${.CURDIR}