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 architecture dependent. We have to
24 # create more HC packages to support more architectures. Note that
25 # these packages are built with integer-simple, not integer-gmp, to
26 # reduce some complexity by not depending on the GMP. The resulting
27 # registerised GHC uses integer-gmp so this won't be a problem.
29 # If you want to build HC packages yourself, follow instructions in
31 ONLY_FOR_PLATFORM= NetBSD-*-i386 FreeBSD-*-i386 Darwin-*-powerpc
33 # We must provide the real pass to gcc to the ./configure script,
34 # because GHC has a runtime dependency on it. Aren't there any ways
36 .include "../../mk/bsd.prefs.mk"
37 .include "../../mk/compiler.mk"
39 WARNINGS+= "This package depends on pkgsrc's undocumented variable \
40 CCPATH but it disappeared somehow."
41 WARNINGS+= "Using hard-coded /usr/bin/gcc as the C compiler..."
42 CONFIGURE_ARGS+= --with-gcc=/usr/bin/gcc
44 CONFIGURE_ARGS+= --with-gcc=${CCPATH}
47 USE_TOOLS+= autoconf date gmake gtar perl perl:run
48 CONFIGURE_ENV+= PerlCmd=${PERL5:Q}
50 # We don't want to extract all of the DISTFILEs.
51 EXTRACT_ONLY= ${DISTNAME}-src.tar.bz2
56 --target=${PLATFORM} \
58 --mandir=${PREFIX}/${PKGMANDIR} \
59 --with-gmp-includes=${PREFIX}/include \
60 --with-gmp-libraries=${PREFIX}/lib \
61 --with-iconv-includes=${PREFIX}/include \
62 --with-iconv-libraries=${PREFIX}/lib
64 # Build an unregisterised bootstrap compiler and install it directly
65 # into the .buildlink directory. But we can't use "make install"
66 # because we don't build it in a standard way (./configure && make).
68 # To install it, we just copy ghc and ghc-pkg from
69 # "work/bootstrap/ghc-${VERSION}/inplace/bin" to
70 # "${BUILDLINK_DIR}/bin". Note that in-place ghc isn't usable until we
71 # run "ghc-pkg recache".
73 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
74 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
75 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-netbsd-i386.c
76 PLATFORM = i386-unknown-netbsdelf6.99.1
78 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
79 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
80 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-freebsd-i386.c
81 PLATFORM = i386-unknown-freebsd8.0
83 .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
84 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap.mk
85 BOOTSTRAP_CAPI_C = ${PKGDIR}/files/capi-wrappers-darwin-powerpc.c
86 PLATFORM = powerpc-apple-darwin9.8.0
87 # Existence of libelf makes LeadingUnderscore being "NO", which is
88 # incorrect for this platform. See ghc-6.12.1/aclocal.m4
89 # (FP_LEADING_UNDERSCORE)
90 CONFLICTS= libelf-[0-9]*
93 PKG_FAIL_REASON+= "internal error: unsupported platform"
96 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-${PLATFORM}.tar.bz2
97 BOOTSTRAP_MAIN_C = ${PKGDIR}/files/bootstrap-main.c
99 pre-configure: ${WRKDIR}/stamp-bootstrap-ghc
101 ${WRKDIR}/stamp-autoreconf:
102 ${RUN} cd ${WRKSRC} && \
103 ${PHASE_MSG} "Regenerating configuration scripts for ${PKGNAME}" && \
107 ${WRKDIR}/stamp-prepare-bootstrap: ${WRKDIR}/stamp-autoreconf
108 ${RUN} cd ${WRKDIR} && \
109 ${PHASE_MSG} "Preparing bootstrapping compiler for ${PKGNAME}" && \
110 ${RM} -rf bootstrap && \
111 ${MKDIR} bootstrap && \
112 ${GTAR} -cf - ${DISTNAME} | ${GTAR} -C bootstrap -xf - && \
113 ${CP} ${BOOTSTRAP_MAIN_C} bootstrap/${DISTNAME}/rts/bootstrap-main.c && \
114 ${CP} ${BOOTSTRAP_CAPI_C} bootstrap/${DISTNAME}/rts/capi-wrappers.c && \
117 ${WRKDIR}/stamp-configure-hc-boot: ${WRKDIR}/stamp-prepare-bootstrap
118 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
119 ${PHASE_MSG} "Configuring bootstrapping compiler for ${PKGNAME}" && \
120 ${SETENV} ${CONFIGURE_ENV} ./configure --enable-hc-boot --with-ghc="" ${CONFIGURE_ARGS} && \
123 ${WRKDIR}/stamp-extract-hc: ${WRKDIR}/stamp-configure-hc-boot
124 ${RUN} cd ${WRKDIR}/bootstrap && \
125 ${PHASE_MSG} "Extracting bootstrap HC archive for ${PKGNAME}" && \
126 if ${TEST} "`${DATE} '+%Y%m%d%H%M'`" -le 200001010000; then \
127 ${FAIL_MSG} "Adjust your system clock: `${DATE}`"; \
129 ${FIND} ${DISTNAME} -type d -o -type f | ${XARGS} ${TOUCH} -t 200001010000 && \
130 ${GTAR} -jxf ${DISTDIR}/${BOOTSTRAP_TARBALL} && \
131 (cd ${DISTNAME} && ${SH} mkfiles) && \
134 ${WRKDIR}/stamp-rewrite-hc-paths: ${WRKDIR}/stamp-extract-hc
135 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
136 ${PHASE_MSG} "Rewriting source paths in bootstrapping compiler for ${PKGNAME}" && \
137 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" ${BOOTSTRAP_BUILD_MK} > mk/build.mk && \
138 for c in libraries/*/configure; do \
139 (cd `${DIRNAME} $$c` && ${SETENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
141 for i in inplace/lib/package.conf.d/*.conf \
142 */package.conf.inplace \
143 */*/package-data.mk \
144 */*/*/package-data.mk \
145 */*/*/*/package-data.mk; do \
146 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" \
147 -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
148 ${MV} -f $$i.tmp $$i; \
150 ${TOUCH} -r inplace/lib/package.conf.d \
151 inplace/lib/package.conf.d/*.conf \
152 */package.conf.inplace \
153 */*/package-data.mk \
154 */*/*/package-data.mk \
155 */*/*/*/package-data.mk \
156 compiler/stage?/build/Config.hs && \
159 ${WRKDIR}/stamp-bootstrap-ghc: ${WRKDIR}/stamp-rewrite-hc-paths
160 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
161 ${PHASE_MSG} "Creating bootstrapping files for ${PKGNAME}" && \
162 ${BUILD_MAKE_CMD} bootstrapping-files && \
163 ${PHASE_MSG} "Building bootstrapping compiler for ${PKGNAME}" && \
164 ${BUILD_MAKE_CMD} all_ghc_stage2 && \
165 ${PHASE_MSG} "Building bootstrapping toolkit for ${PKGNAME}" && \
166 ${BUILD_MAKE_CMD} inplace/bin/ghc-pkg && \
167 ${BUILD_MAKE_CMD} inplace/lib/unlit && \
168 inplace/bin/ghc-pkg recache && \
169 ${CP} -f inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
170 ${CP} -f inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg && \
174 ${RUN} cd ${WRKSRC} && \
175 ${SETENV} ${CONFIGURE_ENV} ./configure ${CONFIGURE_ARGS}
176 # We need to tell the libraries/terminfo/configure that our ncurses is
177 # in a non-standard path. Without that, the resulting GHC tries to
178 # link programs by executing ld(1) without passing it -L${PREFIX}/lib.
179 ${RUN} ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \
180 --configure-option=--with-curses-includes=${PREFIX}/include \
181 --configure-option=--with-curses-libraries=${PREFIX}/lib" >> ${WRKSRC}/mk/build.mk
182 # The ghc compiler does normally split the generated asm files into small
183 # parts before sending them to gcc, to enable the linker to eliminate
184 # unused parts. This does however not play nice with the pkgsrc
185 # framework, and the result is that the build takes more than 5 times
186 # as long than when the files are not split. See
187 # http://mail-index.netbsd.org/tech-pkg/2006/07/30/0005.html
188 # for a description of the problem.
189 # Disable file splitting until pkgsrc gets improved.
190 ${RUN} ${ECHO} "SplitObjs = NO" >> ${WRKSRC}/mk/build.mk
191 # If we don't explicitly disable HsColour, PLIST gets changed
192 # depending on whether we have installed it or not.
193 ${RUN} ${ECHO} "HSCOLOUR_SRCS = NO" >> ${WRKSRC}/mk/build.mk
195 # Substitutions for INSTALL and DEINSTALL.
196 FILES_SUBST+= DISTNAME=${DISTNAME}
198 # There is an unused script which don't pass the portability test.
199 CHECK_PORTABILITY_SKIP+= distrib/prep-bin-dist-mingw
201 # GHC currently *requires* ${PREFIX}/lib to be in
202 # "/etc/ld-elf.so.conf". See
203 # http://hackage.haskell.org/trac/ghc/ticket/2933
204 CHECK_SHLIBS_SUPPORTED= no
206 # I guess pdcurses works well but not tested.
208 .include "../../devel/ncurses/buildlink3.mk"
210 BUILD_DEPENDS+= docbook-xsl-[0-9]*:../../textproc/docbook-xsl
211 BUILDLINK_DEPMETHOD.libxslt = build
212 .include "../../converters/libiconv/buildlink3.mk"
213 .include "../../devel/gmp/buildlink3.mk"
214 .include "../../textproc/libxslt/buildlink3.mk"
215 .include "../../mk/pthread.buildlink3.mk"
216 .include "../../mk/bsd.pkg.mk"