3 # Build an unregisterised bootstrap compiler and install it directly
4 # into the .buildlink directory. But we can't use "make install"
5 # because we don't build it in a standard way (./configure && make).
7 # To install it, we just copy ghc and ghc-pkg from
8 # "work/bootstrap/ghc-${VERSION}/inplace/bin" to
9 # "${BUILDLINK_DIR}/bin". Note that in-place ghc isn't usable until we
10 # run "ghc-pkg recache".
12 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
13 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
14 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-netbsd-i386.c
15 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
16 PLATFORM = i386-unknown-netbsd
18 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
19 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
20 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-freebsd-i386.c
21 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
22 PLATFORM = i386-unknown-freebsd
24 .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
25 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap.mk
26 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-darwin-powerpc.c
27 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-darwin9.8.0.tar.bz2
28 PLATFORM = powerpc-apple-darwin
29 # Existence of libelf makes LeadingUnderscore being "NO", which is
30 # incorrect for this platform. See ghc-6.12.1/aclocal.m4
31 # (FP_LEADING_UNDERSCORE)
32 CONFLICTS= libelf-[0-9]*
35 PKG_FAIL_REASON+= "internal error: unsupported platform"
38 BOOTSTRAP_MAIN_C= ${PKGDIR}/files/bootstrap-main.c
40 pre-configure: ${WRKDIR}/stamp-bootstrap-ghc
42 ${WRKDIR}/stamp-autoreconf:
43 ${RUN} cd ${WRKSRC} && \
44 ${PHASE_MSG} "Regenerating configuration scripts for ${PKGNAME}" && \
48 ${WRKDIR}/stamp-prepare-bootstrap: ${WRKDIR}/stamp-autoreconf
49 ${RUN} cd ${WRKDIR} && \
50 ${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}" && \
51 ${RM} -rf bootstrap && \
52 ${MKDIR} bootstrap && \
53 ${GTAR} -cf - ${DISTNAME} | ${GTAR} -C bootstrap -xf - && \
54 ${CP} ${BOOTSTRAP_MAIN_C} bootstrap/${DISTNAME}/rts/bootstrap-main.c && \
55 ${CP} ${BOOTSTRAP_CAPI_C} bootstrap/${DISTNAME}/rts/capi-wrappers.c && \
58 ${WRKDIR}/stamp-configure-hc-boot: ${WRKDIR}/stamp-prepare-bootstrap
59 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
60 ${PHASE_MSG} "Configuring bootstrapping compiler for ${PKGNAME}" && \
61 ${SETENV} ${CONFIGURE_ENV} ./configure --enable-hc-boot --with-ghc="" ${CONFIGURE_ARGS} && \
64 ${WRKDIR}/stamp-extract-hc: ${WRKDIR}/stamp-configure-hc-boot
65 ${RUN} cd ${WRKDIR}/bootstrap && \
66 ${PHASE_MSG} "Extracting bootstrap HC archive for ${PKGNAME}" && \
67 if ${TEST} "`${DATE} '+%Y%m%d%H%M'`" -le 200001010000; then \
68 ${FAIL_MSG} "Adjust your system clock: `${DATE}`"; \
70 ${FIND} ${DISTNAME} -type d -o -type f | ${XARGS} ${TOUCH} -t 200001010000 && \
71 ${GTAR} -jxf ${DISTDIR}/${BOOTSTRAP_TARBALL} && \
72 (cd ${DISTNAME} && ${SH} mkfiles) && \
75 ${WRKDIR}/stamp-rewrite-hc-paths: ${WRKDIR}/stamp-extract-hc
76 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
77 ${PHASE_MSG} "Rewriting source paths in bootstrapping compiler for ${PKGNAME}" && \
78 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" ${BOOTSTRAP_BUILD_MK} > mk/build.mk
79 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
80 # Unregisterised stage0 compiler gets too large (.text section being
81 # over 64 MiB) without dead-code elimination, exceeding NetBSD/i386's
82 # kernel default limitation.
83 # Note that stage1 currently doesn't bloat that much (about 42.6
84 # MiB), but when it does we have to append
85 # CONF_CC_OPTS_STAGE1="-fdata..." and
86 # CONF_GCC_LINKER_OPTS_STAGE1="-Wl,--gc-sections" to CONFIGURE_ENV as
87 # well. I guess that's a matter of time :(
88 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
89 ${ECHO} "EXTRA_CC_OPTS += -fdata-sections -ffunction-sections" >> mk/build.mk && \
90 ${ECHO} "EXTRA_CC_OPTS += -Wl,--gc-sections" >> mk/build.mk
92 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
93 for c in libraries/*/configure; do \
94 (cd `${DIRNAME} $$c` && ${SETENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
96 for i in inplace/lib/package.conf.d/*.conf \
97 */package.conf.inplace \
99 */*/*/package-data.mk \
100 */*/*/*/package-data.mk; do \
101 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" \
102 -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
103 ${MV} -f $$i.tmp $$i; \
105 ${TOUCH} -r inplace/lib/package.conf.d \
106 inplace/lib/package.conf.d/*.conf \
107 */package.conf.inplace \
108 */*/package-data.mk \
109 */*/*/package-data.mk \
110 */*/*/*/package-data.mk \
111 compiler/stage?/build/Config.hs && \
114 ${WRKDIR}/stamp-bootstrap-ghc: ${WRKDIR}/stamp-rewrite-hc-paths
115 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
116 ${PHASE_MSG} "Creating bootstrapping files for ${PKGNAME}" && \
117 ${BUILD_MAKE_CMD} bootstrapping-files && \
118 ${PHASE_MSG} "Building bootstrapping compiler for ${PKGNAME}" && \
119 ${BUILD_MAKE_CMD} all_ghc_stage2 && \
120 ${PHASE_MSG} "Building bootstrapping toolkit for ${PKGNAME}" && \
121 ${BUILD_MAKE_CMD} inplace/bin/ghc-pkg && \
122 ${BUILD_MAKE_CMD} inplace/lib/unlit && \
123 inplace/bin/ghc-pkg recache && \
124 ${CP} -f inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
125 ${CP} -f inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg && \