aboutsummaryrefslogtreecommitdiffstats
path: root/bsd.after-import.mk
diff options
context:
space:
mode:
Diffstat (limited to 'bsd.after-import.mk')
-rw-r--r--bsd.after-import.mk21
1 files changed, 19 insertions, 2 deletions
diff --git a/bsd.after-import.mk b/bsd.after-import.mk
index eeb397c5ff49..255a24c68607 100644
--- a/bsd.after-import.mk
+++ b/bsd.after-import.mk
@@ -1,4 +1,4 @@
-# $Id: bsd.after-import.mk,v 1.3 2012/06/06 17:48:14 sjg Exp $
+# $Id: bsd.after-import.mk,v 1.5 2012/06/20 22:45:07 sjg Exp $
# This makefile is for use when integrating bmake into a BSD build
# system. Use this makefile after importing bmake.
@@ -13,12 +13,24 @@ all: ${.CURDIR}/Makefile
all: after-import
# we rely on bmake
+.if !defined(.MAKE.LEVEL)
+.error this makefile requires bmake
+.endif
+
_this := ${MAKEFILE:tA}
BMAKE_SRC := ${.PARSEDIR}
# it helps to know where the top of the tree is.
.if !defined(SRCTOP)
srctop := ${.MAKE.MAKEFILES:M*src/share/mk/sys.mk:H:H:H}
+.if empty(srctop)
+# likely locations?
+.for d in contrib/bmake external/bsd/bmake/dist
+.if ${BMAKE_SRC:M*/$d} != ""
+srctop := ${BMAKE_SRC:tA:S,/$d,,}
+.endif
+.endfor
+.endif
.if !empty(srctop)
SRCTOP := ${srctop}
.endif
@@ -47,6 +59,7 @@ bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE}
# Makefiles need a little more tweaking than say config.h
MAKEFILE_SED = sed -e '/^MACHINE/d' \
-e '/^PROG/s,bmake,${.CURDIR:T},' \
+ -e 's,^.-include,.sinclude,' \
-e 's,${SRCTOP},$${SRCTOP},g'
# These are the simple files we want to capture
@@ -55,11 +68,13 @@ configured_files= config.h unit-tests/Makefile
after-import: bootstrap ${MAKEFILE}
.for f in ${configured_files:N*Makefile}
@echo Capturing $f
+ @mkdir -p ${${.CURDIR}/$f:L:H}
@cmp -s ${.CURDIR}/$f ${HOST_OS}/$f || \
cp ${HOST_OS}/$f ${.CURDIR}/$f
.endfor
.for f in ${configured_files:M*Makefile}
@echo Capturing $f
+ @mkdir -p ${${.CURDIR}/$f:L:H}
@${MAKEFILE_SED} ${HOST_OS}/$f > ${.CURDIR}/$f
.endfor
@@ -68,6 +83,8 @@ ${.CURDIR}/Makefile: bootstrap ${MAKEFILE} .PRECIOUS
@echo Generating ${.TARGET:T}
@(echo '# This is a generated file, do NOT edit!'; \
echo '# See ${_this:S,${SRCTOP}/,,}'; \
+ echo '#'; echo '# $$${OS}$$'; echo; \
+ echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \
echo; echo '# look here first for config.h'; \
echo 'CFLAGS+= -I$${.CURDIR}'; echo; \
${MAKEFILE_SED} ${HOST_OS}/Makefile; \
@@ -79,7 +96,7 @@ ${.CURDIR}/Makefile: bootstrap ${MAKEFILE} .PRECIOUS
echo 'CLEANFILES+= bootstrap'; \
echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \
echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \
- echo; echo '.-include "Makefile.inc"'; \
+ echo; echo '.sinclude "Makefile.inc"'; \
echo ) > ${.TARGET:T}.new
@mv ${.TARGET:T}.new ${.TARGET}