From 54f191bfce6a040732e8047153e2b5c35278f965 Mon Sep 17 00:00:00 2001 From: joerg Date: Thu, 15 Nov 2012 23:51:53 +0000 Subject: [PATCH] Move the build_install logic from lib/Makefile into share/mk and re-use it for tools. The existing logic broke for the LLVM build with the recent .ORDER changes in make. --- Makefile | 12 ++----- build.sh | 7 ++-- lib/Makefile | 29 ++-------------- share/mk/Makefile | 6 ++-- share/mk/bsd.buildinstall.mk | 29 ++++++++++++++++ tools/Makefile | 65 ++++-------------------------------- 6 files changed, 47 insertions(+), 101 deletions(-) create mode 100644 share/mk/bsd.buildinstall.mk diff --git a/Makefile b/Makefile index f4d8983df38f..4ecff4ea5a04 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.300 2012/11/04 11:02:11 apb Exp $ +# $NetBSD: Makefile,v 1.301 2012/11/15 23:51:53 joerg Exp $ # # This is the top-level makefile for building NetBSD. For an outline of @@ -92,8 +92,6 @@ # obj: creates object directories. # do-distrib-dirs: creates the distribution directories. # includes: installs include files. -# do-tools-compat: builds the "libnbcompat" library; needed for some -# random host tool programs in the source tree. # do-lib: builds and installs prerequisites from lib # if ${MKCOMPAT} != "no". # do-compat-lib: builds and installs prerequisites from compat/lib @@ -455,12 +453,8 @@ do-${targ}: .PHONY ${targ} @true .endfor -.for dir in tools tools/compat -do-${dir:S/\//-/g}: .PHONY .MAKE -.for targ in dependall install - ${MAKEDIRTARGET} ${dir} ${targ} -.endfor -.endfor +do-tools: .PHONY .MAKE + ${MAKEDIRTARGET} tools build_install do-lib: .PHONY .MAKE ${MAKEDIRTARGET} lib build_install diff --git a/build.sh b/build.sh index 19700f5a3b78..43ce1706212a 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #! /usr/bin/env sh -# $NetBSD: build.sh,v 1.258 2012/10/31 13:05:09 apb Exp $ +# $NetBSD: build.sh,v 1.259 2012/11/15 23:51:53 joerg Exp $ # # Copyright (c) 2001-2011 The NetBSD Foundation, Inc. # All rights reserved. @@ -1718,7 +1718,7 @@ createmakewrapper() eval cat < @@ -229,30 +229,5 @@ SUBDIR+= ../sys/rump/net/lib # Lua bindings come last, they might depend on anything SUBDIR+= lua -# -# build_install logic for src/Makefile. -# Compute a list of subdirectories delimited by .WAIT. -# Run "make dependall && make install" for all subdirectories in a group -# concurrently, but wait after each group. -# -SUBDIR_GROUPS= 1 -CUR_GROUP:= 1 -.for dir in ${SUBDIR} -. if ${dir} == ".WAIT" -CUR_GROUP:= ${CUR_GROUP}1 -SUBDIR_GROUPS:= ${SUBDIR_GROUPS} ${CUR_GROUP} -. else -SUBDIR_GROUP.${CUR_GROUP}+= ${dir} -.endif - -.endfor - -build_install: -.for group in ${SUBDIR_GROUPS} -. if !empty(SUBDIR_GROUP.${group}) - ${MAKEDIRTARGET} . ${SUBDIR_GROUP.${group}:C/^/dependall-/} - ${MAKEDIRTARGET} . ${SUBDIR_GROUP.${group}:C/^/install-/} -. endif -.endfor - +.include .include diff --git a/share/mk/Makefile b/share/mk/Makefile index ef4f73bf635b..2ff17275c602 100644 --- a/share/mk/Makefile +++ b/share/mk/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.46 2011/10/07 16:29:40 plunky Exp $ +# $NetBSD: Makefile,v 1.47 2012/11/15 23:51:53 joerg Exp $ # @(#)Makefile 8.1 (Berkeley) 6/8/93 NOOBJ= # defined @@ -6,8 +6,8 @@ NOOBJ= # defined .include .if ${MKSHARE} != "no" -FILES= bsd.README bsd.clang-analyze.mk bsd.clean.mk bsd.dep.mk bsd.doc.mk \ - bsd.endian.mk bsd.files.mk \ +FILES= bsd.README bsd.buildinstall.mk bsd.clang-analyze.mk bsd.clean.mk \ + bsd.dep.mk bsd.doc.mk bsd.endian.mk bsd.files.mk \ bsd.gcc.mk bsd.hostlib.mk bsd.hostprog.mk bsd.inc.mk bsd.info.mk \ bsd.init.mk bsd.ioconf.mk bsd.kernobj.mk bsd.kinc.mk bsd.klinks.mk \ bsd.kmodule.mk bsd.lib.mk bsd.links.mk bsd.lua.mk \ diff --git a/share/mk/bsd.buildinstall.mk b/share/mk/bsd.buildinstall.mk new file mode 100644 index 000000000000..87c65b3660cb --- /dev/null +++ b/share/mk/bsd.buildinstall.mk @@ -0,0 +1,29 @@ +# $NetBSD: bsd.buildinstall.mk,v 1.1 2012/11/15 23:51:53 joerg Exp $ + +# +# build_install logic for src/Makefile +# Used by src/lib/Makefile and src/tools/Makefile. +# +# Compute a list of subdirectories delimited by .WAIT. +# Run "make dependall && make install" for all subdirectories in a group +# concurrently, but wait after each group. +# +SUBDIR_GROUPS= 1 +CUR_GROUP:= 1 +.for dir in ${SUBDIR} +. if ${dir} == ".WAIT" +CUR_GROUP:= ${CUR_GROUP}1 +SUBDIR_GROUPS:= ${SUBDIR_GROUPS} ${CUR_GROUP} +. else +SUBDIR_GROUP.${CUR_GROUP}+= ${dir} +.endif + +.endfor + +build_install: +.for group in ${SUBDIR_GROUPS} +. if !empty(SUBDIR_GROUP.${group}) + ${MAKEDIRTARGET} . ${SUBDIR_GROUP.${group}:C/^/dependall-/} + ${MAKEDIRTARGET} . ${SUBDIR_GROUP.${group}:C/^/install-/} +. endif +.endfor diff --git a/tools/Makefile b/tools/Makefile index 3c203a98f689..97aa5b1adfc5 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,7 +1,11 @@ -# $NetBSD: Makefile,v 1.158 2012/11/15 19:49:12 jkunz Exp $ +# $NetBSD: Makefile,v 1.159 2012/11/15 23:51:54 joerg Exp $ .include +# Make sure that the ordered build/install processing applies when using +# plain make. +.MAIN: build_install + .if defined(HAVE_GCC) || defined(HAVE_PCC) TOOLCHAIN_BITS= gmake .WAIT .endif @@ -80,12 +84,10 @@ SUBDIR= host-mkdep .WAIT compat .WAIT \ pwd_mkdb stat strfile sunlabel zic .if ${MKLLVM} != "no" -# .WAIT between llvm-tblgen and llvm-clang-tblgen ensures install -# rules works correctly SUBDIR+= \ llvm .WAIT \ llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \ - llvm-tblgen .WAIT llvm-clang-tblgen .WAIT \ + llvm-tblgen llvm-clang-tblgen .WAIT \ llvm-include .WAIT \ llvm-lib .WAIT \ llvm-clang @@ -179,6 +181,7 @@ all-${dir} depend-${dir} dependall-${dir} install-${dir}: .endif # } .include +.include .include .if !defined(PREVIOUSTOOLDIR) @@ -202,59 +205,5 @@ realall realdepend: .MAKE .endif echo ${TOOLDIR} >PREVIOUSTOOLDIR -# For each .WAIT point, make sure the immediately preceding target is -# installed before building anything after that point. -# (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the -# install of 'b', but not the install of 'a'.) -# -# We use the "internal" targets and dependencies generated by -# to achieve this. These targets look like: -# subdir-all: all-dir1 [.WAIT] all-dir2 etc.. -# subdir-install: install-dir1 [.WAIT] install-dir2 etc.. -# and so on for each element in ${TARGETS}, with .WAIT sources inserted at -# places corresponding to the .WAITs in our $SUBDIR variable. -# -# Also, since we're now mixing `install' with `all' and `depend' targets -# an order relationship between those in each individual subdirectory -# must be established. -# -_deps:= -_prev:= - -.for d in ${SUBDIR} # { -_this:= ${d} - -.if ${_this} == ".WAIT" # { - -# setup dependency to apply to all/depend targets in the next group -_deps:= ${_deps} ${_prev:S/^/install-/} - -# if we're building *only* individual targets (i.e. "dependall-yacc"), -# make sure prerequisite tools build before installing -# XXX: dsl: this is likely to generate a dependency loop since there is -# a .ORDER releation between the nodes as well. -.if !make(all) && !make(dependall) && !make(install) -install-${_prev}: dependall-${_prev} -.endif - -.else # ${_this} != ".WAIT" # } { - -# order depend/all/install targets for ${d} subdir. -.ORDER: depend-${d} all-${d} dependall-${d} install-${d} - -# prevent cleandir in real{all,depend} from interfering with subdir makes -.ORDER: realdepend dependall-${d} -.ORDER: realdepend depend-${d} -.ORDER: realall all-${d} - -# make all/depend-${d} dependent on list of install targets -depend-${d} all-${d} dependall-${d}: ${_deps} - -.endif # ${_this} != ".WAIT" # } - -# stash current name in case the next entry is .WAIT -_prev:= ${d} -.endfor # } - cleandir: rm -f ${CLEANFILES}