2012-06-25 22:20:51 +00:00
|
|
|
# $Id: bsd.after-import.mk,v 1.5 2012/06/20 22:45:07 sjg Exp $
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
# 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: ${.CURDIR}/Makefile
|
|
|
|
all: after-import
|
|
|
|
|
|
|
|
# we rely on bmake
|
2012-06-25 22:20:51 +00:00
|
|
|
.if !defined(.MAKE.LEVEL)
|
|
|
|
.error this makefile requires bmake
|
|
|
|
.endif
|
|
|
|
|
2012-06-08 21:57:36 +00:00
|
|
|
_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}
|
2012-06-25 22:20:51 +00:00
|
|
|
.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
|
2012-06-08 21:57:36 +00:00
|
|
|
.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 \
|
|
|
|
--mksrc none
|
|
|
|
|
|
|
|
# run boot-strap with minimal influence
|
|
|
|
bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE}
|
|
|
|
HOME=/ ${BMAKE_SRC}/boot-strap ${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,bmake,${.CURDIR:T},' \
|
2012-06-25 22:20:51 +00:00
|
|
|
-e 's,^.-include,.sinclude,' \
|
2012-06-08 21:57:36 +00:00
|
|
|
-e 's,${SRCTOP},$${SRCTOP},g'
|
|
|
|
|
|
|
|
# These are the simple files we want to capture
|
|
|
|
configured_files= config.h unit-tests/Makefile
|
|
|
|
|
|
|
|
after-import: bootstrap ${MAKEFILE}
|
|
|
|
.for f in ${configured_files:N*Makefile}
|
|
|
|
@echo Capturing $f
|
2012-06-25 22:20:51 +00:00
|
|
|
@mkdir -p ${${.CURDIR}/$f:L:H}
|
2012-06-08 21:57:36 +00:00
|
|
|
@cmp -s ${.CURDIR}/$f ${HOST_OS}/$f || \
|
|
|
|
cp ${HOST_OS}/$f ${.CURDIR}/$f
|
|
|
|
.endfor
|
|
|
|
.for f in ${configured_files:M*Makefile}
|
|
|
|
@echo Capturing $f
|
2012-06-25 22:20:51 +00:00
|
|
|
@mkdir -p ${${.CURDIR}/$f:L:H}
|
2012-06-08 21:57:36 +00:00
|
|
|
@${MAKEFILE_SED} ${HOST_OS}/$f > ${.CURDIR}/$f
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
# this needs the most work
|
|
|
|
${.CURDIR}/Makefile: bootstrap ${MAKEFILE} .PRECIOUS
|
|
|
|
@echo Generating ${.TARGET:T}
|
|
|
|
@(echo '# This is a generated file, do NOT edit!'; \
|
|
|
|
echo '# See ${_this:S,${SRCTOP}/,,}'; \
|
2012-06-25 22:20:51 +00:00
|
|
|
echo '#'; echo '# $$${OS}$$'; echo; \
|
|
|
|
echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \
|
2012-06-08 21:57:36 +00:00
|
|
|
echo; echo '# look here first for config.h'; \
|
|
|
|
echo 'CFLAGS+= -I$${.CURDIR}'; echo; \
|
|
|
|
${MAKEFILE_SED} ${HOST_OS}/Makefile; \
|
|
|
|
echo; echo '# override some simple things'; \
|
|
|
|
echo 'BINDIR= /usr/bin'; \
|
|
|
|
echo 'MANDIR= /usr/share/man'; \
|
|
|
|
echo; echo '# make sure we get this'; \
|
|
|
|
echo 'CFLAGS+= $${COPTS.$${.IMPSRC:T}}'; \
|
|
|
|
echo 'CLEANFILES+= bootstrap'; \
|
|
|
|
echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \
|
|
|
|
echo ' cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \
|
2012-06-25 22:20:51 +00:00
|
|
|
echo; echo '.sinclude "Makefile.inc"'; \
|
2012-06-08 21:57:36 +00:00
|
|
|
echo ) > ${.TARGET:T}.new
|
|
|
|
@mv ${.TARGET:T}.new ${.TARGET}
|
|
|
|
|
|
|
|
.include <bsd.obj.mk>
|
|
|
|
|