2 # -----------------------------------------------------------------------------
3 # Select a bindist of bootstrapping compiler based on a per-platform
7 # This variable is set to the name of compressed archive file of a
8 # bootstrapping compiler for the current platform.
11 # Similar to BOOT_ARCHIVE, but "*.tar" not "*.tar.xz".
13 .include "../../mk/bsd.prefs.mk"
14 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
15 BOOT_ARCHIVE= ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
17 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
18 BOOT_ARCHIVE= ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
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]*
27 .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "Linux"
28 BOOT_ARCHIVE= ${DISTNAME}-boot-x86_64-unknown-linux-gnu.tar.bz2
30 .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "NetBSD"
31 BOOT_ARCHIVE= ${DISTNAME}-boot-x86_64-unknown-netbsd.tar.xz
34 PKG_FAIL_REASON+= "internal error: unsupported platform"
37 BOOT_TARBALL= ${BOOT_ARCHIVE:C/\.xz$//}
40 # -----------------------------------------------------------------------------
41 # The "pre-configure" hook
43 # Install a bootstrapping compiler directly into TOOLS_DIR so that
44 # ./configure can find it.
46 USE_TOOLS+= gmake xzcat
49 @${PHASE_MSG} "Extracting bootstrapping compiler for ${PKGNAME}"
50 ${RUN} ${MKDIR} ${WRKDIR:Q}/build-extract
51 ${RUN} cd ${WRKDIR:Q}/build-extract && \
52 ${EXTRACT_CMD_DEFAULT} ${DISTDIR:Q}/${DIST_SUBDIR:Q}/${BOOT_ARCHIVE}
54 @${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}"
55 ${RUN} cd ${WRKDIR:Q}/build-extract/${DISTNAME}-boot && \
57 --prefix=${TOOLS_DIR:Q} \
58 --with-gcc=${CCPATH:Q} && \
59 ${MAKE_PROGRAM} install
62 # -----------------------------------------------------------------------------
63 # An unusual target "bootstrap"
65 # Build a bootstrapping compiler using an already installed GHC. This
66 # can certainly impossible if you don't have one. It's absolutely
67 # important to build it with the fewest possible run-time
68 # dependencies, otherwise the resulting binary can easily get
73 .if exists(${WRKDIR}/${DISTNAME}/mk/config.mk)
75 @${ERROR_MSG} "You have already configured the package in a way\
76 that building bootstrapping compiler is impossible."
77 @${FAIL_MSG} "Please run \"${MAKE} clean patch\" first."
79 .elif !exists(${WRKDIR}/${DISTNAME}/rts/ghc.mk.orig)
81 @${FAIL_MSG} "Please run \"${MAKE} patch\" first."
84 bootstrap: ${WRKDIR}/${BOOT_ARCHIVE}
85 @${PHASE_MSG} "Done creating" ${WRKDIR}/${BOOT_ARCHIVE}
88 @${PHASE_MSG} "Building lndir(1) to duplicate the source tree."
89 cd ${WRKSRC:Q}/utils/lndir && \
90 ${CCPATH:Q} lndir.c -o ${.TARGET}
92 ${WRKDIR}/stamp-lndir-boot: ${WRKDIR}/lndir
93 @${PHASE_MSG} "Duplicating the source tree for bootstrapping ${DISTNAME}"
94 ${MKDIR} ${WRKDIR:Q}/build-boot
95 cd ${WRKDIR:Q}/build-boot && \
96 ${WRKDIR}/lndir -silent ../${DISTNAME:Q}
99 ${WRKDIR}/stamp-configure-boot: ${WRKDIR}/stamp-lndir-boot
100 @${PHASE_MSG} "Configuring bootstrapping compiler ${DISTNAME}"
101 ${MKDIR} ${WRKDIR:Q}/build-boot
102 cd ${WRKDIR:Q}/build-boot && \
103 ${SH} ./configure --with-gcc=${CCPATH:Q} && \
104 ${LN} -f ${FILESDIR:Q}/bootstrap.build.mk mk/build.mk
107 ${WRKDIR}/stamp-build-boot: ${WRKDIR}/stamp-configure-boot
108 @${PHASE_MSG} "Building bootstrapping compiler ${DISTNAME}"
109 ${RUN} cd ${WRKDIR:Q}/build-boot && ${BUILD_MAKE_CMD}
112 ${WRKDIR}/${BOOT_TARBALL}: ${WRKDIR}/stamp-build-boot
113 @${PHASE_MSG} "Creating binary distribution of bootstrapping ${DISTNAME}"
114 ${RUN} cd ${WRKDIR:Q}/build-boot && ${BUILD_MAKE_CMD} binary-dist
115 ${MV} -f ${WRKDIR:Q}/build-boot/${BOOT_TARBALL} ${.TARGET}
117 # This can take up half an hour. Memory usage is also very high, about 680 MiB.
118 ${WRKDIR}/${BOOT_ARCHIVE}: ${WRKDIR}/${BOOT_TARBALL}
119 @${PHASE_MSG} "Compressing binary distribution of bootstrapping ${DISTNAME}"
120 ${PREFIX:Q}/bin/xz --verbose -9 --extreme ${WRKDIR:Q}/${BOOT_TARBALL}