]> gitweb @ CieloNegro.org - pkgsrc-ghc.git/blob - bootstrap.mk
Tidy-up bootstrapping rules.
[pkgsrc-ghc.git] / bootstrap.mk
1 # $NetBSD$
2 # -----------------------------------------------------------------------------
3 # Select a bindist of bootstrapping compiler based on a per-platform
4 # basis.
5 #
6 # BOOT_ARCHIVE
7 #   This variable is set to the name of compressed archive file of a
8 #   bootstrapping compiler for the current platform.
9 #
10 # BOOT_TARBALL
11 #   Similar to BOOT_ARCHIVE, but "*.tar" not "*.tar.xz".
12 #
13 .include "../../mk/bsd.prefs.mk"
14 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
15 BOOT_ARCHIVE=   ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
16
17 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
18 BOOT_ARCHIVE=   ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
19
20 .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
21 BOOT_ARCHIVE=   ${DISTNAME}-boot-powerpc-apple-darwin.tar.xz
22 # Existence of libelf makes LeadingUnderscore being "NO", which is
23 # incorrect for this platform. See ${WRKSRC}/aclocal.m4
24 # (FP_LEADING_UNDERSCORE)
25 CONFLICTS+=             libelf-[0-9]*
26
27 .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "Linux"
28 BOOT_ARCHIVE=   ${DISTNAME}-boot-x86_64-unknown-linux-gnu.tar.bz2
29
30 .else
31 PKG_FAIL_REASON+=       "internal error: unsupported platform"
32 .endif
33
34 BOOT_TARBALL=   ${BOOT_ARCHIVE:C/\.xz$//}
35
36
37 # -----------------------------------------------------------------------------
38 # The "pre-configure" hook
39 #
40 # Install a bootstrapping compiler directly into TOOLS_DIR so that
41 # ./configure can find it.
42 #
43 USE_TOOLS+=     gmake xzcat
44
45 pre-configure:
46         @${PHASE_MSG} "Extracting bootstrapping compiler for ${PKGNAME}"
47         ${RUN} ${MKDIR} ${WRKDIR:Q}/build-extract
48         ${RUN} cd ${WRKDIR:Q}/build-extract && \
49                 ${EXTRACT_CMD_DEFAULT} ${DISTDIR:Q}/${DIST_SUBDIR:Q}/${BOOT_ARCHIVE}
50
51         @${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}"
52         ${RUN} cd ${WRKDIR:Q}/build-extract/${DISTNAME}-boot && \
53                 ${SH} ./configure \
54                         --prefix=${TOOLS_DIR:Q} \
55                         --with-gcc=${CCPATH:Q} && \
56                 ${MAKE_PROGRAM} install
57
58
59 # -----------------------------------------------------------------------------
60 # An unusual target "bootstrap"
61 #
62 # Build a bootstrapping compiler using an already installed GHC. This
63 # can certainly impossible if you don't have one. It's absolutely
64 # important to build it with the fewest possible run-time
65 # dependencies, otherwise the resulting binary can easily get
66 # unusable.
67 #
68 .PHONY: bootstrap
69
70 .if exists(${WRKDIR}/${DISTNAME}/mk/config.mk)
71 bootstrap:
72         @${ERROR_MSG} "You have already configured the package in a way\
73         that building bootstrapping compiler is impossible."
74         @${FAIL_MSG}  "Please run \"${MAKE} clean patch\" first."
75
76 .elif !exists(${WRKDIR}/${DISTNAME}/rts/ghc.mk.orig)
77 bootstrap:
78         @${FAIL_MSG} "Please run \"${MAKE} patch\" first."
79
80 .else
81 bootstrap: ${WRKDIR}/${BOOT_ARCHIVE}
82         @${PHASE_MSG} "Done creating" ${WRKDIR}/${BOOT_ARCHIVE}
83
84 ${WRKDIR}/lndir:
85         @${PHASE_MSG} "Building lndir(1) to duplicate the source tree."
86         cd ${WRKSRC:Q}/utils/lndir && \
87                 ${CCPATH:Q} lndir.c -o ${.TARGET}
88
89 ${WRKDIR}/stamp-lndir-boot: ${WRKDIR}/lndir
90         @${PHASE_MSG} "Duplicating the source tree for bootstrapping ${DISTNAME}"
91         ${MKDIR} ${WRKDIR:Q}/build-boot
92         cd ${WRKDIR:Q}/build-boot && \
93                 ${WRKDIR}/lndir -silent ../${DISTNAME:Q}
94         ${TOUCH} ${.TARGET}
95
96 ${WRKDIR}/stamp-configure-boot: ${WRKDIR}/stamp-lndir-boot
97         @${PHASE_MSG} "Configuring bootstrapping compiler ${DISTNAME}"
98         ${MKDIR} ${WRKDIR:Q}/build-boot
99         cd ${WRKDIR:Q}/build-boot && \
100                 ${SH} ./configure --with-gcc=${CCPATH:Q} && \
101                 ${LN} -f ${FILESDIR:Q}/bootstrap.build.mk mk/build.mk
102         ${TOUCH} ${.TARGET}
103
104 ${WRKDIR}/stamp-build-boot: ${WRKDIR}/stamp-configure-boot
105         @${PHASE_MSG} "Building bootstrapping compiler ${DISTNAME}"
106         ${RUN} cd ${WRKDIR:Q}/build-boot && ${BUILD_MAKE_CMD}
107         ${TOUCH} ${.TARGET}
108
109 ${WRKDIR}/${BOOT_TARBALL}: ${WRKDIR}/stamp-build-boot
110         @${PHASE_MSG} "Creating binary distribution of bootstrapping ${DISTNAME}"
111         ${RUN} cd ${WRKDIR:Q}/build-boot && ${BUILD_MAKE_CMD} binary-dist
112         ${MV} -f ${WRKDIR:Q}/build-boot/${BOOT_TARBALL} ${.TARGET}
113
114 # This can take up half an hour. Memory usage is also very high, about 680 MiB.
115 ${WRKDIR}/${BOOT_ARCHIVE}: ${WRKDIR}/${BOOT_TARBALL}
116         @${PHASE_MSG} "Compressing binary distribution of bootstrapping ${DISTNAME}"
117         ${PREFIX:Q}/bin/xz --verbose -9 --extreme ${WRKDIR:Q}/${BOOT_TARBALL}
118 .endif