1 # $NetBSD: Makefile,v 1.42 2008/07/07 14:58:00 kristerw Exp $
3 DISTNAME= ghc-${VERSION}
6 MASTER_SITES= http://www.haskell.org/ghc/dist/${VERSION}/
7 MAINTAINER= kristerw@NetBSD.org
8 HOMEPAGE= http://www.haskell.org/ghc/
9 COMMENT= Compiler for the functional language Haskell
12 DISTFILES= ${DISTNAME}-src.tar.bz2
13 DISTFILES+= ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
14 DISTFILES+= ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
15 DISTFILES+= ${DISTNAME}-boot-powerpc-apple-darwin9.8.0.tar.bz2
17 .for i in ${DISTFILES:M*-boot-*}
18 SITES.${i}= http://static.cielonegro.org/archive/
21 PKG_DESTDIR_SUPPORT= user-destdir
23 # Unregisterised HC packages are platform-dependent C sources. Yes,
24 # they are C sources but are totally non-portable. We have to create
25 # more HC packages to support more platforms. Note that those packages
26 # are built with integer-simple, not integer-gmp, to reduce some
27 # complexity by not depending on the GMP. The resulting registerised
28 # GHC uses integer-gmp so this won't be a problem.
30 # If you want to build HC packages yourself, follow instructions in
32 ONLY_FOR_PLATFORM= NetBSD-*-i386 FreeBSD-*-i386 Darwin-*-powerpc
34 # We must provide the real path to gcc to the ./configure script,
35 # because GHC has a runtime dependency on it. Aren't there any ways
37 .include "../../mk/bsd.prefs.mk"
38 .include "../../mk/compiler.mk"
40 WARNINGS+= "This package depends on pkgsrc's undocumented variable \
41 CCPATH but it disappeared somehow."
42 WARNINGS+= "Using hard-coded /usr/bin/gcc as the C compiler..."
43 CONFIGURE_ARGS+= --with-gcc=/usr/bin/gcc
45 CONFIGURE_ARGS+= --with-gcc=${CCPATH}
48 USE_TOOLS+= autoconf date gmake gtar perl perl:run
49 CONFIGURE_ENV+= PerlCmd=${PERL5:Q}
51 # We don't want to extract all of the DISTFILEs.
52 EXTRACT_ONLY= ${DISTNAME}-src.tar.bz2
57 --target=${PLATFORM} \
59 --mandir=${PREFIX}/${PKGMANDIR} \
60 --with-gmp-includes=${PREFIX}/include \
61 --with-gmp-libraries=${PREFIX}/lib \
62 --with-iconv-includes=${PREFIX}/include \
63 --with-iconv-libraries=${PREFIX}/lib
65 # Build an unregisterised bootstrap compiler and install it directly
66 # into the .buildlink directory. But we can't use "make install"
67 # because we don't build it in a standard way (./configure && make).
69 # To install it, we just copy ghc and ghc-pkg from
70 # "work/bootstrap/ghc-${VERSION}/inplace/bin" to
71 # "${BUILDLINK_DIR}/bin". Note that in-place ghc isn't usable until we
72 # run "ghc-pkg recache".
74 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
75 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
76 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-netbsd-i386.c
77 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-netbsdelf6.99.1.tar.bz2
78 PLATFORM = i386-unknown-netbsd
80 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
81 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
82 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-freebsd-i386.c
83 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-freebsd8.0.tar.bz2
84 PLATFORM = i386-unknown-freebsd
86 .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
87 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap.mk
88 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-darwin-powerpc.c
89 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-darwin9.8.0.tar.bz2
90 PLATFORM = powerpc-apple-darwin
91 # Existence of libelf makes LeadingUnderscore being "NO", which is
92 # incorrect for this platform. See ghc-6.12.1/aclocal.m4
93 # (FP_LEADING_UNDERSCORE)
94 CONFLICTS= libelf-[0-9]*
97 PKG_FAIL_REASON+= "internal error: unsupported platform"
100 BOOTSTRAP_MAIN_C= ${PKGDIR}/files/bootstrap-main.c
102 pre-configure: ${WRKDIR}/stamp-bootstrap-ghc
104 ${WRKDIR}/stamp-autoreconf:
105 ${RUN} cd ${WRKSRC} && \
106 ${PHASE_MSG} "Regenerating configuration scripts for ${PKGNAME}" && \
110 ${WRKDIR}/stamp-prepare-bootstrap: ${WRKDIR}/stamp-autoreconf
111 ${RUN} cd ${WRKDIR} && \
112 ${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}" && \
113 ${RM} -rf bootstrap && \
114 ${MKDIR} bootstrap && \
115 ${GTAR} -cf - ${DISTNAME} | ${GTAR} -C bootstrap -xf - && \
116 ${CP} ${BOOTSTRAP_MAIN_C} bootstrap/${DISTNAME}/rts/bootstrap-main.c && \
117 ${CP} ${BOOTSTRAP_CAPI_C} bootstrap/${DISTNAME}/rts/capi-wrappers.c && \
120 ${WRKDIR}/stamp-configure-hc-boot: ${WRKDIR}/stamp-prepare-bootstrap
121 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
122 ${PHASE_MSG} "Configuring bootstrapping compiler for ${PKGNAME}" && \
123 ${SETENV} ${CONFIGURE_ENV} ./configure --enable-hc-boot --with-ghc="" ${CONFIGURE_ARGS} && \
126 ${WRKDIR}/stamp-extract-hc: ${WRKDIR}/stamp-configure-hc-boot
127 ${RUN} cd ${WRKDIR}/bootstrap && \
128 ${PHASE_MSG} "Extracting bootstrap HC archive for ${PKGNAME}" && \
129 if ${TEST} "`${DATE} '+%Y%m%d%H%M'`" -le 200001010000; then \
130 ${FAIL_MSG} "Adjust your system clock: `${DATE}`"; \
132 ${FIND} ${DISTNAME} -type d -o -type f | ${XARGS} ${TOUCH} -t 200001010000 && \
133 ${GTAR} -jxf ${DISTDIR}/${BOOTSTRAP_TARBALL} && \
134 (cd ${DISTNAME} && ${SH} mkfiles) && \
137 ${WRKDIR}/stamp-rewrite-hc-paths: ${WRKDIR}/stamp-extract-hc
138 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
139 ${PHASE_MSG} "Rewriting source paths in bootstrapping compiler for ${PKGNAME}" && \
140 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" ${BOOTSTRAP_BUILD_MK} > mk/build.mk
141 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
142 # Unregisterised stage0 compiler gets too large (.text section being
143 # over 64 MiB) without dead-code elimination, exceeding NetBSD/i386's
144 # kernel default limitation.
145 # Note that stage1 currently doesn't bloat that much (about 42.6
146 # MiB), but when it does we have to append
147 # CONF_CC_OPTS_STAGE1="-fdata..." and
148 # CONF_GCC_LINKER_OPTS_STAGE1="-Wl,--gc-sections" to CONFIGURE_ENV as
149 # well. I guess that's a matter of time :(
150 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
151 ${ECHO} "EXTRA_CC_OPTS += -fdata-sections -ffunction-sections" >> mk/build.mk && \
152 ${ECHO} "EXTRA_CC_OPTS += -Wl,--gc-sections" >> mk/build.mk
154 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
155 for c in libraries/*/configure; do \
156 (cd `${DIRNAME} $$c` && ${SETENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
158 for i in inplace/lib/package.conf.d/*.conf \
159 */package.conf.inplace \
160 */*/package-data.mk \
161 */*/*/package-data.mk \
162 */*/*/*/package-data.mk; do \
163 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" \
164 -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
165 ${MV} -f $$i.tmp $$i; \
167 ${TOUCH} -r inplace/lib/package.conf.d \
168 inplace/lib/package.conf.d/*.conf \
169 */package.conf.inplace \
170 */*/package-data.mk \
171 */*/*/package-data.mk \
172 */*/*/*/package-data.mk \
173 compiler/stage?/build/Config.hs && \
176 ${WRKDIR}/stamp-bootstrap-ghc: ${WRKDIR}/stamp-rewrite-hc-paths
177 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
178 ${PHASE_MSG} "Creating bootstrapping files for ${PKGNAME}" && \
179 ${BUILD_MAKE_CMD} bootstrapping-files && \
180 ${PHASE_MSG} "Building bootstrapping compiler for ${PKGNAME}" && \
181 ${BUILD_MAKE_CMD} all_ghc_stage2 && \
182 ${PHASE_MSG} "Building bootstrapping toolkit for ${PKGNAME}" && \
183 ${BUILD_MAKE_CMD} inplace/bin/ghc-pkg && \
184 ${BUILD_MAKE_CMD} inplace/lib/unlit && \
185 inplace/bin/ghc-pkg recache && \
186 ${CP} -f inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
187 ${CP} -f inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg && \
191 ${RUN} cd ${WRKSRC} && \
192 ${SETENV} ${CONFIGURE_ENV} ./configure ${CONFIGURE_ARGS}
193 # We need to tell the libraries/terminfo/configure that our ncurses is
194 # in a non-standard path. Without that, the resulting GHC tries to
195 # link programs by executing ld(1) without passing it -L${PREFIX}/lib.
196 ${RUN} ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \
197 --configure-option=--with-curses-includes=${PREFIX}/include \
198 --configure-option=--with-curses-libraries=${PREFIX}/lib" >> ${WRKSRC}/mk/build.mk
199 # The ghc compiler does normally split the generated asm files into small
200 # parts before sending them to gcc, to enable the linker to eliminate
201 # unused parts. This does however not play nice with the pkgsrc
202 # framework, and the result is that the build takes more than 5 times
203 # as long than when the files are not split. See
204 # http://mail-index.netbsd.org/tech-pkg/2006/07/30/0005.html
205 # for a description of the problem.
206 # Disable file splitting until pkgsrc gets improved.
207 ${RUN} ${ECHO} "SplitObjs = NO" >> ${WRKSRC}/mk/build.mk
208 # If we don't explicitly disable HsColour, PLIST gets changed
209 # depending on whether we have installed it or not.
210 ${RUN} ${ECHO} "HSCOLOUR_SRCS = NO" >> ${WRKSRC}/mk/build.mk
212 # Substitutions for INSTALL and DEINSTALL.
213 FILES_SUBST+= DISTNAME=${DISTNAME}
215 # There is an unused script which don't pass the portability test.
216 CHECK_PORTABILITY_SKIP+= distrib/prep-bin-dist-mingw
218 # GHC currently *requires* ${PREFIX}/lib to be in
219 # "/etc/ld-elf.so.conf". See
220 # http://hackage.haskell.org/trac/ghc/ticket/2933
221 CHECK_SHLIBS_SUPPORTED= no
223 # I guess pdcurses works well but not tested.
225 .include "../../devel/ncurses/buildlink3.mk"
227 BUILD_DEPENDS+= docbook-xsl-[0-9]*:../../textproc/docbook-xsl
228 BUILDLINK_DEPMETHOD.libxslt = build
229 .include "../../converters/libiconv/buildlink3.mk"
230 .include "../../devel/gmp/buildlink3.mk"
231 .include "../../textproc/libxslt/buildlink3.mk"
232 .include "../../mk/pthread.buildlink3.mk"
233 .include "../../mk/bsd.pkg.mk"