Index: share/mk/Makefile =================================================================== --- share/mk/Makefile +++ share/mk/Makefile @@ -1,9 +1,10 @@ -# $FreeBSD: head/share/mk/Makefile 276846 2015-01-08 18:28:06Z imp $ +# $FreeBSD: projects/bmake/share/mk/Makefile 283591 2015-05-26 21:52:57Z sjg $ # @(#)Makefile 8.1 (Berkeley) 6/8/93 .include FILES= \ + auto.obj.mk \ bsd.README \ bsd.arch.inc.mk \ bsd.compiler.mk \ @@ -39,6 +40,12 @@ bsd.symver.mk \ bsd.sys.mk \ bsd.test.mk \ + dirdeps.mk \ + gendirdeps.mk \ + meta.autodep.mk \ + meta.stage.mk \ + meta.subdir.mk \ + meta.sys.mk \ sys.mk \ version_gen.awk Index: share/mk/bsd.compiler.mk =================================================================== --- share/mk/bsd.compiler.mk +++ share/mk/bsd.compiler.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.compiler.mk 275589 2014-12-08 03:32:26Z ngie $ +# $FreeBSD: projects/bmake/share/mk/bsd.compiler.mk 283591 2015-05-26 21:52:57Z sjg $ # Setup variables for the compiler # @@ -25,8 +25,12 @@ .if !target(____) ____: -.if !defined(COMPILER_TYPE) || !defined(COMPILER_VERSION) +.if ${MACHINE} == "common" +COMPILER_TYPE= none +COMPILER_VERSION= 0 +.elif !defined(COMPILER_TYPE) || !defined(COMPILER_VERSION) _v!= ${CC} --version 2>/dev/null || echo 0.0.0 + .if !defined(COMPILER_TYPE) . if ${CC:T:M*gcc*} COMPILER_TYPE:= gcc Index: share/mk/bsd.crunchgen.mk =================================================================== --- share/mk/bsd.crunchgen.mk +++ share/mk/bsd.crunchgen.mk @@ -25,7 +25,7 @@ # If CRUNCH_GENERATE_LINKS is set to no, no links will be generated. # -# $FreeBSD: head/share/mk/bsd.crunchgen.mk 264927 2014-04-25 19:25:18Z imp $ +# $FreeBSD: projects/bmake/share/mk/bsd.crunchgen.mk 270164 2014-08-19 06:50:54Z sjg $ ################################################################## # The following is pretty nearly a generic crunchgen-handling makefile @@ -106,11 +106,12 @@ .endfor .endfor +CRUNCHGEN?= crunchgen # XXX Make sure we don't pass -P to crunchgen(1). .MAKEFLAGS:= ${.MAKEFLAGS:N-P} .ORDER: $(OUTPUTS) objs -$(OUTPUTS): $(CONF) - MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} crunchgen -fq -m $(OUTMK) \ +$(OUTPUTS): $(CONF) .META + MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${CRUNCHGEN} -fq -m $(OUTMK) \ -c $(OUTC) $(CONF) $(PROG): $(OUTPUTS) objs Index: share/mk/bsd.dep.mk =================================================================== --- share/mk/bsd.dep.mk +++ share/mk/bsd.dep.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.dep.mk 281258 2015-04-08 02:43:05Z markj $ +# $FreeBSD: projects/bmake/share/mk/bsd.dep.mk 283591 2015-05-26 21:52:57Z sjg $ # # The include file handles Makefile dependencies. # @@ -147,6 +147,17 @@ beforebuild: ${DHDRS} .endif +.if defined(.PARSEDIR) +.if ${MK_META_MODE} == "yes" +.include +# this depend: bypasses that below +# the dependency helps when bootstrapping +depend: beforedepend ${DPSRCS} ${SRCS} afterdepend +beforedepend: +afterdepend: beforedepend +.endif +.endif + .if !target(depend) .if defined(SRCS) depend: beforedepend ${DEPENDFILE} afterdepend Index: share/mk/bsd.files.mk =================================================================== --- share/mk/bsd.files.mk +++ share/mk/bsd.files.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.files.mk 267276 2014-06-09 14:36:49Z jmmv $ +# $FreeBSD: projects/bmake/share/mk/bsd.files.mk 270164 2014-08-19 06:50:54Z sjg $ .if !target(____) .error bsd.files.mk cannot be included directly. @@ -23,6 +23,11 @@ ${group}GRP?= ${SHAREGRP} ${group}MODE?= ${SHAREMODE} ${group}DIR?= ${BINDIR} +.if !make(buildincludes) +STAGE_SETS+= ${group} +.endif +STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR} +STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP} _${group}FILES= .for file in ${${group}} @@ -38,6 +43,12 @@ .else ${group}NAME_${file:T}?= ${file:T} .endif +.if !make(buildincludes) +STAGE_AS_SETS+= ${group} +.endif +STAGE_AS_${file:T}= ${${group}NAME_${file:T}} +stage_as.${group}: ${file} + installfiles-${group}: _${group}INS_${file:T} _${group}INS_${file:T}: ${file} ${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \ @@ -49,6 +60,8 @@ .endif .endfor .if !empty(_${group}FILES) +stage_files.${group}: ${_${group}FILES} + installfiles-${group}: _${group}INS _${group}INS: ${_${group}FILES} .if defined(${group}NAME) @@ -67,4 +80,13 @@ realinstall: installfiles .ORDER: beforeinstall installfiles +.if ${MK_STAGING} != "no" +.if !empty(STAGE_SETS) +buildfiles: stage_files +.if !empty(STAGE_AS_SETS) +buildfiles: stage_as +.endif +.endif +.endif + .endif # !target(____) Index: share/mk/bsd.incs.mk =================================================================== --- share/mk/bsd.incs.mk +++ share/mk/bsd.incs.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.incs.mk 282420 2015-05-04 16:28:54Z bapt $ +# $FreeBSD: projects/bmake/share/mk/bsd.incs.mk 283591 2015-05-26 21:52:57Z sjg $ .if !target(____) .error bsd.incs.mk cannot be included directly. @@ -24,12 +24,15 @@ ${group}GRP?= ${BINGRP} ${group}MODE?= ${NOBINMODE} ${group}DIR?= ${INCLUDEDIR}${PRIVATELIB:D/private/${LIB}} +STAGE_SETS+= ${group} +STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR} +STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP} _${group}INCS= .for header in ${${group}} .if defined(${group}OWN_${header:T}) || defined(${group}GRP_${header:T}) || \ defined(${group}MODE_${header:T}) || defined(${group}DIR_${header:T}) || \ - defined(${group}NAME_${header:T}) + defined(${group}NAME_${header:T}) || defined(${group}NAME) ${group}OWN_${header:T}?= ${${group}OWN} ${group}GRP_${header:T}?= ${${group}GRP} ${group}MODE_${header:T}?= ${${group}MODE} @@ -39,6 +42,11 @@ .else ${group}NAME_${header:T}?= ${header:T} .endif +STAGE_AS_SETS+= ${group} +STAGE_AS_${header:T}= ${${group}NAME_${header:T}} +stage_as.${group}: ${header} +stage_includes: stage_as.${group} + installincludes: _${group}INS_${header:T} _${group}INS_${header:T}: ${header} ${INSTALL} -C -o ${${group}OWN_${.ALLSRC:T}} \ @@ -50,6 +58,9 @@ .endif .endfor .if !empty(_${group}INCS) +stage_files.${group}: ${_${group}INCS} +stage_includes: stage_files.${group} + installincludes: _${group}INS _${group}INS: ${_${group}INCS} .if defined(${group}NAME) @@ -81,4 +92,14 @@ realinstall: installincludes .ORDER: beforeinstall installincludes +.if ${MK_STAGING} != "no" && !defined(_SKIP_BUILD) +.if !defined(NO_STAGE_INCLUDES) +staging: stage_includes +.if !empty(INCSLINKS) +staging: stage_symlinks +STAGE_SYMLINKS.INCS= ${INCSLINKS} +.endif +.endif +.endif + .endif # ${MK_TOOLCHAIN} != "no" Index: share/mk/bsd.init.mk =================================================================== --- share/mk/bsd.init.mk +++ share/mk/bsd.init.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.init.mk 264862 2014-04-24 02:02:51Z imp $ +# $FreeBSD: projects/bmake/share/mk/bsd.init.mk 266232 2014-05-16 14:56:06Z sjg $ # The include file includes , # ../Makefile.inc and ; this is used at the @@ -9,9 +9,18 @@ .if !target(____) ____: .include +.sinclude "local.init.mk" .if exists(${.CURDIR}/../Makefile.inc) .include "${.CURDIR}/../Makefile.inc" .endif .include .MAIN: all + +.if defined(.PARSEDIR) +.if ${.MAKE.LEVEL:U1} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no" && !make(clean*) +# this tells lib.mk and prog.mk to not actually build anything +_SKIP_BUILD = not building at level 0 +.endif +.endif + .endif # !target(____) Index: share/mk/bsd.lib.mk =================================================================== --- share/mk/bsd.lib.mk +++ share/mk/bsd.lib.mk @@ -1,5 +1,5 @@ # from: @(#)bsd.lib.mk 5.26 (Berkeley) 5/2/91 -# $FreeBSD: head/share/mk/bsd.lib.mk 282420 2015-05-04 16:28:54Z bapt $ +# $FreeBSD: projects/bmake/share/mk/bsd.lib.mk 283591 2015-05-26 21:52:57Z sjg $ # .include @@ -126,8 +126,10 @@ ${CC} ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} ${CTFCONVERT_CMD} +.if !defined(_SKIP_BUILD) all: beforebuild .WAIT beforebuild: objwarn +.endif _LIBDIR:=${LIBDIR} _SHLIBDIR:=${SHLIBDIR} @@ -210,10 +212,40 @@ beforelinking: ${SOBJS} ${SHLIB_NAME_FULL}: beforelinking .endif + +.if defined(SHLIB_LINK) +# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building +# and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory +# prefix where shared objects will be installed by the install target. +# +# ${_LDSCRIPTROOT} is the directory prefix that will be used when generating +# ld(1) scripts. The crosstools' ld is configured to lookup libraries in an +# alternative directory which is called "sysroot", so during buildworld binaries +# won't be linked against the running system libraries but against the ones of +# the current source tree. ${_LDSCRIPTROOT} behavior is twisted because of +# the location where we store them: +# - 64 bits libs are located under sysroot, so ${_LDSCRIPTROOT} must be empty +# because ld(1) will manage to find them from sysroot; +# - 32 bits shims are not, so ${_LDSCRIPTROOT} is used to specify their full +# path, outside of sysroot. +# Note that ld(1) scripts are generated both during buildworld and +# installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty +# because on the target system, libraries are meant to be looked up from /. +.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) +${SHLIB_LINK:R}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT} + sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${_SHLIBDIR}/${SHLIB_NAME},g' \ + -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${_LIBDIR},g' \ + -e 's,/[^ ]*/,,g' \ + ${.ALLSRC} > ${.TARGET} + +${SHLIB_NAME_FULL}: ${SHLIB_LINK:R}.ld +.endif +.endif + ${SHLIB_NAME_FULL}: ${SOBJS} @${ECHO} building shared library ${SHLIB_NAME} @rm -f ${SHLIB_NAME} ${SHLIB_LINK} -.if defined(SHLIB_LINK) +.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) @${INSTALL_SYMLINK} ${SHLIB_NAME} ${SHLIB_LINK} .endif ${_LD} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \ @@ -258,11 +290,15 @@ .endif # !defined(INTERNALLIB) +.if defined(_SKIP_BUILD) +all: +.else all: ${_LIBS} .if ${MK_MAN} != "no" all: _manpages .endif +.endif _EXTRADEPEND: @TMP=_depend$$$$; \ @@ -318,32 +354,10 @@ ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR} .endif .if defined(SHLIB_LINK) -# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building -# and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory -# prefix where shared objects will be installed by the install target. -# -# ${_LDSCRIPTROOT} is the directory prefix that will be used when generating -# ld(1) scripts. The crosstools' ld is configured to lookup libraries in an -# alternative directory which is called "sysroot", so during buildworld binaries -# won't be linked against the running system libraries but against the ones of -# the current source tree. ${_LDSCRIPTROOT} behavior is twisted because of -# the location where we store them: -# - 64 bits libs are located under sysroot, so ${_LDSCRIPTROOT} must be empty -# because ld(1) will manage to find them from sysroot; -# - 32 bits shims are not, so ${_LDSCRIPTROOT} is used to specify their full -# path, outside of sysroot. -# Note that ld(1) scripts are generated both during buildworld and -# installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty -# because on the target system, libraries are meant to be looked up from /. -.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) - sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${_SHLIBDIR}/${SHLIB_NAME},g' \ - -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${_LIBDIR},g' \ - ${.CURDIR}/${SHLIB_LDSCRIPT} > ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld +.if commands(${SHLIB_LINK:R}.ld) ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${_INSTALLFLAGS} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld \ + ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \ ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} - rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld - .else .if ${_SHLIBDIR} == ${_LIBDIR} ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} Index: share/mk/bsd.nls.mk =================================================================== --- share/mk/bsd.nls.mk +++ share/mk/bsd.nls.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.nls.mk 156813 2006-03-17 18:54:44Z ru $ +# $FreeBSD: projects/bmake/share/mk/bsd.nls.mk 248076 2013-03-08 22:02:08Z sjg $ # # This include file handles building and installing Native # Language Support (NLS) catalogs @@ -61,13 +61,22 @@ # # installation rules # +.if ${MK_STAGING_PROG} == "yes" +.if !defined(_SKIP_BUILD) +staging: stage_symlinks +.endif +STAGE_SYMLINKS.NLS= ${NLSSYMLINKS} +STAGE_SYMLINKS_DIR.NLS= ${STAGE_OBJTOP} +.else +SYMLINKS+= ${NLSSYMLINKS} +.endif .for file in ${NLS} NLSNAME_${file:T}= ${file:T:R}/${NLSNAME}.cat .if defined(NLSLINKS_${file:R}) && !empty(NLSLINKS_${file:R}) NLSLINKS+= ${file:R} .endif .for dst in ${NLSLINKS_${file:R}} -SYMLINKS+= ../${file:R}/${NLSNAME}.cat ${NLSDIR}/${dst}/${NLSNAME}.cat +NLSSYMLINKS+= ../${file:R}/${NLSNAME}.cat ${NLSDIR}/${dst}/${NLSNAME}.cat .endfor .endfor Index: share/mk/bsd.obj.mk =================================================================== --- share/mk/bsd.obj.mk +++ share/mk/bsd.obj.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.obj.mk 279980 2015-03-14 12:29:44Z dim $ +# $FreeBSD: projects/bmake/share/mk/bsd.obj.mk 283591 2015-05-26 21:52:57Z sjg $ # # The include file handles creating the 'obj' directory # and cleaning up object files, etc. @@ -50,6 +50,15 @@ CANONICALOBJDIR:=/usr/obj${.CURDIR} .endif +.if defined(.PARSEDIR) && !defined(NO_OBJ) && !defined(NO_AUTO_OBJ) +.if ${MK_AUTO_OBJ} == "yes" +__objdir?= ${CANONICALOBJDIR} +# this is what auto.obj.mk wants to see +MKOBJDIRS=auto +.include "auto.obj.mk" +.endif +.endif + # # Warn of unorthodox object directory. # @@ -148,4 +157,51 @@ .include +.if make(destroy*) && defined(OBJROOT) +# this is much faster and more reliable than cleaning. + +# just in case we are playing games with these... +_OBJDIR?= ${.OBJDIR} +_CURDIR?= ${.CURDIR} + +# destroy almost everything +destroy: destroy-all +destroy-all: + +# just remove our objdir +destroy-arch: .NOMETA +.if ${_OBJDIR} != ${_CURDIR} + cd ${_CURDIR} && rm -rf ${_OBJDIR} +.endif + +.if defined(HOST_OBJTOP) +destroy-host: destroy.host +destroy.host: .NOMETA + cd ${_CURDIR} && rm -rf ${HOST_OBJTOP}/${RELDIR:N.} +.endif + +.if make(destroy-all) && ${RELDIR} == "." +destroy-all: destroy-stage +.endif + +# remove the stage tree +destroy-stage: .NOMETA +.if defined(STAGE_ROOT) + cd ${_CURDIR} && rm -rf ${STAGE_ROOT} +.endif + +# allow parallel destruction +_destroy_machine_list = common host ${ALL_MACHINE_LIST} +.for m in ${_destroy_machine_list:O:u} +destroy-all: destroy.$m +.if !target(destroy.$m) +destroy.$m: .NOMETA +.if ${_OBJDIR} != ${_CURDIR} + cd ${_CURDIR} && rm -rf ${OBJROOT}$m*/${RELDIR:N.} +.endif +.endif +.endfor + +.endif + .endif # !target(____) Index: share/mk/bsd.opts.mk =================================================================== --- share/mk/bsd.opts.mk +++ share/mk/bsd.opts.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.opts.mk 276556 2015-01-02 18:54:55Z bapt $ +# $FreeBSD: projects/bmake/share/mk/bsd.opts.mk 283996 2015-06-04 19:11:56Z sjg $ # # Option file for src builds. # @@ -70,6 +70,11 @@ DEBUG_FILES \ INSTALL_AS_USER +# meta mode related +__DEFAULT_DEPENDENT_OPTIONS = \ + STAGING_MAN/STAGING \ + STAGING_PROG/STAGING + .include # Index: share/mk/bsd.own.mk =================================================================== --- share/mk/bsd.own.mk +++ share/mk/bsd.own.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.own.mk 278926 2015-02-17 23:13:45Z rpaulo $ +# $FreeBSD: projects/bmake/share/mk/bsd.own.mk 283591 2015-05-26 21:52:57Z sjg $ # # The include file set common variables for owner, # group, mode, and directories. Defaults are in brackets. @@ -140,10 +140,11 @@ .if !defined(USER) USER!= id -un .endif -_gid!= id -gn +_gid!= id -g +_gn!= id -gn .for x in BIN CONF DOC DTB INFO KMOD LIB MAN NLS SHARE $xOWN= ${USER} -$xGRP= ${_gid} +$xGRP= ${_gn} .endfor .endif .endif Index: share/mk/bsd.prog.mk =================================================================== --- share/mk/bsd.prog.mk +++ share/mk/bsd.prog.mk @@ -1,5 +1,5 @@ # from: @(#)bsd.prog.mk 5.26 (Berkeley) 6/25/91 -# $FreeBSD: head/share/mk/bsd.prog.mk 282420 2015-05-04 16:28:54Z bapt $ +# $FreeBSD: projects/bmake/share/mk/bsd.prog.mk 283591 2015-05-26 21:52:57Z sjg $ .include .include @@ -141,11 +141,15 @@ .endif .endif # defined(PROG) +.if defined(_SKIP_BUILD) +all: +.else all: beforebuild .WAIT ${PROG} ${SCRIPTS} beforebuild: objwarn .if ${MK_MAN} != "no" all: _manpages .endif +.endif .if defined(PROG) CLEANFILES+= ${PROG} @@ -218,6 +222,10 @@ SCRIPTSGRP?= ${BINGRP} SCRIPTSMODE?= ${BINMODE} +STAGE_AS_SETS+= scripts +stage_as.scripts: ${SCRIPTS} +FLAGS.stage_as.scripts= -m ${SCRIPTSMODE} +STAGE_FILES_DIR.scripts= ${STAGE_OBJTOP} .for script in ${SCRIPTS} .if defined(SCRIPTSNAME) SCRIPTSNAME_${script:T}?= ${SCRIPTSNAME} @@ -228,6 +236,7 @@ SCRIPTSOWN_${script:T}?= ${SCRIPTSOWN} SCRIPTSGRP_${script:T}?= ${SCRIPTSGRP} SCRIPTSMODE_${script:T}?= ${SCRIPTSMODE} +STAGE_AS_${script:T}= ${SCRIPTSDIR_${script:T}}/${SCRIPTSNAME_${script:T}} _scriptsinstall: _SCRIPTSINS_${script:T} _SCRIPTSINS_${script:T}: ${script} ${INSTALL} -o ${SCRIPTSOWN_${.ALLSRC:T}} \ Index: share/mk/bsd.subdir.mk =================================================================== --- share/mk/bsd.subdir.mk +++ share/mk/bsd.subdir.mk @@ -1,5 +1,5 @@ # from: @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 -# $FreeBSD: head/share/mk/bsd.subdir.mk 267511 2014-06-15 13:45:37Z ian $ +# $FreeBSD: projects/bmake/share/mk/bsd.subdir.mk 283591 2015-05-26 21:52:57Z sjg $ # # The include file contains the default targets # for building subdirectories. @@ -34,6 +34,15 @@ .include +.if defined(.PARSEDIR) && !defined(NEED_SUBDIR) +.if ${.MAKE.LEVEL} == 0 && ${MK_META_MODE} == "yes" && !empty(SUBDIR) && !(make(clean*) || make(destroy*)) +.include +# ignore this +_SUBDIR: +.endif +.endif +.if !target(_SUBDIR) + DISTRIBUTION?= base .if !target(distribute) distribute: .MAKE @@ -122,6 +131,8 @@ .endif .endfor +.endif + .if !target(install) .if !target(beforeinstall) beforeinstall: Index: share/mk/bsd.sys.mk =================================================================== --- share/mk/bsd.sys.mk +++ share/mk/bsd.sys.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.sys.mk 280784 2015-03-28 12:23:15Z dim $ +# $FreeBSD: projects/bmake/share/mk/bsd.sys.mk 283591 2015-05-26 21:52:57Z sjg $ # # This file contains common settings used for building FreeBSD # sources. @@ -173,5 +173,113 @@ realinstall regress subdir-all subdir-depend subdir-install \ tags whereobj -.PHONY: ${PHONY_NOTMAIN} -.NOTMAIN: ${PHONY_NOTMAIN} +# we don't want ${PROG} to be PHONY +.PHONY: ${PHONY_NOTMAIN:N${PROG:U}} +.NOTMAIN: ${PHONY_NOTMAIN:Nall} + +.if ${MK_STAGING} != "no" +.if defined(_SKIP_BUILD) || (!make(all) && !make(clean*)) +_SKIP_STAGING?= yes +.endif +.if ${_SKIP_STAGING:Uno} == "yes" +staging stage_libs stage_files stage_as stage_links stage_symlinks: +.else +# allow targets like beforeinstall to be leveraged +DESTDIR= ${STAGE_OBJTOP} +_SHLIBDIRPREFIX= ${STAGE_OBJTOP} + +.if commands(beforeinstall) +.if !empty(_LIBS) || ${MK_STAGING_PROG} != "no" +staging: beforeinstall +.endif +.endif + +# normally only libs and includes are staged +.if ${MK_STAGING_PROG} != "no" +STAGE_DIR.prog= ${STAGE_OBJTOP}${BINDIR} + +.if !empty(PROG) || !empty(PROGS) +.if defined(PROGNAME) +STAGE_AS_SETS+= prog +STAGE_AS_${PROG}= ${PROGNAME} +stage_as.prog: ${PROG} +.else +STAGE_SETS+= prog +stage_files.prog: ${PROG} +staging: stage_files +.endif +.endif +.endif + +.if !empty(_LIBS) && !defined(INTERNALLIB) +.if defined(SHLIBDIR) && ${SHLIBDIR} != ${LIBDIR} && ${_LIBS:Uno:M*.so.*} != "" +STAGE_SETS+= shlib +STAGE_DIR.shlib= ${STAGE_OBJTOP}${SHLIBDIR} +STAGE_FILES.shlib+= ${_LIBS:M*.so.*} +stage_files.shlib: ${_LIBS:M*.so.*} +.endif + +.if defined(SHLIB_LINK) && commands(${SHLIB_LINK:R}.ld) +_LDSCRIPTROOT?= ${STAGE_OBJTOP} +STAGE_AS_SETS+= ldscript +STAGE_AS.ldscript+= ${SHLIB_LINK:R}.ld +stage_as.ldscript: ${SHLIB_LINK:R}.ld +STAGE_DIR.ldscript = ${STAGE_LIBDIR} +STAGE_AS_${SHLIB_LINK:R}.ld:= ${SHLIB_LINK} +NO_SHLIB_LINKS= +.endif + +.if target(stage_files.shlib) +stage_libs: ${_LIBS} +.if defined(DEBUG_FLAGS) && target(${SHLIB_NAME}.symbols) +stage_files.shlib: ${SHLIB_NAME}.symbols +.endif +.else +stage_libs: ${_LIBS} +.endif +.if defined(SHLIB_NAME) && defined(DEBUG_FLAGS) && target(${SHLIB_NAME}.symbols) +stage_libs: ${SHLIB_NAME}.symbols +.endif + +.endif + +.if !empty(INCS) || !empty(INCSGROUPS) && target(buildincludes) +.if !defined(NO_BEFOREBUILD_INCLUDES) +stage_includes: buildincludes +beforebuild: stage_includes +.endif +.endif + +.for t in stage_libs stage_files stage_as +.if target($t) +staging: $t +.endif +.endfor + +.if !empty(STAGE_AS_SETS) +staging: stage_as +.endif + +.if !empty(_LIBS) || ${MK_STAGING_PROG} != "no" + +.if !empty(LINKS) +staging: stage_links +.if ${MAKE_VERSION} < 20131001 +stage_links.links: ${_LIBS} ${PROG} +.endif +STAGE_SETS+= links +STAGE_LINKS.links= ${LINKS} +.endif + +.if !empty(SYMLINKS) +staging: stage_symlinks +STAGE_SETS+= links +STAGE_SYMLINKS.links= ${SYMLINKS} +.endif + +.endif + +.include +.endif +.endif + Index: share/mk/bsd.test.mk =================================================================== --- share/mk/bsd.test.mk +++ share/mk/bsd.test.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/bsd.test.mk 273810 2014-10-29 04:32:46Z ngie $ +# $FreeBSD: projects/bmake/share/mk/bsd.test.mk 274683 2014-11-19 01:07:58Z sjg $ # # Generic build infrastructure for test programs. # @@ -91,9 +91,30 @@ .include .endif +.ifdef PROG +# we came here via bsd.progs.mk below +# parent will do staging. +MK_STAGING= no +.endif + .if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) .include .endif .include +.if !defined(PROG) && ${MK_STAGING} != "no" +.if !defined(_SKIP_BUILD) +# this will handle staging if needed +_SKIP_STAGING= no +# but we don't want it to build anything +_SKIP_BUILD= +.endif +.if !empty(PROGS) +stage_files.prog: ${PROGS} +.endif +.include +.endif + +.if !target(objwarn) .include +.endif Index: share/mk/src.opts.mk =================================================================== --- share/mk/src.opts.mk +++ share/mk/src.opts.mk @@ -1,4 +1,4 @@ -# $FreeBSD: head/share/mk/src.opts.mk 282198 2015-04-28 19:15:28Z ngie $ +# $FreeBSD: projects/bmake/share/mk/src.opts.mk 283585 2015-05-26 21:41:26Z sjg $ # # Option file for FreeBSD /usr/src builds. # @@ -187,6 +187,7 @@ OPENSSH_NONE_CIPHER \ SHARED_TOOLCHAIN \ SORT_THREADS \ + STALE_STAGED \ SVN # Index: share/mk/sys.mk =================================================================== --- share/mk/sys.mk +++ share/mk/sys.mk @@ -1,5 +1,5 @@ # from: @(#)sys.mk 8.2 (Berkeley) 3/21/94 -# $FreeBSD: head/share/mk/sys.mk 281258 2015-04-08 02:43:05Z markj $ +# $FreeBSD: projects/bmake/share/mk/sys.mk 283590 2015-05-26 21:51:36Z sjg $ unix ?= We run FreeBSD, not UNIX. .FreeBSD ?= true @@ -325,6 +325,25 @@ rm -f ${.PREFIX}.tmp.c ${CTFCONVERT_CMD} + +# Some options we need now +__DEFAULT_NO_OPTIONS= \ + DIRDEPS_CACHE \ + META_MODE \ + META_FILES \ + + +__DEFAULT_DEPENDENT_OPTIONS= \ + AUTO_OBJ/META_MODE \ + STAGING/META_MODE \ + SYSROOT/META_MODE + +.include + +# Set any local definitions first. Place this early, but it needs +# MACHINE_CPUARCH to be defined. +.sinclude + # Pull in global settings. __MAKE_CONF?=/etc/make.conf .if exists(${__MAKE_CONF}) @@ -332,13 +351,18 @@ .endif # Setup anything for the FreeBSD source build, if we're building -# inside the source tree. Needs to be after make.conf, but before -# local stuff. +# inside the source tree. Needs to be after make.conf .sinclude -# Set any local definitions first. Place this early, but it needs -# MACHINE_CPUARCH to be defined. -.sinclude +.if ${MK_META_MODE} == "yes" +.sinclude +.elif ${MK_META_FILES} == "yes" && ${.MAKEFLAGS:U:M-B} == "" +.MAKE.MODE= meta verbose +.endif +.if ${MK_AUTO_OBJ} == "yes" +# This needs to be done early - before .PATH is computed +.sinclude +.endif .if defined(__MAKE_SHELL) && !empty(__MAKE_SHELL) SHELL= ${__MAKE_SHELL}