summaryrefslogtreecommitdiffstats
path: root/share/mk
diff options
context:
space:
mode:
authorbapt <bapt@FreeBSD.org>2015-11-01 21:17:38 +0000
committerbapt <bapt@FreeBSD.org>2015-11-01 21:17:38 +0000
commit1477bec6db952893631d0121f1a0b921b7352899 (patch)
treed7eefbc43ae961805537882e088a954e7b9cf530 /share/mk
parente29f1d2f891c995886c7e37be37546b3dfd29efd (diff)
parenta23a95f981ff4d4789caf8a8349c8b017b1ac351 (diff)
downloadFreeBSD-src-1477bec6db952893631d0121f1a0b921b7352899.zip
FreeBSD-src-1477bec6db952893631d0121f1a0b921b7352899.tar.gz
Merge from head
Diffstat (limited to 'share/mk')
-rw-r--r--share/mk/bsd.README1
-rw-r--r--share/mk/bsd.compiler.mk31
-rw-r--r--share/mk/bsd.confs.mk18
-rw-r--r--share/mk/bsd.crunchgen.mk156
-rw-r--r--share/mk/bsd.files.mk3
-rw-r--r--share/mk/bsd.man.mk34
-rw-r--r--share/mk/bsd.progs.mk10
-rw-r--r--share/mk/bsd.subdir.mk82
-rw-r--r--share/mk/src.opts.mk21
9 files changed, 190 insertions, 166 deletions
diff --git a/share/mk/bsd.README b/share/mk/bsd.README
index cb6e41f..5aa1949 100644
--- a/share/mk/bsd.README
+++ b/share/mk/bsd.README
@@ -20,6 +20,7 @@ bsd.arch.inc.mk - includes arch-specific Makefile.$arch
bsd.compiler.mk - defined based on current compiler
bsd.confs.mk - install of configuration files
bsd.cpu.mk - sets CPU/arch-related variables (included from sys.mk)
+bsd.crunchgen.mk - building crunched binaries using crunchgen(1)
bsd.dep.mk - handle Makefile dependencies
bsd.doc.mk - building troff system documents
bsd.endian.mk - TARGET_ENDIAN=1234(little) or 4321 (big) for target
diff --git a/share/mk/bsd.compiler.mk b/share/mk/bsd.compiler.mk
index dcdf598..9ad4bae 100644
--- a/share/mk/bsd.compiler.mk
+++ b/share/mk/bsd.compiler.mk
@@ -25,13 +25,34 @@
.if !target(__<bsd.compiler.mk>__)
__<bsd.compiler.mk>__:
+# Try to import COMPILER_TYPE and COMPILER_VERSION from parent make.
+# The value is only used/exported for the same environment that impacts
+# CC and COMPILER_* settings here.
+_exported_vars= COMPILER_TYPE COMPILER_VERSION
+_cc_hash= ${CC}${MACHINE}${PATH}
+_cc_hash:= ${_cc_hash:hash}
+# Only import if none of the vars are set somehow else.
+_can_export= yes
+.for var in ${_exported_vars}
+.if defined(${var})
+_can_export= no
+.endif
+.endfor
+.if ${_can_export} == yes
+.for var in ${_exported_vars}
+.if defined(${var}.${_cc_hash})
+${var}= ${${var}.${_cc_hash}}
+.endif
+.endfor
+.endif
+
.if ${MACHINE} == "common"
# common is a pseudo machine for architecture independent
# generated files - thus there is no compiler.
COMPILER_TYPE= none
COMPILER_VERSION= 0
.elif !defined(COMPILER_TYPE) || !defined(COMPILER_VERSION)
-_v!= ${CC} --version 2>/dev/null || echo 0.0.0
+_v!= ${CC} --version || echo 0.0.0
.if !defined(COMPILER_TYPE)
. if ${CC:T:M*gcc*}
@@ -54,6 +75,14 @@ COMPILER_VERSION!=echo ${_v:M[1-9].[0-9]*} | awk -F. '{print $$1 * 10000 + $$2 *
.undef _v
.endif
+# Export the values so sub-makes don't have to look them up again, using the
+# hash key computed above.
+.for var in ${_exported_vars}
+${var}.${_cc_hash}:= ${${var}}
+.export-env ${var}.${_cc_hash}
+.undef ${var}.${_cc_hash}
+.endfor
+
.if ${COMPILER_TYPE} == "clang" || \
(${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800)
COMPILER_FEATURES= c++11
diff --git a/share/mk/bsd.confs.mk b/share/mk/bsd.confs.mk
index 36298d7..aa5191f 100644
--- a/share/mk/bsd.confs.mk
+++ b/share/mk/bsd.confs.mk
@@ -4,11 +4,10 @@
.error bsd.conf.mk cannot be included directly.
.endif
-.if ${MK_INCLUDES} != "no"
CONFGROUPS?= CONFS
.if !target(buildconfig)
-.for group in ${CONFSGROUPS}
+.for group in ${CONFGROUPS}
buildconfig: ${${group}}
.endfor
.endif
@@ -22,10 +21,9 @@ all: buildconfig
${group}OWN?= ${SHAREOWN}
${group}GRP?= ${SHAREGRP}
${group}MODE?= ${CONFMODE}
-${group}DIR?= ${CONFIGDIR}/
+${group}DIR?= ${CONFDIR}
STAGE_SETS+= ${group}
STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
-STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP}
_${group}CONFS=
.for cnf in ${${group}}
@@ -46,7 +44,6 @@ STAGE_AS_${cnf:T}= ${${group}NAME_${cnf:T}}
# XXX {group}OWN,GRP,MODE
STAGE_DIR.${cnf:T}= ${STAGE_OBJTOP}${${group}DIR_${cnf:T}}
stage_as.${cnf:T}: ${cnf}
-stage_config: stage_as.${cnf:T}
installconfig: _${group}INS_${cnf:T}
_${group}INS_${cnf:T}: ${cnf}
@@ -60,7 +57,6 @@ _${group}CONFS+= ${cnf}
.endfor
.if !empty(_${group}CONFS)
stage_files.${group}: ${_${group}CONFS}
-stage_config: stage_files.${group}
installconfig: _${group}INS
_${group}INS: ${_${group}CONFS}
@@ -78,10 +74,12 @@ _${group}INS: ${_${group}CONFS}
.endif # !target(installconfig)
-.if ${MK_STAGING} != "no" && !defined(_SKIP_BUILD)
-.if !defined(NO_STAGE_CONFIG)
-STAGE_TARGETS+= stage_config
+.if ${MK_STAGING} != "no"
+.if !empty(STAGE_SETS)
+buildconfig: stage_files
+.if !empty(STAGE_AS_SETS)
+buildconfig: stage_as
+.endif
.endif
.endif
-.endif # ${MK_INCLUDES} != "no"
diff --git a/share/mk/bsd.crunchgen.mk b/share/mk/bsd.crunchgen.mk
index 0f0edd3..9618f5e 100644
--- a/share/mk/bsd.crunchgen.mk
+++ b/share/mk/bsd.crunchgen.mk
@@ -1,5 +1,7 @@
#################################################################
#
+# Generate crunched binaries using crunchgen(1).
+#
# General notes:
#
# A number of Make variables are used to generate the crunchgen config file.
@@ -13,14 +15,14 @@
# local architecture.
#
# Special options can be specified for individual programs
-# CRUNCH_SRCDIR_$(P): base source directory for program $(P)
-# CRUNCH_BUILDOPTS_$(P): additional build options for $(P)
-# CRUNCH_ALIAS_$(P): additional names to be used for $(P)
+# CRUNCH_SRCDIR_${P}: base source directory for program ${P}
+# CRUNCH_BUILDOPTS_${P}: additional build options for ${P}
+# CRUNCH_ALIAS_${P}: additional names to be used for ${P}
#
# By default, any name appearing in CRUNCH_PROGS or CRUNCH_ALIAS_${P}
# will be used to generate a hard link to the resulting binary.
# Specific links can be suppressed by setting
-# CRUNCH_SUPPRESS_LINK_$(NAME) to 1.
+# CRUNCH_SUPPRESS_LINK_${NAME} to 1.
#
# If CRUNCH_GENERATE_LINKS is set to no, no links will be generated.
#
@@ -31,138 +33,124 @@
# The following is pretty nearly a generic crunchgen-handling makefile
#
-CONF= $(PROG).conf
-OUTMK= $(PROG).mk
-OUTC= $(PROG).c
-OUTPUTS=$(OUTMK) $(OUTC) $(PROG).cache
+CONF= ${PROG}.conf
+OUTMK= ${PROG}.mk
+OUTC= ${PROG}.c
+OUTPUTS=${OUTMK} ${OUTC} ${PROG}.cache
CRUNCHOBJS= ${.OBJDIR}
.if defined(MAKEOBJDIRPREFIX)
CANONICALOBJDIR:= ${MAKEOBJDIRPREFIX}${.CURDIR}
.elif defined(MAKEOBJDIR) && ${MAKEOBJDIR:M/*} != ""
-CANONICALOBJDIR:=${MAKEOBJDIR}
+CANONICALOBJDIR:= ${MAKEOBJDIR}
.else
CANONICALOBJDIR:= /usr/obj${.CURDIR}
.endif
-CRUNCH_GENERATE_LINKS?= yes
+CRUNCH_GENERATE_LINKS?= yes
-CLEANFILES+= $(CONF) *.o *.lo *.c *.mk *.cache *.a *.h
+CLEANFILES+= ${CONF} *.o *.lo *.c *.mk *.cache *.a *.h
# Don't try to extract debug info from ${PROG}.
-MK_DEBUG_FILES=no
+MK_DEBUG_FILES= no
+
+# Set a default SRCDIR for each for simpler handling below.
+.for D in ${CRUNCH_SRCDIRS}
+.for P in ${CRUNCH_PROGS_${D}}
+CRUNCH_SRCDIR_${P}?= ${.CURDIR}/../../${D}/${P}
+.endfor
+.endfor
# Program names and their aliases contribute hardlinks to 'rescue' executable,
# except for those that get suppressed.
-.for D in $(CRUNCH_SRCDIRS)
-.for P in $(CRUNCH_PROGS_$(D))
-.ifdef CRUNCH_SRCDIR_${P}
-$(OUTPUTS): $(CRUNCH_SRCDIR_${P})/Makefile
-.else
-$(OUTPUTS): $(.CURDIR)/../../$(D)/$(P)/Makefile
-.endif
+.for D in ${CRUNCH_SRCDIRS}
+.for P in ${CRUNCH_PROGS_${D}}
+${OUTPUTS}: ${CRUNCH_SRCDIR_${P}}/Makefile
.if ${CRUNCH_GENERATE_LINKS} == "yes"
.ifndef CRUNCH_SUPPRESS_LINK_${P}
-LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(P)
+LINKS+= ${BINDIR}/${PROG} ${BINDIR}/${P}
.endif
-.for A in $(CRUNCH_ALIAS_$(P))
+.for A in ${CRUNCH_ALIAS_${P}}
.ifndef CRUNCH_SUPPRESS_LINK_${A}
-LINKS+= $(BINDIR)/$(PROG) $(BINDIR)/$(A)
+LINKS+= ${BINDIR}/${PROG} ${BINDIR}/${A}
.endif
.endfor
.endif
.endfor
.endfor
-all: $(PROG)
-exe: $(PROG)
+all: ${PROG}
+exe: ${PROG}
-$(CONF): Makefile
- echo \# Auto-generated, do not edit >$(.TARGET)
+${CONF}: Makefile
+ echo \# Auto-generated, do not edit >${.TARGET}
.ifdef CRUNCH_BUILDOPTS
- echo buildopts $(CRUNCH_BUILDOPTS) >>$(.TARGET)
+ echo buildopts ${CRUNCH_BUILDOPTS} >>${.TARGET}
.endif
.ifdef CRUNCH_LIBS
- echo libs $(CRUNCH_LIBS) >>$(.TARGET)
+ echo libs ${CRUNCH_LIBS} >>${.TARGET}
.endif
.ifdef CRUNCH_SHLIBS
- echo libs_so $(CRUNCH_SHLIBS) >>$(.TARGET)
-.endif
-.for D in $(CRUNCH_SRCDIRS)
-.for P in $(CRUNCH_PROGS_$(D))
- echo progs $(P) >>$(.TARGET)
-.ifdef CRUNCH_SRCDIR_${P}
- echo special $(P) srcdir $(CRUNCH_SRCDIR_${P}) >>$(.TARGET)
-.else
- echo special $(P) srcdir $(.CURDIR)/../../$(D)/$(P) >>$(.TARGET)
+ echo libs_so ${CRUNCH_SHLIBS} >>${.TARGET}
.endif
+.for D in ${CRUNCH_SRCDIRS}
+.for P in ${CRUNCH_PROGS_${D}}
+ echo progs ${P} >>${.TARGET}
+ echo special ${P} srcdir ${CRUNCH_SRCDIR_${P}} >>${.TARGET}
.ifdef CRUNCH_BUILDOPTS_${P}
- echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ \
- $(CRUNCH_BUILDOPTS_${P}) >>$(.TARGET)
+ echo special ${P} buildopts DIRPRFX=${DIRPRFX}${P}/ \
+ ${CRUNCH_BUILDOPTS_${P}} >>${.TARGET}
.else
- echo special $(P) buildopts DIRPRFX=${DIRPRFX}${P}/ >>$(.TARGET)
+ echo special ${P} buildopts DIRPRFX=${DIRPRFX}${P}/ >>${.TARGET}
.endif
-.for A in $(CRUNCH_ALIAS_$(P))
- echo ln $(P) $(A) >>$(.TARGET)
+.for A in ${CRUNCH_ALIAS_${P}}
+ echo ln ${P} ${A} >>${.TARGET}
.endfor
.endfor
.endfor
CRUNCHGEN?= crunchgen
-# XXX Make sure we don't pass -P to crunchgen(1).
-.MAKEFLAGS:= ${.MAKEFLAGS:N-P}
-.ORDER: $(OUTPUTS) objs
-$(OUTPUTS): $(CONF) .META
- MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${CRUNCHGEN} -fq -m $(OUTMK) \
- -c $(OUTC) $(CONF)
+CRUNCHENV?= MK_TESTS=no
+.ORDER: ${OUTPUTS} objs
+${OUTPUTS}: ${CONF} .META
+ MAKE=${MAKE} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${CRUNCHGEN} -fq \
+ -m ${OUTMK} -c ${OUTC} ${CONF}
-$(PROG): $(OUTPUTS) objs
- MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) exe
+# These 2 targets cannot use .MAKE since they depend on the generated
+# ${OUTMK} above.
+${PROG}: ${OUTPUTS} objs
+ ${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f ${OUTMK} exe
-objs: $(OUTMK)
- MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) objs
+objs: ${OUTMK}
+ ${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f ${OUTMK} objs
# <sigh> Someone should replace the bin/csh and bin/sh build-tools with
# shell scripts so we can remove this nonsense.
-build-tools:
-.for _tool in $(CRUNCH_BUILDTOOLS)
- cd $(.CURDIR)/../../${_tool}; \
- MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
- MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
+.for _tool in ${CRUNCH_BUILDTOOLS}
+build-tools-${_tool}:
+ ${_+_}cd ${.CURDIR}/../../${_tool}; \
+ ${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} obj; \
+ ${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} build-tools
+build-tools: build-tools-${_tool}
.endfor
# Use a separate build tree to hold files compiled for this crunchgen binary
# Yes, this does seem to partly duplicate bsd.subdir.mk, but I can't
# get that to cooperate with bsd.prog.mk. Besides, many of the standard
# targets should NOT be propagated into the components.
-cleandepend cleandir obj objlink:
-.for D in $(CRUNCH_SRCDIRS)
-.for P in $(CRUNCH_PROGS_$(D))
-.ifdef CRUNCH_SRCDIR_${P}
- cd ${CRUNCH_SRCDIR_$(P)} && \
- MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
- DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
-.else
- cd $(.CURDIR)/../../${D}/${P} && \
- MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
- DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
-.endif
+.for __target in clean cleandepend cleandir obj objlink
+.for D in ${CRUNCH_SRCDIRS}
+.for P in ${CRUNCH_PROGS_${D}}
+${__target}_crunchdir_${P}: .PHONY .MAKE
+ ${_+_}cd ${CRUNCH_SRCDIR_${P}} && \
+ ${CRUNCHENV} MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
+ DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${__target}
+${__target}: ${__target}_crunchdir_${P}
+.endfor
.endfor
.endfor
clean:
rm -f ${CLEANFILES}
- if [ -e ${.OBJDIR}/$(OUTMK) ]; then \
- MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} -f $(OUTMK) clean; \
+ ${_+_}if [ -e ${.OBJDIR}/${OUTMK} ]; then \
+ ${CRUNCHENV} MAKEOBJDIRPREFIX=${CRUNCHOBJS} ${MAKE} \
+ -f ${OUTMK} clean; \
fi
-.for D in $(CRUNCH_SRCDIRS)
-.for P in $(CRUNCH_PROGS_$(D))
-.ifdef CRUNCH_SRCDIR_${P}
- cd ${CRUNCH_SRCDIR_$(P)} && \
- MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
- DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
-.else
- cd $(.CURDIR)/../../${D}/${P} && \
- MAKEOBJDIRPREFIX=${CANONICALOBJDIR} ${MAKE} \
- DIRPRFX=${DIRPRFX}${P}/ ${CRUNCH_BUILDOPTS} ${.TARGET}
-.endif
-.endfor
-.endfor
diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk
index 6a6c66a..17a99d2 100644
--- a/share/mk/bsd.files.mk
+++ b/share/mk/bsd.files.mk
@@ -30,13 +30,12 @@ ${group}DIR?= ${BINDIR}
STAGE_SETS+= ${group}
.endif
STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
-STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP}
_${group}FILES=
.for file in ${${group}}
.if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \
- defined(${group}NAME_${file:T})
+ defined(${group}NAME_${file:T}) || defined(${group}NAME)
${group}OWN_${file:T}?= ${${group}OWN}
${group}GRP_${file:T}?= ${${group}GRP}
${group}MODE_${file:T}?= ${${group}MODE}
diff --git a/share/mk/bsd.man.mk b/share/mk/bsd.man.mk
index 72aedfb..d0992b6 100644
--- a/share/mk/bsd.man.mk
+++ b/share/mk/bsd.man.mk
@@ -104,8 +104,8 @@ ${__target}: ${__page}
.endfor
.endif
.endfor
-.endif
-.else
+.endif # !empty(MAN)
+.else # !defined(MANFILTER)
.if defined(MAN) && !empty(MAN)
CLEANFILES+= ${MAN:T:S/$/${CATEXT}/g}
.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
@@ -120,9 +120,9 @@ ${__target}: ${__page}
_manpages: ${MAN}
.endif
.endif
-.endif
+.endif # defined(MANFILTER)
-.else
+.else # ${MK_MANCOMPRESS} == "yes"
ZEXT= ${MCOMPRESS_EXT}
@@ -169,7 +169,7 @@ ${__target}: ${__page}
.endfor
.endif
-.endif
+.endif # ${MK_MANCOMPRESS} == "no"
maninstall: _maninstall
_maninstall:
@@ -185,20 +185,26 @@ _maninstall: ${MAN}
${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page}
.endif
.endfor
-.else
-.for _page _sect in ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}
- @d=${DESTDIR}${MANDIR}${_sect}${MANSUBDIR}/; \
- ${ECHO} ${MINSTALL} ${_page} $${d}; \
- ${MINSTALL} $${page} $${d};
-.endfor
+.else # !defined(MANFILTER)
+ @set ${.ALLSRC:C/\.([^.]*)$/.\1 \1/}; \
+ while : ; do \
+ case $$# in \
+ 0) break;; \
+ 1) echo "warn: missing extension: $$1"; break;; \
+ esac; \
+ page=$$1; shift; sect=$$1; shift; \
+ d=${DESTDIR}${MANDIR}$${sect}${MANSUBDIR}; \
+ ${ECHO} ${MINSTALL} $${page} $${d}; \
+ ${MINSTALL} $${page} $${d}; \
+ done
.if defined(MANBUILDCAT) && !empty(MANBUILDCAT)
.for __page in ${MAN}
${MINSTALL} ${__page:T:S/$/${CATEXT}/} \
${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T}
.endfor
.endif
-.endif
-.else
+.endif # defined(MANFILTER)
+.else # ${MK_MANCOMPRESS} == "yes"
.for __page in ${MAN}
${MINSTALL} ${__page:T:S/$/${MCOMPRESS_EXT}/g} \
${DESTDIR}${MANDIR}${__page:E}${MANSUBDIR}/
@@ -207,7 +213,7 @@ _maninstall: ${MAN}
${DESTDIR}${CATDIR}${__page:E}${MANSUBDIR}/${__page:T:S/$/${MCOMPRESS_EXT}/}
.endif
.endfor
-.endif
+.endif # ${MK_MANCOMPRESS} == "no"
.endif
.if !defined(NO_MLINKS) && defined(MLINKS) && !empty(MLINKS)
diff --git a/share/mk/bsd.progs.mk b/share/mk/bsd.progs.mk
index 2da30c7..c84e94b 100644
--- a/share/mk/bsd.progs.mk
+++ b/share/mk/bsd.progs.mk
@@ -31,7 +31,7 @@ UPDATE_DEPENDFILE_PROG = ${PROGS:[1]}
# They may have asked us to build just one
.for t in ${PROGS}
.if make($t)
-.if ${PROGS_CXX:M${t}}
+.if ${PROGS_CXX:U:M${t}}
PROG_CXX ?= $t
.endif
PROG ?= $t
@@ -116,16 +116,16 @@ x.$p= PROG_CXX=$p
$p ${p}_p: .PHONY .MAKE
(cd ${.CURDIR} && \
DEPENDFILE=.depend.$p \
- ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
- SUBDIR= PROG=$p ${x.$p})
+ NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
+ 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 \
- ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
- SUBDIR= PROG=$p ${x.$p} ${@:E})
+ NO_SUBDIR=1 ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \
+ PROG=$p ${x.$p} ${@:E})
.endfor
.endfor
diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk
index 037a7fe..f9b9e97 100644
--- a/share/mk/bsd.subdir.mk
+++ b/share/mk/bsd.subdir.mk
@@ -28,6 +28,10 @@
# See ALL_SUBDIR_TARGETS for list of targets that will recurse.
# Custom targets can be added to SUBDIR_TARGETS in src.conf.
#
+# Targets defined in STANDALONE_SUBDIR_TARGETS will always be ran
+# with SUBDIR_PARALLEL and will not respect .WAIT or SUBDIR_DEPEND_
+# values.
+#
.if !target(__<bsd.subdir.mk>__)
__<bsd.subdir.mk>__:
@@ -38,6 +42,10 @@ ALL_SUBDIR_TARGETS= all all-man buildconfig checkdpadd clean cleandepend \
realinstall regress tags \
${SUBDIR_TARGETS}
+# Described above.
+STANDALONE_SUBDIR_TARGETS?= obj checkdpadd clean cleandepend cleandir \
+ cleanilinks cleanobj
+
.include <bsd.init.mk>
.if !defined(NEED_SUBDIR)
@@ -63,35 +71,37 @@ distribute: .MAKE
.endfor
.endif
-_SUBDIR: .USE .MAKE
-.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
- @${_+_}for entry in ${SUBDIR:N.WAIT}; do \
- if test -d ${.CURDIR}/$${entry}.${MACHINE_ARCH}; then \
- ${ECHODIR} "===> ${DIRPRFX}$${entry}.${MACHINE_ARCH} (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \
- edir=$${entry}.${MACHINE_ARCH}; \
- cd ${.CURDIR}/$${edir}; \
- else \
- ${ECHODIR} "===> ${DIRPRFX}$$entry (${.TARGET:S,realinstall,install,:S,^_sub.,,})"; \
- edir=$${entry}; \
- cd ${.CURDIR}/$${edir}; \
+# Subdir code shared among 'make <subdir>', 'make <target>' and SUBDIR_PARALLEL.
+_SUBDIR_SH= \
+ if test -d ${.CURDIR}/$${dir}.${MACHINE_ARCH}; then \
+ dir=$${dir}.${MACHINE_ARCH}; \
fi; \
- ${MAKE} ${.TARGET:S,realinstall,install,:S,^_sub.,,} \
- DIRPRFX=${DIRPRFX}$$edir/; \
- done
+ ${ECHODIR} "===> ${DIRPRFX}$${dir} ($${target})"; \
+ cd ${.CURDIR}/$${dir}; \
+ ${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/
+
+_SUBDIR: .USEBEFORE
+.if defined(SUBDIR) && !empty(SUBDIR) && !defined(NO_SUBDIR)
+ @${_+_}target=${.TARGET:S,realinstall,install,}; \
+ for dir in ${SUBDIR:N.WAIT}; do ( ${_SUBDIR_SH} ); done
.endif
${SUBDIR:N.WAIT}: .PHONY .MAKE
- ${_+_}@if test -d ${.TARGET}.${MACHINE_ARCH}; then \
- cd ${.CURDIR}/${.TARGET}.${MACHINE_ARCH}; \
- else \
- cd ${.CURDIR}/${.TARGET}; \
- fi; \
- ${MAKE} all
+ ${_+_}@target=all; \
+ dir=${.TARGET}; \
+ ${_SUBDIR_SH};
# Work around parsing of .if nested in .for by putting .WAIT string into a var.
__wait= .WAIT
.for __target in ${ALL_SUBDIR_TARGETS}
-.ifdef SUBDIR_PARALLEL
+# Can ordering be skipped for this and SUBDIR_PARALLEL forced?
+.if make(${__target}) && ${STANDALONE_SUBDIR_TARGETS:M${__target}}
+_is_standalone_target= 1
+SUBDIR:= ${SUBDIR:N.WAIT}
+.else
+_is_standalone_target= 0
+.endif
+.if defined(SUBDIR_PARALLEL) || ${_is_standalone_target} == 1
__subdir_targets=
.for __dir in ${SUBDIR}
.if ${__wait} == ${__dir}
@@ -99,31 +109,24 @@ __subdir_targets+= .WAIT
.else
__subdir_targets+= ${__target}_subdir_${__dir}
__deps=
+.if ${_is_standalone_target} == 0
.for __dep in ${SUBDIR_DEPEND_${__dir}}
__deps+= ${__target}_subdir_${__dep}
.endfor
-${__target}_subdir_${__dir}: .MAKE ${__deps}
+.endif
+${__target}_subdir_${__dir}: .PHONY .MAKE ${__deps}
.if !defined(NO_SUBDIR)
- @${_+_}if test -d ${.CURDIR}/${__dir}.${MACHINE_ARCH}; then \
- ${ECHODIR} "===> ${DIRPRFX}${__dir}.${MACHINE_ARCH} (${__target:realinstall=install})"; \
- edir=${__dir}.${MACHINE_ARCH}; \
- cd ${.CURDIR}/$${edir}; \
- else \
- ${ECHODIR} "===> ${DIRPRFX}${__dir} (${__target:realinstall=install})"; \
- edir=${__dir}; \
- cd ${.CURDIR}/$${edir}; \
- fi; \
- ${MAKE} ${__target:realinstall=install} \
- DIRPRFX=${DIRPRFX}$$edir/
+ @${_+_}target=${__target:realinstall=install}; \
+ dir=${__dir}; \
+ ${_SUBDIR_SH};
.endif
.endif
-.endfor
+.endfor # __dir in ${SUBDIR}
${__target}: ${__subdir_targets}
.else
-${__target}: _sub.${__target}
-_sub.${__target}: _SUBDIR
-.endif
-.endfor
+${__target}: _SUBDIR
+.endif # SUBDIR_PARALLEL || _is_standalone_target
+.endfor # __target in ${ALL_SUBDIR_TARGETS}
# This is to support 'make includes' calling 'make buildincludes' and
# 'make installincludes' in the proper order, and to support these
@@ -132,8 +135,7 @@ _sub.${__target}: _SUBDIR
.for __stage in build install
${__stage}${__target}:
.if make(${__stage}${__target})
-${__stage}${__target}: _sub.${__stage}${__target}
-_sub.${__stage}${__target}: _SUBDIR
+${__stage}${__target}: _SUBDIR
.endif
.endfor
.if !target(${__target})
diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk
index a5e78a3..7aca914 100644
--- a/share/mk/src.opts.mk
+++ b/share/mk/src.opts.mk
@@ -210,21 +210,22 @@ __TT=${MACHINE}
.endif
.include <bsd.compiler.mk>
-.if !${COMPILER_FEATURES:Mc++11}
-# If the compiler is not C++11 capable, disable clang and use gcc instead.
-__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
-__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
-.elif ${__T} == "aarch64" || ${__T} == "amd64" || ${__TT} == "arm" || \
- ${__T} == "i386"
-# On x86 and arm, clang is enabled, and will be installed as the default cc.
+# If the compiler is not C++11 capable, disable Clang and use GCC instead.
+# This means that architectures that have GCC 4.2 as default can not
+# build Clang without using an external compiler.
+
+.if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \
+ ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386")
+# Clang is enabled, and will be installed as the default /usr/bin/cc.
__DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
__DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
-.elif ${__T:Mpowerpc*}
-# On powerpc, clang is enabled, but gcc is installed as the default cc.
+.elif ${COMPILER_FEATURES:Mc++11} && ${__T:Mpowerpc*}
+# On powerpc, if an external compiler that supports C++11 is used as ${CC},
+# then Clang is enabled, but GCC is installed as the default /usr/bin/cc.
__DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL GCC GCC_BOOTSTRAP GNUCXX
__DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC
.else
-# Everything else disables clang, and uses gcc instead.
+# Everything else disables Clang, and uses GCC instead.
__DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
__DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
.endif
OpenPOWER on IntegriCloud