]> gitweb @ CieloNegro.org - pkgsrc-ghc.git/blob - bootstrap.mk
7.6.2 for x86_64-unknown-netbsd
[pkgsrc-ghc.git] / bootstrap.mk
1 # $NetBSD$
2 # -----------------------------------------------------------------------------
3 # Select a bindist of bootstrapping compiler based on a per-platform
4 # basis.
5 #
6 # BOOT_ARCHIVE
7 #   This variable is set to the name of compressed archive file of a
8 #   bootstrapping compiler for the current platform.
9 #
10 # BOOT_TARBALL
11 #   Similar to BOOT_ARCHIVE, but "*.tar" not "*.tar.xz".
12 #
13 .include "../../mk/bsd.prefs.mk"
14 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
15 BOOT_ARCHIVE=   ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
16
17 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
18 BOOT_ARCHIVE=   ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
19
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]*
26
27 .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "Linux"
28 BOOT_ARCHIVE=   ${DISTNAME}-boot-x86_64-unknown-linux-gnu.tar.bz2
29
30 .elif ${MACHINE_ARCH} == "x86_64" && ${OPSYS} == "NetBSD"
31 BOOT_ARCHIVE=   ${DISTNAME}-boot-x86_64-unknown-netbsd.tar.xz
32
33 .else
34 PKG_FAIL_REASON+=       "internal error: unsupported platform"
35 .endif
36
37 BOOT_TARBALL=   ${BOOT_ARCHIVE:C/\.xz$//}
38
39
40 # -----------------------------------------------------------------------------
41 # The "pre-configure" hook
42 #
43 # Install a bootstrapping compiler directly into TOOLS_DIR so that
44 # ./configure can find it.
45 #
46 USE_TOOLS+=     gmake xzcat
47
48 pre-configure:
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}
53
54         @${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}"
55         ${RUN} cd ${WRKDIR:Q}/build-extract/${DISTNAME}-boot && \
56                 ${SH} ./configure \
57                         --prefix=${TOOLS_DIR:Q} \
58                         --with-gcc=${CCPATH:Q} && \
59                 ${MAKE_PROGRAM} install
60
61
62 # -----------------------------------------------------------------------------
63 # An unusual target "bootstrap"
64 #
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
69 # unusable.
70 #
71 .PHONY: bootstrap
72
73 .if exists(${WRKDIR}/${DISTNAME}/mk/config.mk)
74 bootstrap:
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."
78
79 .elif !exists(${WRKDIR}/${DISTNAME}/rts/ghc.mk.orig)
80 bootstrap:
81         @${FAIL_MSG} "Please run \"${MAKE} patch\" first."
82
83 .else
84 bootstrap: ${WRKDIR}/${BOOT_ARCHIVE}
85         @${PHASE_MSG} "Done creating" ${WRKDIR}/${BOOT_ARCHIVE}
86
87 ${WRKDIR}/lndir:
88         @${PHASE_MSG} "Building lndir(1) to duplicate the source tree."
89         cd ${WRKSRC:Q}/utils/lndir && \
90                 ${CCPATH:Q} lndir.c -o ${.TARGET}
91
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}
97         ${TOUCH} ${.TARGET}
98
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
105         ${TOUCH} ${.TARGET}
106
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}
110         ${TOUCH} ${.TARGET}
111
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}
116
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}
121 .endif