aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile61
1 files changed, 43 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 653d7f608bb3..c49a1dd5eac2 100644
--- a/Makefile
+++ b/Makefile
@@ -130,11 +130,34 @@ _MAKEOBJDIRPREFIX!= /usr/bin/env -i PATH=${PATH} ${MAKE} \
.error MAKEOBJDIRPREFIX can only be set in environment, not as a global\
(in make.conf(5)) or command-line variable.
.endif
-MAKEPATH= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}
-BINMAKE= \
- `if [ -x ${MAKEPATH}/make ]; then echo ${MAKEPATH}/make; else echo ${MAKE}; fi` \
+
+# We often need to use the tree's version of make to build it.
+# Choices add to complexity though.
+# We cannot blindly use a make which may not be the one we want
+# so be exlicit - until all choice is removed.
+.if !defined(WITHOUT_BMAKE)
+WANT_MAKE= bmake
+.else
+WANT_MAKE= fmake
+.endif
+MYMAKE= ${MAKEOBJDIRPREFIX}${.CURDIR}/make.${MACHINE}/${WANT_MAKE}
+.if defined(.PARSEDIR)
+HAVE_MAKE= bmake
+.else
+HAVE_MAKE= fmake
+.endif
+.if exists(${MYMAKE})
+SUB_MAKE:= ${MYMAKE} -m ${.CURDIR}/share/mk
+.elif ${WANT_MAKE} != ${HAVE_MAKE} || ${WANT_MAKE} != "bmake"
+# It may not exist yet but we may cause it to.
+# In the case of fmake, upgrade_checks may cause a newer version to be built.
+SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
-m ${.CURDIR}/share/mk
-_MAKE= PATH=${PATH} ${BINMAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
+.else
+SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
+.endif
+
+_MAKE= PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
# Guess machine architecture from machine type, and vice versa.
.if !defined(TARGET_ARCH) && defined(TARGET)
@@ -291,11 +314,13 @@ kernel: buildkernel installkernel
# Perform a few tests to determine if the installed tools are adequate
# for building the world.
#
+# Note: if we ever need to care about the version of bmake, simply testing
+# MAKE_VERSION against a required version should suffice.
+#
upgrade_checks:
-.if !defined(.PARSEDIR)
-.if !defined(WITHOUT_BMAKE)
- (cd ${.CURDIR} && ${MAKE} bmake)
-.else
+.if ${HAVE_MAKE} != ${WANT_MAKE}
+ @(cd ${.CURDIR} && ${MAKE} ${WANT_MAKE:S,^f,,})
+.elif ${WANT_MAKE} == "fmake"
@if ! (cd ${.CURDIR}/tools/build/make_check && \
PATH=${PATH} ${BINMAKE} obj >/dev/null 2>&1 && \
PATH=${PATH} ${BINMAKE} >/dev/null 2>&1); \
@@ -303,14 +328,13 @@ upgrade_checks:
(cd ${.CURDIR} && ${MAKE} make); \
fi
.endif
-.endif
#
# Upgrade make(1) to the current version using the installed
# headers, libraries and tools. Also, allow the location of
# the system bsdmake-like utility to be overridden.
#
-MMAKEENV= MAKEOBJDIRPREFIX=${MAKEPATH} \
+MMAKEENV= MAKEOBJDIRPREFIX=${MYMAKE:H} \
DESTDIR= \
INSTALL="sh ${.CURDIR}/tools/install.sh"
MMAKE= ${MMAKEENV} ${MAKE} \
@@ -327,7 +351,7 @@ make bmake: .PHONY
${MMAKE} obj && \
${MMAKE} depend && \
${MMAKE} all && \
- ${MMAKE} install DESTDIR=${MAKEPATH} BINDIR=
+ ${MMAKE} install DESTDIR=${MYMAKE:H} BINDIR= PROGNAME=${MYMAKE:T}
tinderbox:
@cd ${.CURDIR} && ${MAKE} DOING_TINDERBOX=YES universe
@@ -377,7 +401,8 @@ MAKEFAIL=tee -a ${FAILFILE}
MAKEFAIL=cat
.endif
-universe: universe_prologue upgrade_checks
+universe_prologue: upgrade_checks
+universe: universe_prologue
universe_prologue:
@echo "--------------------------------------------------------------"
@echo ">>> make universe started on ${STARTTIME}"
@@ -387,9 +412,9 @@ universe_prologue:
.endif
.for target in ${TARGETS}
universe: universe_${target}
-.ORDER: universe_prologue upgrade_checks universe_${target} universe_epilogue
+universe_epilogue: universe_${target}
universe_${target}: universe_${target}_prologue
-universe_${target}_prologue:
+universe_${target}_prologue: universe_prologue
@echo ">> ${target} started on `LC_ALL=C date`"
.if !defined(MAKE_JUST_KERNELS)
.for target_arch in ${TARGET_ARCHES_${target}}
@@ -397,7 +422,7 @@ universe_${target}: universe_${target}_${target_arch}
universe_${target}_${target_arch}: universe_${target}_prologue
@echo ">> ${target}.${target_arch} ${UNIVERSE_TARGET} started on `LC_ALL=C date`"
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
- ${MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
+ ${SUB_MAKE} ${JFLAG} ${UNIVERSE_TARGET} \
TARGET=${target} \
TARGET_ARCH=${target_arch} \
> _.${target}.${target_arch}.${UNIVERSE_TARGET} 2>&1 || \
@@ -418,11 +443,11 @@ universe_${target}: universe_${target}_kernels
universe_${target}_kernels: universe_${target}_prologue
.if exists(${KERNSRCDIR}/${target}/conf/NOTES)
@(cd ${KERNSRCDIR}/${target}/conf && env __MAKE_CONF=/dev/null \
- ${MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
+ ${SUB_MAKE} LINT > ${.CURDIR}/_.${target}.makeLINT 2>&1 || \
(echo "${target} 'make LINT' failed," \
"check _.${target}.makeLINT for details"| ${MAKEFAIL}))
.endif
- @cd ${.CURDIR} && ${MAKE} ${.MAKEFLAGS} TARGET=${target} \
+ @cd ${.CURDIR} && ${SUB_MAKE} ${.MAKEFLAGS} TARGET=${target} \
universe_kernels
.endif
@echo ">> ${target} completed on `LC_ALL=C date`"
@@ -445,7 +470,7 @@ TARGET_ARCH_${kernel}!= cd ${KERNSRCDIR}/${TARGET}/conf && \
universe_kernconfs: universe_kernconf_${TARGET}_${kernel}
universe_kernconf_${TARGET}_${kernel}:
@(cd ${.CURDIR} && env __MAKE_CONF=/dev/null \
- ${MAKE} ${JFLAG} buildkernel \
+ ${SUB_MAKE} ${JFLAG} buildkernel \
TARGET=${TARGET} \
TARGET_ARCH=${TARGET_ARCH_${kernel}} \
KERNCONF=${kernel} \