~ubuntu-branches/ubuntu/trusty/bmake/trusty-proposed

« back to all changes in this revision

Viewing changes to bsd.after-import.mk

  • Committer: Package Import Robot
  • Author(s): Andrew Shadura
  • Date: 2013-09-22 16:07:33 UTC
  • Revision ID: package-import@ubuntu.com-20130922160733-9cvmsi7z0jswtrbi
Tags: upstream-20130904
ImportĀ upstreamĀ versionĀ 20130904

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $Id: bsd.after-import.mk,v 1.11 2012/12/29 19:32:25 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
 
 
12
all: _makefile
 
13
all: after-import
 
14
 
 
15
# we rely on bmake
 
16
.if !defined(.PARSEDIR)
 
17
.error this makefile requires bmake
 
18
.endif
 
19
 
 
20
_this := ${MAKEFILE:tA} 
 
21
BMAKE_SRC := ${.PARSEDIR}
 
22
 
 
23
# it helps to know where the top of the tree is.
 
24
.if !defined(SRCTOP)
 
25
srctop := ${.MAKE.MAKEFILES:M*src/share/mk/sys.mk:H:H:H}
 
26
.if empty(srctop)
 
27
# likely locations?
 
28
.for d in contrib/bmake external/bsd/bmake/dist
 
29
.if ${BMAKE_SRC:M*/$d} != ""
 
30
srctop := ${BMAKE_SRC:tA:S,/$d,,}
 
31
.endif
 
32
.endfor
 
33
.endif
 
34
.if !empty(srctop)
 
35
SRCTOP := ${srctop}
 
36
.endif
 
37
.endif
 
38
 
 
39
# This lets us match what boot-strap does
 
40
.if !defined(HOST_OS)
 
41
HOST_OS!= uname
 
42
.endif
 
43
 
 
44
# .../share/mk will find ${SRCTOP}/share/mk
 
45
# if we are within ${SRCTOP}
 
46
DEFAULT_SYS_PATH= .../share/mk:/usr/share/mk
 
47
 
 
48
BOOTSTRAP_ARGS = \
 
49
        --with-default-sys-path='${DEFAULT_SYS_PATH}' \
 
50
        --prefix /usr \
 
51
        --share /usr/share
 
52
 
 
53
 
 
54
# run boot-strap with minimal influence
 
55
bootstrap:      ${BMAKE_SRC}/boot-strap ${MAKEFILE}
 
56
        HOME=/ ${BMAKE_SRC}/boot-strap -o ${HOST_OS} ${BOOTSTRAP_ARGS} ${BOOTSTRAP_XTRAS}
 
57
        touch ${.TARGET}
 
58
 
 
59
# Makefiles need a little more tweaking than say config.h
 
60
MAKEFILE_SED =  sed -e '/^MACHINE/d' \
 
61
        -e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \
 
62
        -e 's,^.-include,.sinclude,' \
 
63
        -e '/^\..*include  *</ { s,<,<bsd.,;/autoconf/d; }' \
 
64
        -e 's,${SRCTOP},$${SRCTOP},g'
 
65
 
 
66
# These are the simple files we want to capture
 
67
configured_files= config.h Makefile.config unit-tests/Makefile
 
68
 
 
69
after-import: bootstrap ${MAKEFILE}
 
70
.for f in ${configured_files:M*.[ch]}
 
71
        @echo Capturing $f
 
72
        @mkdir -p ${${.CURDIR}/$f:L:H}
 
73
        @(echo '/* $$${HOST_OS}$$ */'; cat ${HOST_OS}/$f) > ${.CURDIR}/$f
 
74
.endfor
 
75
.for f in ${configured_files:M*Makefile*}
 
76
        @echo Capturing $f
 
77
        @mkdir -p ${${.CURDIR}/$f:L:H}
 
78
        @(echo '# This is a generated file, do NOT edit!'; \
 
79
        echo '# See ${_this:S,${SRCTOP}/,,}'; \
 
80
        echo '#'; echo '# $$${HOST_OS}$$'; echo; \
 
81
        echo 'SRCTOP?= $${.CURDIR:${${.CURDIR}/$f:L:H:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; echo; \
 
82
        ${MAKEFILE_SED} ${HOST_OS}/$f ) > ${.CURDIR}/$f
 
83
.endfor
 
84
 
 
85
# this needs the most work
 
86
_makefile:      bootstrap ${MAKEFILE}
 
87
        @echo Generating ${.CURDIR}/Makefile
 
88
        @(echo '# This is a generated file, do NOT edit!'; \
 
89
        echo '# See ${_this:S,${SRCTOP}/,,}'; \
 
90
        echo '#'; echo '# $$${HOST_OS}$$'; \
 
91
        echo; echo '.sinclude "Makefile.inc"'; \
 
92
        echo; echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \
 
93
        echo; echo '# look here first for config.h'; \
 
94
        echo 'CFLAGS+= -I$${.CURDIR}'; echo; \
 
95
        echo '# for after-import'; \
 
96
        echo 'CLEANDIRS+= ${HOST_OS}'; \
 
97
        echo 'CLEANFILES+= bootstrap'; echo; \
 
98
        ${MAKEFILE_SED} \
 
99
        ${1 2:L:@n@-e '/start-delete$n/,/end-delete$n/d'@} \
 
100
        ${BMAKE_SRC}/Makefile; \
 
101
        echo; echo '# override some simple things'; \
 
102
        echo 'BINDIR= /usr/bin'; \
 
103
        echo 'MANDIR= ${MANDIR:U/usr/share/man}'; \
 
104
        echo; echo '# make sure we get this'; \
 
105
        echo 'CFLAGS+= $${COPTS.$${.IMPSRC:T}}'; \
 
106
        echo; echo 'after-import: ${_this:S,${SRCTOP},\${SRCTOP},}'; \
 
107
        echo '  cd $${.CURDIR} && $${.MAKE} -f ${_this:S,${SRCTOP},\${SRCTOP},}'; \
 
108
        echo ) > ${.TARGET}
 
109
        @cmp -s ${.TARGET} ${.CURDIR}/Makefile || \
 
110
            mv ${.TARGET} ${.CURDIR}/Makefile
 
111
 
 
112
.include <bsd.obj.mk>
 
113