From 9cf9bf889ad8fc0b8e271048dcc8c343cd15aa36 Mon Sep 17 00:00:00 2001 From: espie Date: Fri, 16 Jun 2017 10:20:52 +0000 Subject: [PATCH] introduce a BUILDFIRST/BUILDAFTER mechanism: record every standard component built in bsd.lib.mk/bsd.prog.mk in BUILDAFTER and have BUILDAFTER depend on BUILDFIRST, thus making possible to build some stuff early without relying on "make depend" okay tb@ millert@ --- share/mk/bsd.dep.mk | 8 +++++++- share/mk/bsd.lib.mk | 8 +++++++- share/mk/bsd.prog.mk | 4 +++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index 3e7fb6cb238..bbbe61b2673 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -1,4 +1,4 @@ -# $OpenBSD: bsd.dep.mk,v 1.14 2017/06/04 12:25:19 espie Exp $ +# $OpenBSD: bsd.dep.mk,v 1.15 2017/06/16 10:20:52 espie Exp $ # $NetBSD: bsd.dep.mk,v 1.12 1995/09/27 01:15:09 christos Exp $ # some of the rules involve .h sources, so remove them from mkdep line @@ -53,4 +53,10 @@ cleandepend: rm -f .depend ${.CURDIR}/tags .endif +BUILDFIRST ?= +BUILDAFTER ?= +.if !empty(BUILDFIRST) && !empty(BUILDAFTER) +${BUILDAFTER}: ${BUILDFIRST} +.endif + .PHONY: beforedepend depend afterdepend cleandepend realdepend diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index c4c58566732..cf7cbeed237 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -1,4 +1,4 @@ -# $OpenBSD: bsd.lib.mk,v 1.83 2017/06/07 16:01:07 robert Exp $ +# $OpenBSD: bsd.lib.mk,v 1.84 2017/06/16 10:20:52 espie Exp $ # $NetBSD: bsd.lib.mk,v 1.67 1996/01/17 20:39:26 mycroft Exp $ # @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 @@ -164,7 +164,10 @@ LDADD+= -Wl,--version-script=${VERSION_SCRIPT} all: ${_LIBS} _SUBDIRUSE +BUILDAFTER += ${_LIBS} + OBJS+= ${SRCS:N*.h:R:S/$/.o/} +BUILDAFTER += ${OBJS} lib${LIB}.a: ${OBJS} @echo building standard ${LIB} library @@ -173,6 +176,7 @@ lib${LIB}.a: ${OBJS} ${RANLIB} lib${LIB}.a POBJS+= ${OBJS:.o=.po} +BUILDAFTER += ${POBJS} lib${LIB}_p.a: ${POBJS} @echo building profiled ${LIB} library @rm -f lib${LIB}_p.a @@ -180,6 +184,7 @@ lib${LIB}_p.a: ${POBJS} ${RANLIB} lib${LIB}_p.a SOBJS+= ${OBJS:.o=.so} +BUILDAFTER += ${SOBJS} ${FULLSHLIBNAME}: ${SOBJS} ${DPADD} @echo building shared ${LIB} library \(version ${SHLIB_MAJOR}.${SHLIB_MINOR}\) @rm -f ${.TARGET} @@ -200,6 +205,7 @@ ${FULLSHLIBNAME}.a: ${SOBJS} # all .do files... DOBJS+= ${OBJS:.o=.do} +BUILDAFTER += ${DOBJS} # .do files that we actually need for where this dist lib will be used .if defined(DIST_OBJS) diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index 5feb0456874..49f3c5b16e6 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -1,4 +1,4 @@ -# $OpenBSD: bsd.prog.mk,v 1.70 2015/11/14 23:56:50 deraadt Exp $ +# $OpenBSD: bsd.prog.mk,v 1.71 2017/06/16 10:20:52 espie Exp $ # $NetBSD: bsd.prog.mk,v 1.55 1996/04/08 21:19:26 jtc Exp $ # @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 @@ -95,6 +95,8 @@ MAN= ${PROG}.1 .MAIN: all all: ${PROG} _SUBDIRUSE +BUILDAFTER += ${PROG} ${OBJS} + .if !target(clean) clean: _SUBDIRUSE rm -f a.out [Ee]rrs mklog *.core y.tab.h \ -- 2.20.1