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 for c in libraries/*/configure; do \
142 (cd `${DIRNAME} $$c` && ${SETENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
144 for i in inplace/lib/package.conf.d/*.conf \
145 */package.conf.inplace \
146 */*/package-data.mk \
147 */*/*/package-data.mk \
148 */*/*/*/package-data.mk; do \
149 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" \
150 -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
151 ${MV} -f $$i.tmp $$i; \
153 ${TOUCH} -r inplace/lib/package.conf.d \
154 inplace/lib/package.conf.d/*.conf \
155 */package.conf.inplace \
156 */*/package-data.mk \
157 */*/*/package-data.mk \
158 */*/*/*/package-data.mk \
159 compiler/stage?/build/Config.hs && \
162 ${WRKDIR}/stamp-bootstrap-ghc: ${WRKDIR}/stamp-rewrite-hc-paths
163 ${RUN} cd ${WRKDIR}/bootstrap/${DISTNAME} && \
164 ${PHASE_MSG} "Creating bootstrapping files for ${PKGNAME}" && \
165 ${BUILD_MAKE_CMD} bootstrapping-files && \
166 ${PHASE_MSG} "Building bootstrapping compiler for ${PKGNAME}" && \
167 ${BUILD_MAKE_CMD} all_ghc_stage2 && \
168 ${PHASE_MSG} "Building bootstrapping toolkit for ${PKGNAME}" && \
169 ${BUILD_MAKE_CMD} inplace/bin/ghc-pkg && \
170 ${BUILD_MAKE_CMD} inplace/lib/unlit && \
171 inplace/bin/ghc-pkg recache && \
172 ${CP} -f inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
173 ${CP} -f inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg && \
177 ${RUN} cd ${WRKSRC} && \
178 ${SETENV} ${CONFIGURE_ENV} ./configure ${CONFIGURE_ARGS}
179 # We need to tell the libraries/terminfo/configure that our ncurses is
180 # in a non-standard path. Without that, the resulting GHC tries to
181 # link programs by executing ld(1) without passing it -L${PREFIX}/lib.
182 ${RUN} ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \
183 --configure-option=--with-curses-includes=${PREFIX}/include \
184 --configure-option=--with-curses-libraries=${PREFIX}/lib" >> ${WRKSRC}/mk/build.mk
185 # The ghc compiler does normally split the generated asm files into small
186 # parts before sending them to gcc, to enable the linker to eliminate
187 # unused parts. This does however not play nice with the pkgsrc
188 # framework, and the result is that the build takes more than 5 times
189 # as long than when the files are not split. See
190 # http://mail-index.netbsd.org/tech-pkg/2006/07/30/0005.html
191 # for a description of the problem.
192 # Disable file splitting until pkgsrc gets improved.
193 ${RUN} ${ECHO} "SplitObjs = NO" >> ${WRKSRC}/mk/build.mk
194 # If we don't explicitly disable HsColour, PLIST gets changed
195 # depending on whether we have installed it or not.
196 ${RUN} ${ECHO} "HSCOLOUR_SRCS = NO" >> ${WRKSRC}/mk/build.mk
198 # Substitutions for INSTALL and DEINSTALL.
199 FILES_SUBST+= DISTNAME=${DISTNAME}
201 # There is an unused script which don't pass the portability test.
202 CHECK_PORTABILITY_SKIP+= distrib/prep-bin-dist-mingw
204 # GHC currently *requires* ${PREFIX}/lib to be in
205 # "/etc/ld-elf.so.conf". See
206 # http://hackage.haskell.org/trac/ghc/ticket/2933
207 CHECK_SHLIBS_SUPPORTED= no
209 # I guess pdcurses works well but not tested.
211 .include "../../devel/ncurses/buildlink3.mk"
213 BUILD_DEPENDS+= docbook-xsl-[0-9]*:../../textproc/docbook-xsl
214 BUILDLINK_DEPMETHOD.libxslt = build
215 .include "../../converters/libiconv/buildlink3.mk"
216 .include "../../devel/gmp/buildlink3.mk"
217 .include "../../textproc/libxslt/buildlink3.mk"
218 .include "../../mk/pthread.buildlink3.mk"
219 .include "../../mk/bsd.pkg.mk"