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-netbsd.tar.bz2 \
14 ${DISTNAME}-boot-i386-unknown-freebsd.tar.bz2
16 SITES.${DISTNAME}-src.tar.bz2 = http://www.haskell.org/ghc/dist/${VERSION}/
17 SITES.${DISTNAME}-boot-i386-unknown-netbsd.tar.bz2 = http://static.cielonegro.org/archive/
18 SITES.${DISTNAME}-boot-i386-unknown-freebsd.tar.bz2 = http://static.cielonegro.org/archive/
20 PKG_DESTDIR_SUPPORT= user-destdir
22 .include "../../mk/bsd.prefs.mk"
24 # Unregisterised HC packages are architecture dependent. We have to
25 # create more HC packages to support more architectures.
26 ONLY_FOR_PLATFORM= NetBSD-*-i386 FreeBSD-*-i386
27 # Note: Darwin-*-powerpc is temporarily disabled for now. It shall
28 # come back in the near future. Thanks for your patience.
30 # We must provide the real pass to gcc to the ./configure script,
31 # because GHC has a runtime dependency on it. Aren't there any better
33 .include "../../mk/compiler.mk"
35 WARNINGS+= "This package depends on pkgsrc's undocumented variable CCPATH but it disappeared somehow."
36 WARNINGS+= "Using hard-coded /usr/bin/gcc as the C compiler..."
37 CONFIGURE_ARGS+= --with-gcc=/usr/bin/gcc
39 CONFIGURE_ARGS+= --with-gcc=${CCPATH}
42 USE_TOOLS+= gmake bsdtar perl:run
43 CONFIGURE_ENV+= PerlCmd=${PERL5:Q}
45 # We don't want to extract all of the DISTFILEs.
46 EXTRACT_ONLY= ${DISTNAME}-src.tar.bz2
50 --mandir=${PREFIX}/${PKGMANDIR} \
51 --with-gmp-includes=${PREFIX}/include \
52 --with-gmp-libraries=${PREFIX}/lib \
53 --with-iconv-includes=${PREFIX}/include \
54 --with-iconv-libraries=${PREFIX}/lib
56 # Build an unregisterised bootstrap compiler and install it directly
57 # into the .buildlink directory. But we can't use "make install"
58 # because we don't build it in a standard way (./configure && make).
60 # To install it, we just copy ghc and ghc-pkg from
61 # "work/bootstrap/ghc-${VERSION}/inplace/bin" to
62 # "${BUILDLINK_DIR}/bin". Note that in-place ghc isn't usable before
63 # running "ghc-pkg recache".
65 .if ${MACHINE_ARCH} == "i386" && ${OPSYS} == "NetBSD"
66 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-netbsd.tar.bz2
67 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
69 .elif ${MACHINE_ARCH} == "i386" && ${OPSYS} == "FreeBSD"
70 BOOTSTRAP_TARBALL = ${DISTNAME}-boot-i386-unknown-freebsd.tar.bz2
71 BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap-bsd.mk
73 #.elif ${MACHINE_ARCH} == "powerpc" && ${OPSYS} == "Darwin"
74 #BOOTSTRAP_TARBALL = ${DISTNAME}-boot-powerpc-apple-darwin.tar.bz2
75 #BOOTSTRAP_BUILD_MK = ${PKGDIR}/files/bootstrap.mk
78 PKG_FAIL_REASON+= "internal error: unsupported platform"
82 ${RUN} cd ${WRKDIR} && \
83 ${ECHO} "====> Preparing bootstrap compiler" && \
84 ${MKDIR} bootstrap && \
85 ${CP} -r ${DISTNAME} bootstrap && \
86 cd bootstrap/${DISTNAME} && \
87 ${LN} -sf ${PWD_CMD} utils/ghc-pwd/ghc-pwd && \
88 ${ECHO} "====> Configuring for bootstrap compiler" && \
89 ${ENV} ${CONFIGURE_ENV} ./configure --enable-hc-boot ${CONFIGURE_ARGS} && \
90 ${ECHO} "====> Extracting bootstrap HC archive" && \
91 (cd .. && bsdtar jxfm ${DISTDIR}/${BOOTSTRAP_TARBALL}) && \
93 ${ECHO} "====> Building bootstrap compiler" && \
94 ${SED} -e "s#\\[\\[PREFIX\\]\\]#${PREFIX}#g" ${BOOTSTRAP_BUILD_MK} > mk/build.mk && \
95 for c in libraries/*/configure; do \
96 (cd `${DIRNAME} $$c` && ${ENV} ${CONFIGURE_ENV} ${SH} configure ${CONFIGURE_ARGS}); \
98 for i in inplace/lib/package.conf.d/*.conf */*/package-data.mk */*/*/package-data.mk; do \
99 ${SED} -e "s#\\[\\[GHC_SOURCE_PATH\\]\\]#`${PWD_CMD}`#g" $$i > $$i.tmp; \
100 ${MV} -f $$i.tmp $$i; \
102 ${TOUCH} -r inplace/lib/package.conf.d */*/package-data.mk */*/*/package-data.mk && \
103 ${GMAKE} bootstrapping-files && \
104 ${GMAKE} all_ghc_stage2 && \
105 ${GMAKE} inplace/bin/ghc-pkg && \
106 ${GMAKE} inplace/lib/unlit && \
107 inplace/bin/ghc-pkg recache && \
108 ${CP} inplace/bin/ghc-stage2 ${BUILDLINK_DIR}/bin/ghc && \
109 ${CP} inplace/bin/ghc-pkg ${BUILDLINK_DIR}/bin/ghc-pkg
111 # We need to tell the libraries/integer-gmp/configure that libgmp is
112 # in a non-standard path. Without that, the resulting GHC tries to
113 # link programs by executing ld(1) without passing it -L${PREFIX}/lib.
115 ${RUN} cd ${WRKSRC} && \
116 ${ENV} ${CONFIGURE_ENV} ./configure ${CONFIGURE_ARGS}
117 ${RUN} ${ECHO} "libraries/integer-gmp_CONFIGURE_OPTS += \
118 --configure-option=--with-gmp-includes=${PREFIX}/include \
119 --configure-option=--with-gmp-libraries=${PREFIX}/lib" > ${WRKSRC}/mk/build.mk
120 ${RUN} ${ECHO} "libraries/terminfo_CONFIGURE_OPTS += \
121 --configure-option=--with-curses-includes=${PREFIX}/include \
122 --configure-option=--with-curses-libraries=${PREFIX}/lib" >> ${WRKSRC}/mk/build.mk
124 # The ghc compiler does normally split the generated C files into small
125 # parts before sending them to gcc, to enable the linker to eliminate
126 # unused parts. This does however not play nice with the pkgsrc
127 # framework, and the result is that the build takes more than 5 times
128 # as long than when the files are not split. See
129 # http://mail-index.netbsd.org/tech-pkg/2006/07/30/0005.html
130 # for a description of the problem.
131 # Disable file splitting until pkgsrc gets improved.
133 ${RUN} ${ECHO} "SplitObjs = NO" >> ${WRKSRC}/mk/build.mk
135 # Some unused scripts don't pass the portability test.
136 CHECK_PORTABILITY_SKIP+= distrib/prep-bin-dist-mingw
138 # GHC currently *requires* ${PREFIX}/lib to be in
139 # "/etc/ld-elf.so.conf". See
140 # http://hackage.haskell.org/trac/ghc/ticket/2933
141 CHECK_SHLIBS_SUPPORTED= no
143 BUILDLINK_DEPMETHOD.libxslt = build
144 .include "../../converters/libiconv/buildlink3.mk"
145 .include "../../devel/gmp/buildlink3.mk"
146 .include "../../textproc/libxslt/buildlink3.mk"
147 .include "../../mk/termcap.buildlink3.mk"
148 .include "../../mk/pthread.buildlink3.mk"
149 .include "../../mk/bsd.pkg.mk"