]> gitweb @ CieloNegro.org - pkgsrc-ghc.git/blob - stage0.mk
moved some USE_TOOLS from Makefile to stage0.mk, the actual user of those tools.
[pkgsrc-ghc.git] / stage0.mk
1 # $NetBSD$
2
3 USE_TOOLS+=     autoconf date gtar perl
4
5 # Build an unregisterised bootstrap compiler and install it directly
6 # into the .buildlink directory. But we can't use "make install"
7 # because we don't build it in a standard way (./configure && make).
8 #
9 # To install it, we just copy ghc and ghc-pkg from
10 # "work/bootstrap/ghc-${VERSION}/inplace/bin" to
11 # "${BUILDLINK_DIR}/bin". Note that in-place ghc isn't usable until we
12 # run "ghc-pkg recache".
13
14 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
15 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
16 BOOTSTRAP_CAPI_C   = ${PKGDIR}/files/capi-wrappers-netbsd-i386.c
17 BOOTSTRAP_TARBALL  = ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
18 PLATFORM           = i386-unknown-netbsd
19
20 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
21 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
22 BOOTSTRAP_CAPI_C   = ${PKGDIR}/files/capi-wrappers-freebsd-i386.c
23 BOOTSTRAP_TARBALL  = ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
24 PLATFORM           = i386-unknown-freebsd
25
26 .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
27 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap.mk
28 BOOTSTRAP_CAPI_C   = ${PKGDIR}/files/capi-wrappers-darwin-powerpc.c
29 BOOTSTRAP_TARBALL  = ${DISTNAME}-boot-i386-unknown-darwin9.8.0.tar.bz2
30 PLATFORM           = powerpc-apple-darwin
31 # Existence of libelf makes LeadingUnderscore being "NO", which is
32 # incorrect for this platform. See ghc-6.12.1/aclocal.m4
33 # (FP_LEADING_UNDERSCORE)
34 CONFLICTS=      libelf-[0-9]*
35
36 .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "Linux"
37 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-linux.mk
38 BOOTSTRAP_CAPI_C   = ${PKGDIR}/files/capi-wrappers-linux-x86_64.c
39 BOOTSTRAP_TARBALL  = ${DISTNAME}-boot-x86_64-unknown-linux-gnu.tar.bz2
40 PLATFORM           = x86_64-unknown-linux
41
42 .else
43 PKG_FAIL_REASON+=       "internal error: unsupported platform"
44 .endif
45
46 BOOTSTRAP_MAIN_C=       ${PKGDIR}/files/bootstrap-main.c
47
48 pre-configure: ${WRKDIR}/stamp-bootstrap-ghc
49
50 ${WRKDIR}/stamp-autoreconf:
51         ${RUN} cd ${WRKSRC} && \
52                 ${PHASE_MSG} "Regenerating configuration scripts for ${PKGNAME}" && \
53                 ${PERL5} boot && \
54                 ${TOUCH} ${.TARGET}
55
56 ${WRKDIR}/stamp-prepare-bootstrap: ${WRKDIR}/stamp-autoreconf
57         ${RUN} cd ${WRKDIR} && \
58                 ${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}" && \
59                 ${RM} -rf bootstrap && \
60                 ${MKDIR} bootstrap && \
61                 ${GTAR} -cf - ${DISTNAME} | ${GTAR} -C bootstrap -xf - && \
62                 ${CP} ${BOOTSTRAP_MAIN_C} bootstrap/${DISTNAME}/rts/bootstrap-main.c && \
63                 ${CP} ${BOOTSTRAP_CAPI_C} bootstrap/${DISTNAME}/rts/capi-wrappers.c  && \
64                 ${TOUCH} ${.TARGET}
65
66 ${WRKDIR}/stamp-configure-hc-boot: ${WRKDIR}/stamp-prepare-bootstrap
67         ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
68                 ${PHASE_MSG} "Configuring bootstrapping compiler for ${PKGNAME}" && \
69                 ${SETENV} ${CONFIGURE_ENV} ./configure --enable-hc-boot --with-ghc="" ${CONFIGURE_ARGS} && \
70                 ${TOUCH} ${.TARGET}
71
72 ${WRKDIR}/stamp-extract-hc: ${WRKDIR}/stamp-configure-hc-boot
73         ${RUN} cd ${WRKDIR}/bootstrap && \
74                 ${PHASE_MSG} "Extracting bootstrap HC archive for ${PKGNAME}" && \
75                 if ${TEST} "`${DATE} '+%Y%m%d%H%M'`" -le 200001010000; then \
76                         ${FAIL_MSG} "Adjust your system clock: `${DATE}`"; \
77                 fi && \
78                 ${FIND} ${DISTNAME} -type d -o -type f | ${XARGS} ${TOUCH} -t 200001010000 && \
79                 ${GTAR} -jxf ${DISTDIR}/${BOOTSTRAP_TARBALL} && \
80                 (cd ${DISTNAME} && ${SH} mkfiles) && \
81                 ${TOUCH} ${.TARGET}
82
83 ${WRKDIR}/stamp-rewrite-hc-paths: ${WRKDIR}/stamp-extract-hc
84         ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
85                 ${PHASE_MSG} "Rewriting source paths in bootstrapping compiler for ${PKGNAME}" && \
86                 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" ${BOOTSTRAP_BUILD_MK} > mk/build.mk && \
87                 for c in libraries/*/configure; do \
88                         (cd `${DIRNAME} $$c` && ${SETENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
89                 done && \
90                 for i in inplace/lib/package.conf.d/*.conf \
91                                  */package.conf.inplace \
92                                  */*/package-data.mk \
93                                  */*/*/package-data.mk \
94                                  */*/*/*/package-data.mk; do \
95                         ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" \
96                                    -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
97                         ${MV} -f $$i.tmp $$i; \
98                 done && \
99                 ${TOUCH} -r inplace/lib/package.conf.d \
100                                         inplace/lib/package.conf.d/*.conf \
101                                         */package.conf.inplace \
102                                         */*/package-data.mk \
103                                         */*/*/package-data.mk \
104                                         */*/*/*/package-data.mk \
105                                         compiler/stage?/build/Config.hs && \
106                 ${TOUCH} ${.TARGET}
107
108 ${WRKDIR}/stamp-bootstrap-ghc: ${WRKDIR}/stamp-rewrite-hc-paths
109         ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
110                 ${PHASE_MSG} "Creating bootstrapping files for ${PKGNAME}" && \
111                 ${BUILD_MAKE_CMD} bootstrapping-files && \
112                 ${PHASE_MSG} "Building bootstrapping compiler for ${PKGNAME}" && \
113                 ${BUILD_MAKE_CMD} all_ghc_stage2 && \
114                 ${PHASE_MSG} "Building bootstrapping toolkit for ${PKGNAME}" && \
115                 ${BUILD_MAKE_CMD} inplace/bin/ghc-pkg && \
116                 ${BUILD_MAKE_CMD} inplace/lib/unlit && \
117                 inplace/bin/ghc-pkg recache && \
118                 ${CP} -f inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
119                 ${CP} -f inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg && \
120                 ${TOUCH} ${.TARGET}