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} == "NetBSD"
15 BOOT_ARCHIVE= ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
17 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
18 BOOT_ARCHIVE= ${DISTNAME}-boot-i386-unknown-freebsd8.0.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
31 PKG_FAIL_REASON+= "internal error: unsupported platform"
34 BOOT_TARBALL= ${BOOT_ARCHIVE:C/\.xz$//}
37 # -----------------------------------------------------------------------------
38 # The "pre-configure" hook
40 # Install a bootstrapping compiler directly into TOOLS_DIR so that
41 # ./configure can find it.
43 USE_TOOLS+= gmake xzcat
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}
51 @${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}"
52 ${RUN} cd ${WRKDIR:Q}/build-extract/${DISTNAME}-boot && \
54 --prefix=${TOOLS_DIR:Q} \
55 --with-gcc=${CCPATH:Q} && \
56 ${MAKE_PROGRAM} install
59 # -----------------------------------------------------------------------------
60 # An unusual target "bootstrap"
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
70 .if exists(${WRKDIR}/${DISTNAME}/mk/config.mk)
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."
76 .elif !exists(${WRKDIR}/${DISTNAME}/rts/ghc.mk.orig)
78 @${FAIL_MSG} "Please run \"${MAKE} patch\" first."
81 bootstrap: ${WRKDIR}/${BOOT_ARCHIVE}
82 @${PHASE_MSG} "Done creating" ${WRKDIR}/${BOOT_ARCHIVE}
85 @${PHASE_MSG} "Building lndir(1) to duplicate the source tree."
86 cd ${WRKSRC:Q}/utils/lndir && \
87 ${CCPATH:Q} lndir.c -o ${.TARGET}
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}
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
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}
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}
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}