Index: stable/11/share/mk/bsd.obj.mk =================================================================== --- stable/11/share/mk/bsd.obj.mk (revision 335642) +++ stable/11/share/mk/bsd.obj.mk (revision 335643) @@ -1,236 +1,237 @@ # $FreeBSD$ # # The include file handles creating the 'obj' directory # and cleaning up object files, etc. # # +++ variables +++ # # CLEANDIRS Additional directories to remove for the clean target. # # CLEANFILES Additional files to remove for the clean target. # # MAKEOBJDIR A pathname for the directory where the targets # are built. Note: MAKEOBJDIR is an *environment* variable # and works properly only if set as an environment variable, # not as a global or command line variable! # # E.g. use `env MAKEOBJDIR=temp-obj make' # # MAKEOBJDIRPREFIX Specifies somewhere other than /usr/obj to root the object # tree. Note: MAKEOBJDIRPREFIX is an *environment* variable # and works properly only if set as an environment variable, # not as a global or command line variable! # # E.g. use `env MAKEOBJDIRPREFIX=/somewhere/obj make' # # NO_OBJ Do not create object directories. This should not be set # if anything is built. # # +++ targets +++ # # clean: # remove ${CLEANFILES}; remove ${CLEANDIRS} and all contents. # # cleandir: # remove the build directory (and all its contents) created by obj # # obj: # create build directory. # .if !target(____) ____: .include .if ${MK_AUTO_OBJ} == "yes" # it is done by now objwarn: obj: CANONICALOBJDIR= ${.OBJDIR} .if defined(NO_OBJ) # but this makefile does not want it! .OBJDIR: ${.CURDIR} .endif # Handle special case where SRCS is full-pathed and requires # nested objdirs. This duplicates some auto.obj.mk logic. .if (!empty(SRCS:M*/*) || !empty(DPSRCS:M*/*)) && \ (${.TARGETS} == "" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} != "") _wantdirs= ${SRCS:M*/*:H} ${DPSRCS:M*/*:H} .if !empty(_wantdirs) _wantdirs:= ${_wantdirs:O:u} _needdirs= .for _dir in ${_wantdirs} .if !exists(${.OBJDIR}/${_dir}/) _needdirs+= ${_dir} .endif .endfor .endif .if !empty(_needdirs) #_mkneededdirs!= umask ${OBJDIR_UMASK:U002}; ${Mkdirs} ${_needdirs} __objdir_made != umask ${OBJDIR_UMASK:U002}; ${Mkdirs}; \ for dir in ${_needdirs}; do \ dir=${.OBJDIR}/$${dir}; \ ${ECHO_TRACE} "[Creating nested objdir $${dir}...]" >&2; \ Mkdirs $${dir}; \ done .endif .endif # !empty(SRCS:M*/*) || !empty(DPSRCS:M*/*) .elif defined(MAKEOBJDIRPREFIX) CANONICALOBJDIR:=${MAKEOBJDIRPREFIX}${.CURDIR} .elif defined(MAKEOBJDIR) && ${MAKEOBJDIR:M/*} != "" CANONICALOBJDIR:=${MAKEOBJDIR} OBJTOP?= ${MAKEOBJDIR} .else CANONICALOBJDIR:=/usr/obj${.CURDIR} .endif OBJTOP?= ${.OBJDIR:S,${.CURDIR},,}${SRCTOP} # # Warn of unorthodox object directory. # # The following directories are tried in order for ${.OBJDIR}: # # 1. ${MAKEOBJDIRPREFIX}/`pwd` # 2. ${MAKEOBJDIR} # 3. obj.${MACHINE} # 4. obj # 5. /usr/obj/`pwd` # 6. ${.CURDIR} # # If ${.OBJDIR} is constructed using canonical cases 1 or 5, or # case 2 (using MAKEOBJDIR), don't issue a warning. Otherwise, # issue a warning differentiating between cases 6 and (3 or 4). # objwarn: .if !defined(NO_OBJ) && ${.OBJDIR} != ${CANONICALOBJDIR} && \ !(defined(MAKEOBJDIRPREFIX) && exists(${CANONICALOBJDIR}/)) && \ !(defined(MAKEOBJDIR) && exists(${MAKEOBJDIR}/)) .if ${.OBJDIR} == ${.CURDIR} @${ECHO} "Warning: Object directory not changed from original ${.CURDIR}" .elif exists(${.CURDIR}/obj.${MACHINE}/) || exists(${.CURDIR}/obj/) @${ECHO} "Warning: Using ${.OBJDIR} as object directory instead of\ canonical ${CANONICALOBJDIR}" .endif .endif beforebuild: objwarn .if !defined(NO_OBJ) .if !target(obj) obj: .PHONY @if ! test -d ${CANONICALOBJDIR}/; then \ mkdir -p ${CANONICALOBJDIR}; \ if ! test -d ${CANONICALOBJDIR}/; then \ ${ECHO} "Unable to create ${CANONICALOBJDIR}."; \ exit 1; \ fi; \ ${ECHO} "${CANONICALOBJDIR} created for ${.CURDIR}"; \ fi .for dir in ${SRCS:H:O:u} ${DPSRCS:H:O:u} @if ! test -d ${CANONICALOBJDIR}/${dir}/; then \ mkdir -p ${CANONICALOBJDIR}/${dir}; \ if ! test -d ${CANONICALOBJDIR}/${dir}/; then \ ${ECHO} "Unable to create ${CANONICALOBJDIR}/${dir}."; \ exit 1; \ fi; \ ${ECHO} "${CANONICALOBJDIR}/${dir} created for ${.CURDIR}"; \ fi .endfor .endif .if !target(objlink) objlink: @if test -d ${CANONICALOBJDIR}/; then \ rm -f ${.CURDIR}/obj; \ ln -s ${CANONICALOBJDIR} ${.CURDIR}/obj; \ else \ echo "No ${CANONICALOBJDIR} to link to - do a make obj."; \ fi .endif .endif # !defined(NO_OBJ) # # where would that obj directory be? # .if !target(whereobj) whereobj: @echo ${.OBJDIR} .endif +# Same check in bsd.progs.mk .if ${CANONICALOBJDIR} != ${.CURDIR} && exists(${CANONICALOBJDIR}/) cleanobj: -rm -rf ${CANONICALOBJDIR} .else cleanobj: clean cleandepend .endif @if [ -L ${.CURDIR}/obj ]; then rm -f ${.CURDIR}/obj; fi # Tell bmake not to look for generated files via .PATH NOPATH_FILES+= ${CLEANFILES} .if !empty(NOPATH_FILES) .NOPATH: ${NOPATH_FILES} .endif .if !target(clean) clean: .if defined(CLEANFILES) && !empty(CLEANFILES) rm -f ${CLEANFILES} .endif .if defined(CLEANDIRS) && !empty(CLEANDIRS) -rm -rf ${CLEANDIRS} .endif .endif .ORDER: clean all -cleandir: cleanobj - .include + +cleandir: .WAIT cleanobj .if make(destroy*) && defined(OBJROOT) # this (rm -rf objdir) 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: stable/11/share/mk/bsd.progs.mk =================================================================== --- stable/11/share/mk/bsd.progs.mk (revision 335642) +++ stable/11/share/mk/bsd.progs.mk (revision 335643) @@ -1,155 +1,164 @@ # $FreeBSD$ # $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $ # # @(#) Copyright (c) 2006, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. # Permission to copy, redistribute or otherwise # use this file is hereby granted provided that # the above copyright notice and this notice are # left intact. # # Please send copies of changes and bug-fixes to: # sjg@crufty.net # .MAIN: all .if defined(PROGS) || defined(PROGS_CXX) # we really only use PROGS below... PROGS += ${PROGS_CXX} .if defined(PROG) # just one of many PROG_OVERRIDE_VARS += BINDIR BINGRP BINOWN BINMODE DPSRCS MAN NO_WERROR \ PROGNAME SRCS STRIP WARNS PROG_VARS += CFLAGS CXXFLAGS DEBUG_FLAGS DPADD INTERNALPROG LDADD LIBADD \ LINKS LDFLAGS MLINKS ${PROG_OVERRIDE_VARS} .for v in ${PROG_VARS:O:u} .if empty(${PROG_OVERRIDE_VARS:M$v}) .if defined(${v}.${PROG}) $v += ${${v}.${PROG}} .elif defined(${v}_${PROG}) $v += ${${v}_${PROG}} .endif .else $v ?= .endif .endfor .if ${MK_DIRDEPS_BUILD} == "yes" # Leave updating the Makefile.depend to the parent. UPDATE_DEPENDFILE = NO # Record our meta files for the parent to use. CLEANFILES+= ${PROG}.meta_files ${PROG}.meta_files: .NOMETA $${.MAKE.META.CREATED} ${_this} @echo "Updating ${.TARGET}: ${.OODATE:T:[1..8]}" @echo ${.MAKE.META.FILES} > ${.TARGET} .if !defined(_SKIP_BUILD) .END: ${PROG}.meta_files .endif .endif # ${MK_DIRDEPS_BUILD} == "yes" # prog.mk will do the rest .else # !defined(PROG) .if !defined(_SKIP_BUILD) all: ${PROGS} .endif META_XTRAS+= ${cat ${PROGS:S/$/*.meta_files/} 2>/dev/null || true:L:sh} .if ${MK_STAGING} != "no" && !empty(PROGS) # Stage from parent while respecting PROGNAME and BINDIR overrides. .for _prog in ${PROGS} STAGE_DIR.prog.${_prog}= ${STAGE_OBJTOP}${BINDIR.${_prog}:UBINDIR_${_prog}:U${BINDIR}} STAGE_AS_SETS+= prog.${_prog} STAGE_AS_prog.${_prog}= ${PROGNAME.${_prog}:UPROGNAME_${_prog}:U${_prog}} stage_as.prog.${_prog}: ${_prog} .endfor .endif # ${MK_STAGING} != "no" && !empty(PROGS) .endif .endif # PROGS || PROGS_CXX # These are handled by the main make process. .ifdef _RECURSING_PROGS MK_STAGING= no _PROGS_GLOBAL_VARS= CLEANFILES CLEANDIRS CONFGROUPS FILESGROUPS INCSGROUPS \ SCRIPTS .for v in ${_PROGS_GLOBAL_VARS} $v = .endfor .endif # handle being called [bsd.]progs.mk .include # Find common sources among the PROGS to depend on them before building # anything. This allows parallelization without them each fighting over # the same objects. _PROGS_COMMON_SRCS= _PROGS_ALL_SRCS= .for p in ${PROGS} .for s in ${SRCS.${p}} .if ${_PROGS_ALL_SRCS:M${s}} && !${_PROGS_COMMON_SRCS:M${s}} _PROGS_COMMON_SRCS+= ${s} .else _PROGS_ALL_SRCS+= ${s} .endif .endfor .endfor .if !empty(_PROGS_COMMON_SRCS) _PROGS_COMMON_OBJS= ${_PROGS_COMMON_SRCS:M*.[dhly]} .if !empty(_PROGS_COMMON_SRCS:N*.[dhly]) _PROGS_COMMON_OBJS+= ${_PROGS_COMMON_SRCS:N*.[dhly]:R:S/$/.o/g} .endif .endif # When recursing, ensure common sources are not rebuilt in META_MODE. .if defined(_RECURSING_PROGS) && !empty(_PROGS_COMMON_OBJS) && \ !empty(.MAKE.MODE:Mmeta) ${_PROGS_COMMON_OBJS}: .NOMETA .endif .if !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG) # tell progs.mk we might want to install things -PROGS_TARGETS+= checkdpadd clean cleandepend cleandir depend install +PROGS_TARGETS+= checkdpadd clean depend install +# Only handle removing depend files from the main process. +_PROG_MK.cleandir= CLEANDEPENDFILES= CLEANDEPENDDIRS= +_PROG_MK.cleanobj= CLEANDEPENDFILES= CLEANDEPENDDIRS= +# Only recurse on these if there is no objdir, meaning a normal +# 'clean' gets ran via the target defined in bsd.obj.mk. +# Same check from cleanobj: in bsd.obj.mk +.if ${CANONICALOBJDIR} == ${.CURDIR} || !exists(${CANONICALOBJDIR}/) +PROGS_TARGETS+= cleandir cleanobj +.endif # Ensure common objects are built before recursing. .if !empty(_PROGS_COMMON_OBJS) ${PROGS}: ${_PROGS_COMMON_OBJS} .endif .for p in ${PROGS} .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) # bsd.prog.mk may need to know this x.$p= PROG_CXX=$p .endif # Main PROG target $p ${p}_p: .PHONY .MAKE (cd ${.CURDIR} && \ DEPENDFILE=.depend.$p \ NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \ PROG=$p ${x.$p}) # Pseudo targets for PROG, such as 'install'. .for t in ${PROGS_TARGETS:O:u} $p.$t: .PHONY .MAKE (cd ${.CURDIR} && \ DEPENDFILE=.depend.$p \ NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS=t \ - PROG=$p ${x.$p} ${@:E}) + ${_PROG_MK.${t}} PROG=$p ${x.$p} ${@:E}) .endfor .endfor # Depend main pseudo targets on all PROG.pseudo targets too. .for t in ${PROGS_TARGETS:O:u} .if make(${t}) $t: ${PROGS:%=%.$t} .endif .endfor .endif # !empty(PROGS) && !defined(_RECURSING_PROGS) && !defined(PROG) Index: stable/11 =================================================================== --- stable/11 (revision 335642) +++ stable/11 (revision 335643) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r321427,321445