]> gitweb @ CieloNegro.org - pkgsrc-ghc.git/blob - bootstrap.mk
Drop superfluous PKG_DESTDIR_SUPPORT, "user-destdir" is default these days.
[pkgsrc-ghc.git] / bootstrap.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 BOOTSTRAP_MAIN_C=       ${PKGDIR}/files/bootstrap-main.c
15 BOOTSTRAP_CC_OPTS=      -I${PREFIX:Q}/include
16 BOOTSTRAP_LD_OPTS=      -L${PREFIX:Q}/lib -Wl,-rpath -Wl,${PREFIX:Q}/lib
17 BOOTSTRAP_LD_OPTS+=     -lm -liconv -lncurses
18 BOOTSTRAP_CONF_ARGS=    --enable-hc-boot --with-ghc=""
19
20 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
21 PLATFORM=               i386-unknown-netbsd
22 BOOTSTRAP_CAPI_C=       ${PKGDIR}/files/capi-wrappers-netbsd-i386.c
23 BOOTSTRAP_TARBALL=      ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
24 # Unregisterised compilers get too large (.text section being over 64
25 # MiB) without -Os, exceeding NetBSD/i386's kernel default limitation.
26 BOOTSTRAP_CC_OPTS+=     -Os
27 BOOTSTRAP_CONF_ARGS+=   CONF_CC_OPTS_STAGE2="-Os"
28
29 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
30 PLATFORM=               i386-unknown-freebsd
31 BOOTSTRAP_CAPI_C=       ${PKGDIR}/files/capi-wrappers-freebsd-i386.c
32 BOOTSTRAP_TARBALL=      ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
33 BOOTSTRAP_CC_OPTS+=     -O2
34 BOOTSTRAP_LD_OPTS+=     -lutil -lrt
35 BOOTSTRAP_CONF_ARGS+=   CONF_CC_OPTS_STAGE2="-O2"
36
37 .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
38 PLATFORM=               powerpc-apple-darwin
39 BOOTSTRAP_CAPI_C=       ${PKGDIR}/files/capi-wrappers-darwin-powerpc.c
40 BOOTSTRAP_TARBALL=      ${DISTNAME}-boot-powerpc-apple-darwin9.8.0.tar.bz2
41 BOOTSTRAP_CC_OPTS+=     -O2
42 BOOTSTRAP_CONF_ARGS+=   CONF_CC_OPTS_STAGE2="-O2"
43 # Existence of libelf makes LeadingUnderscore being "NO", which is
44 # incorrect for this platform. See ghc-6.12.1/aclocal.m4
45 # (FP_LEADING_UNDERSCORE)
46 CONFLICTS+=             libelf-[0-9]*
47
48 .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "Linux"
49 PLATFORM=               x86_64-unknown-linux
50 BOOTSTRAP_CAPI_C=       ${PKGDIR}/files/capi-wrappers-linux-x86_64.c
51 BOOTSTRAP_TARBALL=      ${DISTNAME}-boot-x86_64-unknown-linux-gnu.tar.bz2
52 BOOTSTRAP_CC_OPTS+=     -O2
53 BOOTSTRAP_LD_OPTS+=     -lrt -ldl
54 BOOTSTRAP_CONF_ARGS+=   CONF_CC_OPTS_STAGE2="-O2"
55
56 .else
57 PKG_FAIL_REASON+=       "internal error: unsupported platform"
58 .endif
59
60 pre-configure: ${WRKDIR}/stamp-bootstrap-ghc
61
62 ${WRKDIR}/stamp-autoreconf:
63         ${RUN} cd ${WRKSRC} && \
64                 ${PHASE_MSG} "Regenerating configuration scripts for ${PKGNAME}" && \
65                 ${PERL5} boot && \
66                 ${TOUCH} ${.TARGET}
67
68 ${WRKDIR}/stamp-prepare-bootstrap: ${WRKDIR}/stamp-autoreconf
69         ${RUN} cd ${WRKDIR} && \
70                 ${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}" && \
71                 ${RM} -rf bootstrap && \
72                 ${MKDIR} bootstrap && \
73                 ${GTAR} -cf - ${DISTNAME} | ${GTAR} -C bootstrap -xf - && \
74                 ${CP} -f ${BOOTSTRAP_MAIN_C:Q} bootstrap/${DISTNAME}/rts/bootstrap-main.c && \
75                 ${CP} -f ${BOOTSTRAP_CAPI_C:Q} bootstrap/${DISTNAME}/rts/capi-wrappers.c  && \
76                 ${TOUCH} ${.TARGET}
77
78 ${WRKDIR}/stamp-configure-hc-boot: ${WRKDIR}/stamp-prepare-bootstrap
79         ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
80                 ${PHASE_MSG} "Configuring bootstrapping compiler for ${PKGNAME}" && \
81                 ${SETENV} ${CONFIGURE_ENV} ./configure ${BOOTSTRAP_CONF_ARGS} ${CONFIGURE_ARGS} && \
82                 ${TOUCH} ${.TARGET}
83
84 ${WRKDIR}/stamp-extract-hc: ${WRKDIR}/stamp-configure-hc-boot
85         ${RUN} cd ${WRKDIR}/bootstrap && \
86                 ${PHASE_MSG} "Extracting bootstrap HC archive for ${PKGNAME}" && \
87                 if ${TEST} "`${DATE} '+%Y%m%d%H%M'`" -le 200001010000; then \
88                         ${FAIL_MSG} "Adjust your system clock: `${DATE}`"; \
89                 fi && \
90                 ${FIND} ${DISTNAME} -type d -o -type f | ${XARGS} ${TOUCH} -t 200001010000 && \
91                 ${GTAR} -jxf ${DISTDIR}/${BOOTSTRAP_TARBALL} && \
92                 (cd ${DISTNAME} && ${SH} mkfiles) && \
93                 ${TOUCH} ${.TARGET}
94
95 ${WRKDIR}/stamp-rewrite-hc-paths: ${WRKDIR}/stamp-extract-hc
96         ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
97                 ${PHASE_MSG} "Rewriting source paths in bootstrapping compiler for ${PKGNAME}" && \
98                 ${CP} -f ${PKGDIR:Q}/files/build.bootstrap.common.mk mk/build.mk && \
99                 ${ECHO} "SRC_CC_OPTS += ${BOOTSTRAP_CC_OPTS}" >> mk/build.mk && \
100                 ${ECHO} "LD_OPTS += ${BOOTSTRAP_LD_OPTS}" >> mk/build.mk && \
101                 for c in libraries/*/configure; do \
102                         (cd `${DIRNAME} $$c` && ${SETENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
103                 done && \
104                 for i in inplace/lib/package.conf.d/*.conf \
105                                  */package.conf.inplace \
106                                  */*/package-data.mk \
107                                  */*/*/package-data.mk \
108                                  */*/*/*/package-data.mk; do \
109                         ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" \
110                                    -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
111                         ${MV} -f $$i.tmp $$i; \
112                 done && \
113                 ${TOUCH} -r inplace/lib/package.conf.d \
114                                         inplace/lib/package.conf.d/*.conf \
115                                         */package.conf.inplace \
116                                         */*/package-data.mk \
117                                         */*/*/package-data.mk \
118                                         */*/*/*/package-data.mk \
119                                         compiler/stage?/build/Config.hs && \
120                 ${TOUCH} ${.TARGET}
121
122 ${WRKDIR}/stamp-bootstrap-ghc: ${WRKDIR}/stamp-rewrite-hc-paths
123         ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
124                 ${PHASE_MSG} "Creating bootstrapping files for ${PKGNAME}" && \
125                 ${BUILD_MAKE_CMD} bootstrapping-files && \
126                 ${PHASE_MSG} "Building bootstrapping compiler for ${PKGNAME}" && \
127                 ${BUILD_MAKE_CMD} all_ghc_stage2 && \
128                 ${PHASE_MSG} "Building bootstrapping toolkit for ${PKGNAME}" && \
129                 ${BUILD_MAKE_CMD} inplace/bin/ghc-pkg && \
130                 ${BUILD_MAKE_CMD} inplace/lib/unlit && \
131                 inplace/bin/ghc-pkg recache && \
132                 ${CP} -f inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
133                 ${CP} -f inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg && \
134                 ${TOUCH} ${.TARGET}