bsd.after-import.mk revision 236769
1# $Id: bsd.after-import.mk,v 1.3 2012/06/06 17:48:14 sjg Exp $ 2 3# This makefile is for use when integrating bmake into a BSD build 4# system. Use this makefile after importing bmake. 5# It will bootstrap the new version, 6# capture the generated files we need, and add an after-import 7# target to allow the process to be easily repeated. 8 9# The goal is to allow the benefits of autoconf without 10# the overhead of running configure. 11 12all: ${.CURDIR}/Makefile 13all: after-import 14 15# we rely on bmake 16_this := ${MAKEFILE:tA} 17BMAKE_SRC := ${.PARSEDIR} 18 19# it helps to know where the top of the tree is. 20.if !defined(SRCTOP) 21srctop := ${.MAKE.MAKEFILES:M*src/share/mk/sys.mk:H:H:H} 22.if !empty(srctop) 23SRCTOP := ${srctop} 24.endif 25.endif 26 27# This lets us match what boot-strap does 28.if !defined(HOST_OS) 29HOST_OS!= uname 30.endif 31 32# .../share/mk will find ${SRCTOP}/share/mk 33# if we are within ${SRCTOP} 34DEFAULT_SYS_PATH= .../share/mk:/usr/share/mk 35 36BOOTSTRAP_ARGS = \ 37 --with-default-sys-path='${DEFAULT_SYS_PATH}' \ 38 --prefix /usr \ 39 --share /usr/share \ 40 --mksrc none 41 42# run boot-strap with minimal influence 43bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE} 44 HOME=/ ${BMAKE_SRC}/boot-strap ${BOOTSTRAP_ARGS} ${BOOTSTRAP_XTRAS} 45 touch ${.TARGET} 46 47# Makefiles need a little more tweaking than say config.h 48MAKEFILE_SED = sed -e '/^MACHINE/d' \ 49 -e '/^PROG/s,bmake,${.CURDIR:T},' \ 50 -e 's,${SRCTOP},$${SRCTOP},g' 51 52# These are the simple files we want to capture 53configured_files= config.h unit-tests/Makefile 54 55after-import: bootstrap ${MAKEFILE} 56.for f in ${configured_files:N*Makefile} 57 @echo Capturing $f 58 @cmp -s ${.CURDIR}/$f ${HOST_OS}/$f || \ 59 cp ${HOST_OS}/$f ${.CURDIR}/$f 60.endfor 61.for f in ${configured_files:M*Makefile} 62 @echo Capturing $f 63 @${MAKEFILE_SED} ${HOST_OS}/$f > ${.CURDIR}/$f 64.endfor 65 66# this needs the most work 67${.CURDIR}/Makefile: bootstrap ${MAKEFILE} .PRECIOUS 68 @echo Generating ${.TARGET:T} 69 @(echo '# This is a generated file, do NOT edit!'; \ 70 echo '# See ${_this:S,${SRCTOP}/,,}'; \ 71 echo; echo '# look here first for config.h'; \ 72 echo 'CFLAGS+= -I$${.CURDIR}'; echo; \ 73 ${MAKEFILE_SED} ${HOST_OS}/Makefile; \ 74 echo; echo '# override some simple things'; \ 75 echo 'BINDIR= /usr/bin'; \ 76 echo 'MANDIR= /usr/share/man'; \ 77 echo; echo '# make sure we get this'; \ 78 echo 'CFLAGS+= $${COPTS.$${.IMPSRC:T}}'; \ 79 echo 'CLEANFILES+= bootstrap'; \ 80 echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \ 81 echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \ 82 echo; echo '.-include "Makefile.inc"'; \ 83 echo ) > ${.TARGET:T}.new 84 @mv ${.TARGET:T}.new ${.TARGET} 85 86.include <bsd.obj.mk> 87 88