2017-11-01 23:16:32 +00:00
|
|
|
# $Id: bsd.after-import.mk,v 1.13 2017/08/13 00:56:10 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.
|
|
|
|
|
2012-07-06 00:03:45 +00:00
|
|
|
all: _makefile
|
2012-06-08 21:57:36 +00:00
|
|
|
all: after-import
|
|
|
|
|
|
|
|
# we rely on bmake
|
2012-09-11 02:56:02 +00:00
|
|
|
.if !defined(.PARSEDIR)
|
2012-06-25 22:20:51 +00:00
|
|
|
.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
|
|
|
|
|
|
|
|
BOOTSTRAP_ARGS = \
|
|
|
|
--prefix /usr \
|
2013-01-31 16:44:23 +00:00
|
|
|
--share /usr/share
|
|
|
|
|
2014-07-02 21:24:54 +00:00
|
|
|
.if !empty(DEFAULT_SYS_PATH)
|
|
|
|
BOOTSTRAP_ARGS += --with-default-sys-path='${DEFAULT_SYS_PATH}'
|
|
|
|
.endif
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
# run boot-strap with minimal influence
|
|
|
|
bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE}
|
2013-01-31 16:44:23 +00:00
|
|
|
HOME=/ ${BMAKE_SRC}/boot-strap -o ${HOST_OS} ${BOOTSTRAP_ARGS} ${BOOTSTRAP_XTRAS}
|
2012-06-08 21:57:36 +00:00
|
|
|
touch ${.TARGET}
|
|
|
|
|
|
|
|
# Makefiles need a little more tweaking than say config.h
|
|
|
|
MAKEFILE_SED = sed -e '/^MACHINE/d' \
|
2017-11-01 23:16:32 +00:00
|
|
|
-e '/include.*VERSION/d' \
|
2012-10-25 20:31:22 +00:00
|
|
|
-e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \
|
2012-06-25 22:20:51 +00:00
|
|
|
-e 's,^.-include,.sinclude,' \
|
2013-01-31 16:44:23 +00:00
|
|
|
-e '/^\..*include *</ { s,<,<bsd.,;/autoconf/d; }' \
|
2012-06-08 21:57:36 +00:00
|
|
|
-e 's,${SRCTOP},$${SRCTOP},g'
|
|
|
|
|
|
|
|
# These are the simple files we want to capture
|
2013-01-31 16:44:23 +00:00
|
|
|
configured_files= config.h Makefile.config unit-tests/Makefile
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
after-import: bootstrap ${MAKEFILE}
|
2013-01-31 16:44:23 +00:00
|
|
|
.for f in ${configured_files:M*.[ch]}
|
2012-06-08 21:57:36 +00:00
|
|
|
@echo Capturing $f
|
2012-06-25 22:20:51 +00:00
|
|
|
@mkdir -p ${${.CURDIR}/$f:L:H}
|
2013-01-31 16:44:23 +00:00
|
|
|
@(echo '/* $$${HOST_OS}$$ */'; cat ${HOST_OS}/$f) > ${.CURDIR}/$f
|
2012-06-08 21:57:36 +00:00
|
|
|
.endfor
|
2013-01-31 16:44:23 +00:00
|
|
|
.for f in ${configured_files:M*Makefile*}
|
2012-06-08 21:57:36 +00:00
|
|
|
@echo Capturing $f
|
2012-06-25 22:20:51 +00:00
|
|
|
@mkdir -p ${${.CURDIR}/$f:L:H}
|
2012-09-11 02:56:02 +00:00
|
|
|
@(echo '# This is a generated file, do NOT edit!'; \
|
|
|
|
echo '# See ${_this:S,${SRCTOP}/,,}'; \
|
2013-01-31 16:44:23 +00:00
|
|
|
echo '#'; echo '# $$${HOST_OS}$$'; echo; \
|
2012-09-11 02:56:02 +00:00
|
|
|
echo 'SRCTOP?= $${.CURDIR:${${.CURDIR}/$f:L:H:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \
|
|
|
|
${MAKEFILE_SED} ${HOST_OS}/$f ) > ${.CURDIR}/$f
|
2012-06-08 21:57:36 +00:00
|
|
|
.endfor
|
|
|
|
|
|
|
|
# this needs the most work
|
2012-07-06 00:03:45 +00:00
|
|
|
_makefile: bootstrap ${MAKEFILE}
|
|
|
|
@echo Generating ${.CURDIR}/Makefile
|
2012-06-08 21:57:36 +00:00
|
|
|
@(echo '# This is a generated file, do NOT edit!'; \
|
|
|
|
echo '# See ${_this:S,${SRCTOP}/,,}'; \
|
2013-01-31 16:44:23 +00:00
|
|
|
echo '#'; echo '# $$${HOST_OS}$$'; \
|
2012-10-25 20:31:22 +00:00
|
|
|
echo; echo '.sinclude "Makefile.inc"'; \
|
|
|
|
echo; echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \
|
2012-06-08 21:57:36 +00:00
|
|
|
echo; echo '# look here first for config.h'; \
|
|
|
|
echo 'CFLAGS+= -I$${.CURDIR}'; echo; \
|
2013-01-31 16:44:23 +00:00
|
|
|
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; \
|
2012-06-08 21:57:36 +00:00
|
|
|
echo; echo '# override some simple things'; \
|
|
|
|
echo 'BINDIR= /usr/bin'; \
|
2012-10-25 20:31:22 +00:00
|
|
|
echo 'MANDIR= ${MANDIR:U/usr/share/man}'; \
|
2012-06-08 21:57:36 +00:00
|
|
|
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},}'; \
|
2012-07-06 00:03:45 +00:00
|
|
|
echo ) > ${.TARGET}
|
|
|
|
@cmp -s ${.TARGET} ${.CURDIR}/Makefile || \
|
|
|
|
mv ${.TARGET} ${.CURDIR}/Makefile
|
2012-06-08 21:57:36 +00:00
|
|
|
|
|
|
|
.include <bsd.obj.mk>
|
|
|
|
|