diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-04-01 14:07:52 +0000 |
---|---|---|
committer | <> | 2013-05-17 14:06:43 +0000 |
commit | 986bc2ac05bc4c08c6a0ed30c9e97674932ccfeb (patch) | |
tree | 8346daf16e98e93415195acbf99f09cb5326b73b /bsd.after-import.mk | |
download | bmake-tarball-986bc2ac05bc4c08c6a0ed30c9e97674932ccfeb.tar.gz |
Diffstat (limited to 'bsd.after-import.mk')
-rw-r--r-- | bsd.after-import.mk | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/bsd.after-import.mk b/bsd.after-import.mk new file mode 100644 index 0000000..85bd2c1 --- /dev/null +++ b/bsd.after-import.mk @@ -0,0 +1,113 @@ +# $Id: bsd.after-import.mk,v 1.11 2012/12/29 19:32:25 sjg Exp $ + +# This makefile is for use when integrating bmake into a BSD build +# system. Use this makefile after importing bmake. +# It will bootstrap the new version, +# capture the generated files we need, and add an after-import +# target to allow the process to be easily repeated. + +# The goal is to allow the benefits of autoconf without +# the overhead of running configure. + +all: _makefile +all: after-import + +# we rely on bmake +.if !defined(.PARSEDIR) +.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 +.endif + +# This lets us match what boot-strap does +.if !defined(HOST_OS) +HOST_OS!= uname +.endif + +# .../share/mk will find ${SRCTOP}/share/mk +# if we are within ${SRCTOP} +DEFAULT_SYS_PATH= .../share/mk:/usr/share/mk + +BOOTSTRAP_ARGS = \ + --with-default-sys-path='${DEFAULT_SYS_PATH}' \ + --prefix /usr \ + --share /usr/share + + +# run boot-strap with minimal influence +bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE} + HOME=/ ${BMAKE_SRC}/boot-strap -o ${HOST_OS} ${BOOTSTRAP_ARGS} ${BOOTSTRAP_XTRAS} + touch ${.TARGET} + +# Makefiles need a little more tweaking than say config.h +MAKEFILE_SED = sed -e '/^MACHINE/d' \ + -e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \ + -e 's,^.-include,.sinclude,' \ + -e '/^\..*include *</ { s,<,<bsd.,;/autoconf/d; }' \ + -e 's,${SRCTOP},$${SRCTOP},g' + +# These are the simple files we want to capture +configured_files= config.h Makefile.config unit-tests/Makefile + +after-import: bootstrap ${MAKEFILE} +.for f in ${configured_files:M*.[ch]} + @echo Capturing $f + @mkdir -p ${${.CURDIR}/$f:L:H} + @(echo '/* $$${HOST_OS}$$ */'; cat ${HOST_OS}/$f) > ${.CURDIR}/$f +.endfor +.for f in ${configured_files:M*Makefile*} + @echo Capturing $f + @mkdir -p ${${.CURDIR}/$f:L:H} + @(echo '# This is a generated file, do NOT edit!'; \ + echo '# See ${_this:S,${SRCTOP}/,,}'; \ + echo '#'; echo '# $$${HOST_OS}$$'; echo; \ + echo 'SRCTOP?= $${.CURDIR:${${.CURDIR}/$f:L:H:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \ + ${MAKEFILE_SED} ${HOST_OS}/$f ) > ${.CURDIR}/$f +.endfor + +# this needs the most work +_makefile: bootstrap ${MAKEFILE} + @echo Generating ${.CURDIR}/Makefile + @(echo '# This is a generated file, do NOT edit!'; \ + echo '# See ${_this:S,${SRCTOP}/,,}'; \ + echo '#'; echo '# $$${HOST_OS}$$'; \ + echo; echo '.sinclude "Makefile.inc"'; \ + echo; echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \ + echo; echo '# look here first for config.h'; \ + echo 'CFLAGS+= -I$${.CURDIR}'; echo; \ + echo '# for after-import'; \ + echo 'CLEANDIRS+= ${HOST_OS}'; \ + echo 'CLEANFILES+= bootstrap'; echo; \ + ${MAKEFILE_SED} \ + ${1 2:L:@n@-e '/start-delete$n/,/end-delete$n/d'@} \ + ${BMAKE_SRC}/Makefile; \ + echo; echo '# override some simple things'; \ + echo 'BINDIR= /usr/bin'; \ + echo 'MANDIR= ${MANDIR:U/usr/share/man}'; \ + echo; echo '# make sure we get this'; \ + echo 'CFLAGS+= $${COPTS.$${.IMPSRC:T}}'; \ + echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \ + echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \ + echo ) > ${.TARGET} + @cmp -s ${.TARGET} ${.CURDIR}/Makefile || \ + mv ${.TARGET} ${.CURDIR}/Makefile + +.include <bsd.obj.mk> + |