1 # Created by: Simon Marlow <simonmar@microsoft.com>
4 PORTVERSION= ${GHC_VERSION}
6 CATEGORIES= lang haskell
7 MASTER_SITES= https://www.haskell.org/ghc/dist/${PORTVERSION}/:source \
8 http://leaf.dragonflybsd.org/~marino/dports-src/:dflyboot \
10 https://hackage.haskell.org/package/hscolour-${HSCOLOUR_VERSION}/:docs
11 DISTFILES= ghc-${PORTVERSION}-src${EXTRACT_SUFX}:source \
12 hscolour-${HSCOLOUR_VERSION}.tar.gz:docs
13 EXTRACT_ONLY= ${_DISTFILES:C/hscolour.*$//g}
15 MAINTAINER= haskell@FreeBSD.org
16 COMMENT= Compiler for the functional language Haskell
19 LICENSE_FILE= ${WRKSRC}/LICENSE
21 ONLY_FOR_ARCHS= amd64 i386 aarch64 armv6 armv7 powerpc64
23 USES= autoreconf compiler:c11 gmake iconv:translit \
24 localbase:ldflags ncurses perl5 tar:xz
25 USE_LOCALE= en_US.UTF-8
28 CONFIGURE_ARGS= --with-iconv-includes=${LOCALBASE}/include \
29 --with-iconv-libraries=${LOCALBASE}/lib
30 CONFIGURE_ENV= CC=${CC} LD=${LD} PATH=${SLAVES_PREFIX}/bin:${PATH}
31 MAKE_ENV= PATH=${SLAVES_PREFIX}/bin:${PATH}
34 SUB_LIST= GHC_VERSION=${GHC_VERSION} \
35 NCURSESINC="${NCURSESBASE}/include" NCURSESLIB="${NCURSESLIB}" \
38 OPTIONS_GROUP= BOOTSTRAP
39 BOOTSTRAP_DESC= Bootsrap using installed ghc
40 OPTIONS_GROUP_BOOTSTRAP=BOOT
41 OPTIONS_DEFINE= DYNAMIC GMP PROFILE DOCS
44 OPTIONS_DEFAULT= DYNAMIC PROFILE GMP
46 BOOT_DESC= Use installed GHC for bootstrapping
47 DOCS_DESC= Install HTML documentation
48 DYNAMIC_DESC= Add support for dynamic linking
49 GMP_DESC= Use GNU Multi-precision Library for big integers support
50 PROFILE_DESC= Add support for performance profiling
52 DOCS_BUILD_DEPENDS= sphinx-build:textproc/py-sphinx
54 DYNAMIC_CONFIGURE_WITH= system-libffi \
55 ffi-includes=${LOCALBASE}/include \
56 ffi-libraries=${LOCALBASE}/lib
57 DYNAMIC_LIB_DEPENDS= libffi.so:devel/libffi
58 DYNAMIC_SUB_LIST= WITH_DYNAMIC="YES"
59 DYNAMIC_SUB_LIST_OFF= WITH_DYNAMIC="NO"
60 DYNAMIC_PLIST_SUB= NODYNAMIC="@comment "
61 DYNAMIC_PLIST_SUB_OFF= NODYNAMIC=""
63 GMP_CONFIGURE_WITH= gmp-includes=${LOCALBASE}/include \
64 gmp-libraries=${LOCALBASE}/lib
65 GMP_LIB_DEPENDS= libgmp.so:math/gmp
66 GMP_SUB_LIST= INTEGER_LIBRARY="integer-gmp"
67 GMP_SUB_LIST_OFF= INTEGER_LIBRARY="integer-simple"
68 GMP_PLIST_SUB= GMP="" SIMPLE="@comment "
69 GMP_PLIST_SUB_OFF= GMP="@comment " SIMPLE=""
71 # Append substitutions for build.mk
72 BOOT_SUB_LIST= HSC2HS=${LOCALBASE}/bin/hsc2hs
73 BOOT_SUB_LIST_OFF= HSC2HS=${BOOT_HSC2HS}
75 PROFILE_SUB_LIST= WITH_PROFILE="YES"
76 PROFILE_SUB_LIST_OFF= WITH_PROFILE="NO"
79 CABAL_VERSION= 3.2.1.0
80 HSCOLOUR_VERSION= 1.24.4
82 # LLVM version that bootstrap compiler uses
85 PLIST_SUB= GHC_VERSION=${GHC_VERSION} CABAL_VERSION=${CABAL_VERSION}
89 .include <bsd.port.pre.mk>
91 # This version of ncurses is needed by bootstrap compiler
92 .if ${OPSYS} == FreeBSD
93 .if ${OSVERSION} > 1300078 && empty(PORT_OPTIONS:MBOOT) && ${ARCH} != powerpc64
94 BUILD_DEPENDS+= ${LOCALBASE}/lib/compat/libncursesw.so.8:misc/compat12x
98 .if ${ARCH} == powerpc64
99 CONFIGURE_ARGS+= --enable-dtrace=0
102 .if defined(PPC_ABI) && ${PPC_ABI} == ELFv1
103 BOOT_GHC_VERSION= 8.6.3
104 .elif ${ARCH} == aarch64 || ${ARCH:Marmv*}
105 BOOT_GHC_VERSION= 8.10.4
107 BOOT_GHC_VERSION= 8.6.5
110 NO_CCACHE= ccache: error: Failed to create directory /nonexistent/.ccache/tmp: Permission denied
112 DOCSDIR= ${PREFIX}/share/doc/${DISTNAME}
113 DATADIR= ${PREFIX}/share/ghc-${GHC_VERSION}
114 EXAMPLESDIR= ${PREFIX}/share/examples/ghc-${GHC_VERSION}
115 GHC_ARCH= ${ARCH:S/amd64/x86_64/:C/armv.*/arm/}
116 GHC_LIBDIR= ${STAGEDIR}${PREFIX}/lib/ghc-${GHC_VERSION}
117 GHC_LIBDIR_REL= lib/ghc-${GHC_VERSION}
119 _EXECUTABLES= ${GHC_LIBDIR}/bin/unlit \
120 ${GHC_LIBDIR}/bin/hpc \
121 ${GHC_LIBDIR}/bin/ghc-iserv \
122 ${GHC_LIBDIR}/bin/ghc-pkg \
123 ${GHC_LIBDIR}/bin/hsc2hs \
124 ${GHC_LIBDIR}/bin/runghc \
125 ${GHC_LIBDIR}/bin/ghc \
126 ${GHC_LIBDIR}/bin/haddock \
127 ${GHC_LIBDIR}/bin/hp2ps
129 .if ${PORT_OPTIONS:MPROFILE}
130 _EXECUTABLES+= ${GHC_LIBDIR}/bin/ghc-iserv-prof
132 .if ${PORT_OPTIONS:MDYNAMIC}
133 _EXECUTABLES+= ${GHC_LIBDIR}/bin/ghc-iserv-dyn
136 .if empty(PORT_OPTIONS:MBOOT) && ${OPSYS} == "FreeBSD"
137 BOOTSTRAPS_SUFFIX?= ${BOOTSTRAPS_SUFFIX_${ARCH}}
138 BOOTSTRAPS_SUFFIX_powerpc64?= -${PPC_ABI:tl}
139 . if ${OSVERSION} < 1200000 && (${ARCH} == x86_64 || ${ARCH} == i386)
142 DISTFILES+= ghc-${BOOT_GHC_VERSION}-boot-${ARCH}-freebsd${BOOTSTRAPS_SUFFIX}${ELEVEN_SUFX}${EXTRACT_SUFX}:boot
145 .if ${ARCH} == aarch64 || ${ARCH:Marmv*}
146 # ghc-8.10.x on arm requires devel/llvm90
147 # CONFIGURE_TARGET must to be the same as the llvm triple
148 CONFIGURE_TARGET= ${ARCH}-unknown-freebsd${"${ARCH:Maarch64}" != "":?:-gnueabihf}
149 EXTRA_PATCHES+= ${PATCHDIR}/extra-patch-aclocal.m4
150 BUILD_DEPENDS+= llc${LLVM_VERSION}:devel/llvm${LLVM_VERSION}
151 RUN_DEPENDS+= llc${LLVM_VERSION}:devel/llvm${LLVM_VERSION}
152 CONFIGURE_ENV+= LLC=llc${LLVM_VERSION} \
153 OPT=opt${LLVM_VERSION} \
154 CLANG=clang${LLVM_VERSION} \
155 CC=clang${LLVM_VERSION}
157 # When GHC being compiled and GHC used for bootstrapping support different
158 # LLVM versions, we have to pull in both. Luckily, this is relatively rare.
159 . if ${BOOT_LLVM_VERSION} != ${LLVM_VERSION}
160 BUILD_DEPENDS+= llc${BOOT_LLVM_VERSION}:devel/llvm${BOOT_LLVM_VERSION}
161 # Keep in sync with BOOT_LLVM_VERSION
162 BINARY_ALIAS+= llc-9.0=llc90 \
167 .if ${ARCH} == aarch64 || ${ARCH:Marmv*} || ${ARCH} == powerpc64
168 . if ${OSVERSION} < 1202000
169 IGNORE= lang/ghc requires at least FreeBSD 12.2-RELEASE
171 . ifdef QEMU_EMULATING
172 IGNORE= qemu-user-static isn't able to build lang/ghc, but it builds fine on a real hardware
176 .if empty(PORT_OPTIONS:MBOOT)
177 BOOT_DIR= ${WRKDIR}/ghc-${BOOT_GHC_VERSION}-boot
178 BOOT_GHC= ${BOOT_DIR}/bin/ghc-${BOOT_GHC_VERSION}
179 BOOT_GHC-PKG= ${BOOT_DIR}/bin/ghc-pkg-${BOOT_GHC_VERSION}
180 BOOT_HSC2HS= ${BOOT_DIR}/bin/hsc2hs
182 SLAVE_ENV= ${SETENV} PATH=${BOOT_DIR}/bin:${PATH}
184 CONFIGURE_ARGS+= GHC=${BOOT_GHC}
187 CONFIGURE_ARGS+= GHC=${LOCALBASE}/bin/ghc
190 .if empty(PORT_OPTIONS:MBOOT) && ${OPSYS} == "DragonFly"
191 BUILD_DEPENDS+= libtinfow-compat>0:misc/libtinfow-compat
192 BOOT_GHC_VERSION= 8.8.4
193 DISTFILES+= ghc-${BOOT_GHC_VERSION}-boot-${ARCH}-dragonfly.tar.xz:dflyboot
194 CONFIGURE_TARGET= ${ARCH}-portbld-dragonfly
195 CONFIGURE_ENV+= BOOTDIR=${BOOT_DIR} LBASE=${LOCALBASE}
197 CONFIGURE_ARGS+= --target=${CONFIGURE_TARGET}
198 LLVM_VERSION:= ${LLVM_DEFAULT}
199 # for bootstrap only disable all OPTIONS_DEFAULT except for GMP, previous boots used devel/libffi321
201 CONFIGURE_ARGS+= --with-intree-gmp
206 # avoid "sed: RE error: Illegal byte sequence" in bootstrap configure script, smth fishy
207 # upstream configure does not support target x86_64-unknown-dragonfly5.9, resed solaris2
208 BUILD_DEPENDS+= gsed:textproc/gsed
210 ${REINPLACE_CMD} -e 's@solaris2\*@dragonfly*@g' -e 's@"solaris2"@"dragonfly"@g' \
211 ${WRKSRC}/configure # this is fragile, but avoid patch-configure diffs...
212 ${REINPLACE_CMD} -e 's@solaris2\*@dragonfly*@g' -e 's@"solaris2"@"dragonfly"@g' \
213 ${BOOT_DIR}/configure
214 # ${REINPLACE_CMD} -e 's@[[:<:]]sed[[:>:]]@gsed@g' \
215 # ${BOOT_DIR}/configure
218 SLAVES_PREFIX= ${WRKDIR}/slaves_prefix
219 SLAVES_WRKDIRPREFIX= ${WRKDIR}/slaves_wrkdirprefix
222 @${REINPLACE_CMD} -e 's|%%CC%%|${CC}|; \
225 ${WRKSRC}/libraries/Cabal/Cabal/Distribution/Simple/Program/Builtin.hs
227 .if empty(PORT_OPTIONS:MBOOT) && ${OPSYS} == "FreeBSD"
228 @${REINPLACE_CMD} -e '/^mandir/d' ${BOOT_DIR}/mk/build.mk
229 @${REINPLACE_CMD} -e '/^infodir/d' ${BOOT_DIR}/mk/build.mk
230 @${REINPLACE_CMD} -e '/^docdir/d' ${BOOT_DIR}/mk/build.mk
231 @${REINPLACE_CMD} -e '/^htmldir/d' ${BOOT_DIR}/mk/build.mk
234 .if ${ARCH} == powerpc64 && ${PPC_ABI} == ELFv2
235 @${REINPLACE_CMD} -e 's/ELF_V1/ELF_V2/' \
236 ${WRKSRC}/configure ${WRKSRC}/aclocal.m4
239 pre-configure: apply-slist
240 # Copy the subbed build.mk to the proper position
241 ${CP} ${WRKDIR}/build.mk ${WRKSRC}/mk/build.mk
243 # If we are using bootstrap compiler, configure and install it into ${BOOT_DIR}
244 .if empty(PORT_OPTIONS:MBOOT)
245 cd ${BOOT_DIR} && ${CONFIGURE_ENV} ${CONFIGURE_CMD} --prefix=${BOOT_DIR}
246 cd ${BOOT_DIR} && PACKAGES='' ${MAKE_CMD} install
248 # otherwise, make sure we have "ghc" in PATH
249 if ! ${WHICH} -s ghc ; then \
250 echo "No 'ghc' executable is found in your PATH! Turn off BOOT option." ; false ; \
253 # If DOCS are set, install HsColour in-place
254 .if ${PORT_OPTIONS:MDOCS}
255 ${MKDIR} ${SLAVES_PREFIX}
256 ${MKDIR} ${SLAVES_WRKDIRPREFIX}
258 cd ${SLAVES_WRKDIRPREFIX} && \
259 ${TAR} xvf ${DISTDIR}/hscolour-${HSCOLOUR_VERSION}.tar.gz && \
260 cd hscolour-${HSCOLOUR_VERSION} && \
261 ${SLAVE_ENV} ghc --make -o Setup Setup.hs -package Cabal && \
262 ${SLAVE_ENV} ./Setup configure --ghc --prefix=${SLAVES_PREFIX} --with-gcc=${CC} --with-ld=${LD} && \
263 ${SLAVE_ENV} ./Setup build && \
264 ${SLAVE_ENV} ./Setup install
268 (for f in ${_EXECUTABLES} $$(${FIND} ${GHC_LIBDIR} -name '*.so*'); do \
269 ${STRIP_CMD} $$f; done)
270 ${RM} -r ${STAGEDIR}${DOCSDIR}/html/haddock/.build-html
271 ${RM} ${STAGEDIR}${PREFIX}/bin/haddock
275 ${BOOT_DIR}/bin/runhaskell ${PATCHDIR}/fixup-plist.hs ${.CURDIR}/pkg-plist
277 # Create a bootstrap compiler tar ball: run this in an interactive poudriere jail
278 # Set all OPTIONS to OFF when generating bootstraps
279 .PHONY: create-bootstrap
282 && ${ECHO} "BIN_DIST_NAME=ghc-${GHC_VERSION}-boot" >> mk/build.mk \
283 && ${ECHO} "BIN_DIST_TAR=ghc-${GHC_VERSION}-boot.tar" >> mk/build.mk \
284 && ${ECHO} "HADDOCK_DOCS=NO" >> mk/build.mk \
285 && ${GMAKE} binary-dist TAR_COMP=xz \
286 && ${MV} ${WRKSRC}/ghc-${GHC_VERSION}-boot-${GHC_ARCH}-portbld-freebsd.tar.xz /tmp/ghc-${GHC_VERSION}-boot-${ARCH}-freebsd.tar.xz
289 && sha256 ghc-${GHC_VERSION}-boot-${ARCH}-freebsd.tar.xz \
290 && ${ECHO} -n "SIZE (ghc-${GHC_VERSION}-boot-${ARCH}-freebsd.tar.xz) = " \
291 && ${STAT} -f %z ghc-${GHC_VERSION}-boot-${ARCH}-freebsd.tar.xz
293 # Much like create-bootstrap, just different naming and output format
294 # Set DYNAMIC, GMP and PROFILE to ON, and DOCS to OFF when generating Stack bindist
295 .PHONY: create-stack-bindist
296 create-stack-bindist:
297 ${REINPLACE_CMD} -e '/^mandir/d' \
301 ${WRKSRC}/mk/build.mk
304 && ${GMAKE} binary-dist TAR_COMP=xz \
305 && ${MV} ${WRKSRC}/ghc-${GHC_VERSION}-${GHC_ARCH}-portbld-freebsd.tar.xz /tmp/
308 && ${ECHO} "${GHC_VERSION}:" \
309 && ${ECHO} "url: \"http://distcache.FreeBSD.org/local-distfiles/arrowd/stack-bindists/ghc-${GHC_VERSION}-${GHC_ARCH}-portbld-freebsd.tar.xz\"" \
310 && ${ECHO} -n "content-length: " \
311 && ${STAT} -f %z ghc-${GHC_VERSION}-${GHC_ARCH}-portbld-freebsd.tar.xz \
312 && ${ECHO} -n "sha1: " \
313 && sha1 -q ghc-${GHC_VERSION}-${GHC_ARCH}-portbld-freebsd.tar.xz \
314 && ${ECHO} -n "sha256: " \
315 && sha256 -q ghc-${GHC_VERSION}-${GHC_ARCH}-portbld-freebsd.tar.xz
317 .include <bsd.port.post.mk>