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 ${DISTNAME}-boot-i386-unknown-freebsd.tar.bz2 \
14 ${DISTNAME}-boot-i386-unknown-netbsd.tar.bz2 \
15 ${DISTNAME}-boot-powerpc-apple-darwin.tar.bz2
17 SITES.${DISTNAME}-src.tar.bz2 = http://www.haskell.org/ghc/dist/${VERSION}/
18 SITES.${DISTNAME}-boot-i386-unknown-netbsd.tar.bz2 = http://static.cielonegro.org/archive/
19 SITES.${DISTNAME}-boot-i386-unknown-freebsd.tar.bz2 = http://static.cielonegro.org/archive/
20 SITES.${DISTNAME}-boot-powerpc-apple-darwin.tar.bz2 = http://static.cielonegro.org/archive/
22 PKG_DESTDIR_SUPPORT= user-destdir
24 .include "../../mk/bsd.prefs.mk"
26 # Unregisterised HC packages are architecture dependent. We have to
27 # create more HC packages to support more architectures. Note that
28 # these packages are built with integer-simple, not integer-gmp, to
29 # reduce some complexity by not depending on the GMP. The resulting
30 # registerised GHC uses integer-gmp so this won't be a problem.
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 better
36 .include "../../mk/compiler.mk"
38 WARNINGS+= "This package depends on pkgsrc's undocumented variable\
39 CCPATH but it disappeared somehow."
40 WARNINGS+= "Using hard-coded /usr/bin/gcc as the C compiler..."
41 CONFIGURE_ARGS+= --with-gcc=/usr/bin/gcc
43 CONFIGURE_ARGS+= --with-gcc=${CCPATH}
46 USE_TOOLS+= gmake bsdtar perl:run
47 CONFIGURE_ENV+= PerlCmd=${PERL5:Q}
49 # We don't want to extract all of the DISTFILEs.
50 EXTRACT_ONLY= ${DISTNAME}-src.tar.bz2
55 --target=${PLATFORM} \
57 --mandir=${PREFIX}/${PKGMANDIR} \
58 --with-gmp-includes=${PREFIX}/include \
59 --with-gmp-libraries=${PREFIX}/lib \
60 --with-iconv-includes=${PREFIX}/include \
61 --with-iconv-libraries=${PREFIX}/lib
63 # Build an unregisterised bootstrap compiler and install it directly
64 # into the .buildlink directory. But we can't use "make install"
65 # because we don't build it in a standard way (./configure && make).
67 # To install it, we just copy ghc and ghc-pkg from
68 # "work/bootstrap/ghc-${VERSION}/inplace/bin" to
69 # "${BUILDLINK_DIR}/bin". Note that in-place ghc isn't usable before
70 # running "ghc-pkg recache".
72 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
73 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
74 PLATFORM = i386-unknown-netbsd
76 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
77 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
78 PLATFORM = i386-unknown-freebsd
80 .elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
81 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap.mk
82 PLATFORM = powerpc-apple-darwin
84 # Existence of libelf makes LeadingUnderscore being "NO", which is
85 # incorrect. See ghc-6.12.1/aclocal.m4 (FP_LEADING_UNDERSCORE)
86 CONFLICTS= libelf-[0-9]*
89 PKG_FAIL_REASON+= "internal error: unsupported platform"
92 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-${PLATFORM}.tar.bz2
95 ${RUN} cd ${WRKDIR} && \
96 ${ECHO} "====> Preparing bootstrap compiler" && \
97 ${MKDIR} bootstrap && \
98 ${CP} -r ${DISTNAME} bootstrap && \
99 cd bootstrap/${DISTNAME} && \
100 ${LN} -sf ${PWD_CMD} utils/ghc-pwd/ghc-pwd && \
101 ${ECHO} "====> Configuring for bootstrap compiler" && \
102 ${SETENV} ${CONFIGURE_ENV} ./configure --enable-hc-boot --with-ghc="" ${CONFIGURE_ARGS} && \
103 ${ECHO} "====> Extracting bootstrap HC archive" && \
104 (cd .. && bsdtar jxfm ${DISTDIR}/${BOOTSTRAP_TARBALL}) && \
106 ${ECHO} "====> Building bootstrap compiler" && \
107 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" ${BOOTSTRAP_BUILD_MK} > mk/build.mk && \
108 for c in libraries/*/configure; do \
109 (cd `${DIRNAME} $$c` && ${SETENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
111 for i in inplace/lib/package.conf.d/*.conf */*/package-data.mk */*/*/package-data.mk; do \
112 ${SED} -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
113 ${MV} -f $$i.tmp $$i; \
115 ${TOUCH} -r inplace/lib/package.conf.d */*/package-data.mk */*/*/package-data.mk && \
116 ${GMAKE} bootstrapping-files && \
117 ${GMAKE} all_ghc_stage2 && \
118 ${GMAKE} inplace/bin/ghc-pkg && \
119 ${GMAKE} inplace/lib/unlit && \
120 inplace/bin/ghc-pkg recache && \
121 ${CP} inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
122 ${CP} inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg
125 ${RUN} cd ${WRKSRC} && \
126 ${SETENV} ${CONFIGURE_ENV} ./configure ${CONFIGURE_ARGS}
127 # We need to tell the libraries/integer-gmp/configure that libgmp is
128 # in a non-standard path. Without that, the resulting GHC tries to
129 # link programs by executing ld(1) without passing it -L${PREFIX}/lib.
130 ${RUN} ${ECHO} "libraries/integer-gmp_CONFIGURE_OPTS += \
131 --configure-option=--with-gmp-includes=${PREFIX}/include \
132 --configure-option=--with-gmp-libraries=${PREFIX}/lib" > ${WRKSRC}/mk/build.mk
133 # The ncurses is also in a non-standard path.
134 ${RUN} ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \
135 --configure-option=--with-curses-includes=${PREFIX}/include \
136 --configure-option=--with-curses-libraries=${PREFIX}/lib" >> ${WRKSRC}/mk/build.mk
137 # The ghc compiler does normally split the generated C files into small
138 # parts before sending them to gcc, to enable the linker to eliminate
139 # unused parts. This does however not play nice with the pkgsrc
140 # framework, and the result is that the build takes more than 5 times
141 # as long than when the files are not split. See
142 # http://mail-index.netbsd.org/tech-pkg/2006/07/30/0005.html
143 # for a description of the problem.
144 # Disable file splitting until pkgsrc gets improved.
145 ${RUN} ${ECHO} "SplitObjs = NO" >> ${WRKSRC}/mk/build.mk
146 # If we don't explicitly disable HsColour, PLIST gets changed
147 # depending on whether we have installed it or not.
148 ${RUN} ${ECHO} "HSCOLOUR_SRCS = NO" >> ${WRKSRC}/mk/build.mk
149 # To avoid powerpc crash...
150 # See http://hackage.haskell.org/trac/ghc/ticket/4034
151 .if ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
152 ${RUN} ${ECHO} "GhcRtsHcOpts = -optc-O0 -optc-g" >> ${WRKSRC}/mk/build.mk
153 ${RUN} ${ECHO} "GhcRtsCcOpts = -O0 -g" >> ${WRKSRC}/mk/build.mk
157 # We have to sacrifice the GHCi library for GHC itself to work around
158 # for powerpc ld bug. See
159 # http://hackage.haskell.org/trac/ghc/ticket/3260
160 .if ${MACHINE_ARCH} == "powerpc"
161 ${RUN} ${MKDIR} ${WRKSRC}/compiler/stage1/build
162 ${RUN} ${TOUCH} -t `expr \`date '+%Y'\` + 1`12310000 \
163 ${WRKSRC}/compiler/stage1/build/HS${DISTNAME}.o
164 ${RUN} ${MKDIR} ${WRKSRC}/compiler/stage2/build
165 ${RUN} ${TOUCH} -t `expr \`date '+%Y'\` + 1`12310000 \
166 ${WRKSRC}/compiler/stage2/build/HS${DISTNAME}.o
169 .if ${MACHINE_ARCH} == "powerpc"
170 WARNINGS+= "You won't be able to use GHCi library for GHC itself\
171 because of powerpc ld bug."
174 # Some unused scripts don't pass the portability test.
175 CHECK_PORTABILITY_SKIP+= distrib/prep-bin-dist-mingw
177 # GHC currently *requires* ${PREFIX}/lib to be in
178 # "/etc/ld-elf.so.conf". See
179 # http://hackage.haskell.org/trac/ghc/ticket/2933
180 CHECK_SHLIBS_SUPPORTED= no
182 # I guess pdcurses works well but not tested.
184 .include "../../devel/ncurses/buildlink3.mk"
186 BUILD_DEPENDS+= docbook-xsl-[0-9]*:../../textproc/docbook-xsl
187 BUILDLINK_DEPMETHOD.libxslt = build
188 .include "../../converters/libiconv/buildlink3.mk"
189 .include "../../devel/gmp/buildlink3.mk"
190 .include "../../textproc/libxslt/buildlink3.mk"
191 .include "../../mk/pthread.buildlink3.mk"
192 .include "../../mk/bsd.pkg.mk"