Makefile 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. # $OpenBSD: Makefile,v 1.149 2017/06/05 20:20:49 sthen Exp $
  2. COMMENT = compiler for the functional language Haskell
  3. # Note: please never ever set DPB_PROPERTIES=parallel (or some other
  4. # magic that enables parallel builds) for this port! Not even if it
  5. # appears to work. (search the upstream bug tracker for terms like
  6. # "non-deterministic", "unresolved symbol", "signature mismatch" etc. to
  7. # find the appropriate bug tickets)
  8. # ghc hardcodes ${WRKDIR}/bin/gcc when the package is compiled with ccache
  9. NO_CCACHE = Yes
  10. DISTNAME = ghc-${MODGHC_VER}
  11. REVISION = 9
  12. CATEGORIES = lang devel
  13. HOMEPAGE = https://www.haskell.org/ghc/
  14. # Version of the precompiled binaries
  15. BIN_VER = 7.10.2.20170417
  16. # Pull in lang/ghc to get MODGHC_VER and ONLY_FOR_ARCHS, which is maintained
  17. # in ghc.port.mk. lang/python needed for regression tests.
  18. MODULES = lang/ghc lang/python
  19. # BSD w/o advertising clause + LGPLv3 (from libgmp).
  20. # Distfile is bundled with other stuff like libffi, mingw
  21. # binaries, with BSD, GPLv2 and Perl artistic license.
  22. PERMIT_PACKAGE_CDROM = Yes
  23. LIB_DEPENDS = converters/libiconv
  24. BUILD_DEPENDS = archivers/gtar \
  25. textproc/docbook-xsl
  26. RUN_DEPENDS =
  27. # We can't use the wrapper script, because it then gets hardcoded into
  28. # the packaged ghc. So we explicitely use -Wl,-z,wxneeded (see
  29. # CONFIGURE_ENV below)
  30. USE_WXNEEDED = special
  31. WANTLIB += c iconv m ncursesw pthread util
  32. MASTER_SITES = ${HOMEPAGE}dist/${MODGHC_VER}/ \
  33. ${HOMEPAGE}dist/stable/dist/
  34. MASTER_SITES0 = https://openbsd.dead-parrot.de/distfiles/
  35. DIST_SUBDIR = ghc
  36. BINDISTFILE = ${BINDISTFILE-${MACHINE_ARCH}}
  37. DISTFILES = ghc-${MODGHC_VER}b-src.tar.bz2 \
  38. ghc-${MODGHC_VER}b-testsuite.tar.bz2 \
  39. ${BINDISTFILE}
  40. .for m in amd64 i386
  41. BINDISTFILE-$m = ghc-${BIN_VER}-$m-unknown-openbsd.tar.bz2:0 \
  42. ghc-${BIN_VER}-shlibs-$m.tar.gz:0
  43. SUPDISTFILES += ${BINDISTFILE-$m}
  44. .endfor
  45. # Newest madness from the haskell world: packages are now stored in a
  46. # directory named after the package 'key', which is made out of an
  47. # abbreviation of the package name and the package version or whatever.
  48. # At this point, we can as well factor out package version numbers to
  49. # get smaller PLIST diffs for future updates.
  50. GHC_ITEMS = \
  51. CABAL 1.22.5.0 3ux67khMI118y6VpwrFnXN \
  52. ARRAY 0.5.1.0 67iodizgJQIIxYVTp4emlA \
  53. BASE 4.8.2.0 HQfYBxpPvuw8OunzQu6JGM \
  54. BINARY 0.7.5.0 3uXFWMoAGBg0xKP9MHKRwi \
  55. BIN_PACKAGE_DB 0.0.0.0 JPOxOw4FLalDxRNtBqZ2ji \
  56. BYTESTRING 0.10.6.0 6VWy06pWzJq9evDvK2d4w6 \
  57. CONTAINERS 0.5.6.2 2C3ZI8RgPO2LBMidXKTvIU \
  58. DEEPSEQ 1.4.1.1 6vMKxt5sPFR0XsbRWvvq59 \
  59. DIRECTORY 1.2.2.0 0hFG6ZxK1nk4zsyOqbNHfm \
  60. FILEPATH 1.4.0.0 Ey7a1in9roBAE8bUFJ5R9m \
  61. GHC 7.10.3 0AG9TOjDEtx4Ji3wSwHOBe \
  62. GHC_PRIM 0.4.0.0 8TmvWUcS1U1IKHT0levwg3 \
  63. HASKELINE 0.7.2.1 GGvi737nHHfG6zm2y7Rimi \
  64. HOOPL 3.10.0.2 FCWMV1gJiCi02IwN4CnRgk \
  65. HPC 0.6.0.2 FUjQx3d1H3dEEtLFWv7hFw \
  66. INTEGER_GMP 1.0.0.0 2aU3IZNMF9a7mQ0OzsZ0dS \
  67. PRETTY 1.1.2.0 JItwetRppk1H5Uq3xbjDGC \
  68. PROCESS 1.2.3.0 52AgREEfSrnJLlkGV9YZZJ \
  69. TEMPLATE_HASKELL 2.10.0.0 GJPvtLC64aA4c1Jl10o2qt \
  70. TERMINFO 0.4.0.1 6iVf4EBnOgfIaaOCLRs8jl \
  71. TIME 1.5.0.1 FTheb6LSxyX1UABIbBXRfn \
  72. TRANSFORMERS 0.4.2.0 GZTjP9K5WFq01xC9BAGQpF \
  73. UNIX 2.7.1.0 KZL8h98IqDM57kQSPo1mKx \
  74. XHTML 3000.2.1 0ACfOp3hebWD9jGWE4v4Gh
  75. .for _i _v _s in ${GHC_ITEMS}
  76. ${_i}_VER = ${_v}
  77. ${_i}_KEY = ${_s}
  78. SUBST_VARS += ${_i}_VER ${_i}_KEY
  79. .endfor
  80. USE_GMAKE = Yes
  81. USE_GROFF = Yes
  82. .if ${MACHINE_ARCH} == "i386"
  83. CFLAGS += -fno-pie
  84. .endif
  85. CONFIGURE_STYLE = gnu
  86. CONFIGURE_ARGS += --with-iconv-includes=${LOCALBASE}/include \
  87. --with-iconv-libraries=${LOCALBASE}/lib \
  88. --with-gcc="${CC}" \
  89. --with-clang="${CC}"
  90. # XXX: wxneeded is a hack. Fix rts/Linker.c, mmapForLinker() and
  91. # loadObj_() instead.
  92. GHC_CC_OPTS = -fno-pie -nopie
  93. CONFIGURE_ENV += CONF_CC_OPTS_STAGE0="${GHC_CC_OPTS}" \
  94. CONF_CC_OPTS_STAGE1="${GHC_CC_OPTS}" \
  95. CONF_CC_OPTS_STAGE2="${GHC_CC_OPTS}" \
  96. CONF_GCC_LINKER_OPTS_STAGE0="${GHC_CC_OPTS}" \
  97. CONF_GCC_LINKER_OPTS_STAGE1="${GHC_CC_OPTS} -Wl,-z,wxneeded" \
  98. CONF_GCC_LINKER_OPTS_STAGE2="${GHC_CC_OPTS} -Wl,-z,wxneeded"
  99. # Do not pick up gpatch
  100. CONFIGURE_ENV += ac_cv_path_PatchCmd=/usr/bin/patch
  101. # Since ghc-7.10, ghc does not run without HOME defined and pointing to
  102. # a writable directory, which would cause configure to fail (because it
  103. # still builds ghc-pwd). Set HOME to let a 7.10-bootstrapper work.
  104. CONFIGURE_ENV += HOME=${PORTHOME}
  105. MAKE_FLAGS += StripLibraries=YES \
  106. INSTALL_BIN_OPTS=-s \
  107. HSCOLOUR_SRCS=NO \
  108. BUILD_DOCBOOK_PDF=NO \
  109. BUILD_DOCBOOK_PS=NO
  110. # Thank god that they're only building compilers and no nuclear
  111. # power plants. Note that we do not override CREATE_DATA, because
  112. # it's now used for *changing* permissions instead of initially
  113. # creating the files, and because we remove them anyway in post-install
  114. # (they are re-created during pkg_add).
  115. FAKE_FLAGS += CREATE_SCRIPT="${INSTALL_SCRIPT} /dev/null " \
  116. INSTALL_DATA="${INSTALL_DATA} \$$1 \$$2 \$$3" \
  117. INSTALL_DIR="${INSTALL_DATA_DIR} \$$1" \
  118. INSTALL_DOC="${INSTALL_DATA} \$$1 \$$2 \$$3" \
  119. INSTALL_HEADER="${INSTALL_DATA} \$$1 \$$2 \$$3" \
  120. INSTALL_MAN="${INSTALL_MAN} \$$1 \$$2 \$$3" \
  121. INSTALL_PROGRAM="${INSTALL_PROGRAM} \$$1 \$$2 \$$3" \
  122. INSTALL_SCRIPT="${INSTALL_SCRIPT} \$$1 \$$2 \$$3" \
  123. INSTALL_SHLIB="${INSTALL} ${INSTALL_COPY} -S -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \$$1 \$$2 \$$3"
  124. # For mktexpk (via dvips when building the PostScript documentation):
  125. PORTHOME = ${WRKDIR}
  126. TEST_DEPENDS = print/ghostscript/gnu
  127. post-extract:
  128. cd ${WRKSRC}/libraries/unix && \
  129. mkdir -p System/OpenBSD && \
  130. install -m 644 ${FILESDIR}/Process.hsc System/OpenBSD
  131. BOOTSTRAP_SHLIBS = ${WRKDIR}/ghc-${BIN_VER}-shlibs-${MACHINE_ARCH}
  132. post-patch:
  133. # - Install a precompiled binary.
  134. cd ${WRKDIR}/ghc-${BIN_VER} && \
  135. LD_LIBRARY_PATH=${BOOTSTRAP_SHLIBS} \
  136. CONFIGURE_ENV=${CONFIGURE_ENV} \
  137. ./configure --prefix=${WRKDIR}/bootstrap \
  138. --with-gcc="${CC}" \
  139. --with-clang="${CC}" && \
  140. LD_LIBRARY_PATH=${BOOTSTRAP_SHLIBS} \
  141. ${MAKE_PROGRAM} install
  142. rm -rf ${WRKDIR}/ghc-${BIN_VER}
  143. # - Create some wrapper scripts setting LD_LIBRARY_PATH
  144. cd ${WRKDIR}/bin && \
  145. for f in $$(ls ../bootstrap/bin); do \
  146. ${INSTALL_SCRIPT} /dev/null $$f && \
  147. exec > $$f && \
  148. echo '#!/bin/sh' && \
  149. echo 'LD_LIBRARY_PATH=${BOOTSTRAP_SHLIBS} \' && \
  150. printf 'exec ${WRKDIR}/bootstrap/bin/%s "$$@"\n' "$$f"; \
  151. done
  152. post-install:
  153. cd ${PREFIX}/lib/ghc && \
  154. GHC_PKG="./bin/ghc-pkg --no-user-package-db --global-package-db ./package.conf.d" && \
  155. ${INSTALL_SCRIPT} /dev/null register.sh && \
  156. exec > register.sh && \
  157. echo '#!/bin/sh' && \
  158. echo 'p="$${0%/*}/bin/ghc-pkg --no-user-package-db --global-package-db $${0%/*}/package.conf.d"' && \
  159. for p in $$($$GHC_PKG dot | sed -n -e 's/^"\([^"]*\)" -> "\([^"]*\)"$$/\1 \2/p' | tsort -r); do \
  160. echo \$$p register --force - \<\< \'EOF\' && \
  161. $$GHC_PKG describe $$p | sed '/^pkgpath:$$/s@$$@ ${PKGPATH}@' && \
  162. echo EOF; \
  163. done && \
  164. ${INSTALL_SCRIPT} /dev/null unregister.sh && \
  165. exec > unregister.sh && \
  166. echo '#!/bin/sh' && \
  167. echo 'p="$${0%/*}/bin/ghc-pkg --no-user-package-db --global-package-db $${0%/*}/package.conf.d"' && \
  168. for p in $$($$GHC_PKG dot | sed -n -e 's/^"\([^"]*\)" -> "\([^"]*\)"$$/\1 \2/p' | tsort); do \
  169. echo \$$p unregister --force $$p; \
  170. done && \
  171. rm package.conf.d/* && \
  172. $$GHC_PKG recache
  173. do-test:
  174. ulimit -c 0 && \
  175. cd ${WRKSRC}/testsuite/tests && \
  176. exec ${SETENV} ${MAKE_ENV} HS_ENCODING=utf-8 \
  177. ${MAKE_PROGRAM} ${MAKE_FLAGS} \
  178. PYTHON="${MODPY_BIN}"
  179. # It doesn't matter wether this is the actual date of the bootstrapper
  180. # build. It's just used to get different distfiles whenever new
  181. # bootstrappers have to be built.
  182. BOOTSTRAP_DATE = 20170417
  183. # Create a bootstrapper. This compiles a stripped-down version of
  184. # ghc and creates a `bindist', i.e. a tarball with binaries that
  185. # can be used for bootstrapping.
  186. bootstrap: patch
  187. @if [ ! -x ${LOCALBASE}/bin/autoconf-2.61 ]; then \
  188. echo Please install autoconf-2.61.; \
  189. false; \
  190. fi
  191. @if [ ! -x ${LOCALBASE}/bin/automake-1.4 ]; then \
  192. echo Please install automake-1.4.; \
  193. false; \
  194. fi
  195. echo HSCOLOUR_SRCS=NO > ${WRKSRC}/mk/build.mk
  196. echo GhcLibHcOpts=-O -fasm >> ${WRKSRC}/mk/build.mk
  197. echo GhcStage1HcOpts=-O -fasm >> ${WRKSRC}/mk/build.mk
  198. echo GhcStage2HcOpts=-O -fasm >> ${WRKSRC}/mk/build.mk
  199. echo SplitObjs=NO >> ${WRKSRC}/mk/build.mk
  200. echo GhcLibWays=v >> ${WRKSRC}/mk/build.mk
  201. echo GhcRTSWays= >> ${WRKSRC}/mk/build.mk
  202. echo GhcWithInterpreter=NO >> ${WRKSRC}/mk/build.mk
  203. echo INTEGER_LIBRARY=integer-gmp2 >> ${WRKSRC}/mk/build.mk
  204. echo SRC_CC_OPTS+=-g -O0 >> ${WRKSRC}/mk/build.mk
  205. echo HADDOCK_DOCS=NO >> ${WRKSRC}/mk/build.mk
  206. echo LATEX_DOCS=NO >> ${WRKSRC}/mk/build.mk
  207. echo BUILD_DOCBOOK_HTML=NO >> ${WRKSRC}/mk/build.mk
  208. echo BUILD_DOCBOOK_PDF=NO >> ${WRKSRC}/mk/build.mk
  209. echo BUILD_DOCBOOK_PS=NO >> ${WRKSRC}/mk/build.mk
  210. echo GhcWithSMP=NO >> ${WRKSRC}/mk/build.mk
  211. echo LD_OPTS=-optl-static -optl-s >> ${WRKSRC}/mk/build.mk
  212. echo ${BOOTSTRAP_DATE} > ${WRKSRC}/VERSION_DATE
  213. env CONFIGURE_ENV=RELEASE=NO ${MAKE} configure
  214. env MAKE_ENV="AUTOCONF_VERSION=2.61 AUTOMAKE_VERSION=1.4" \
  215. ${MAKE} build ALL_TARGET="all binary-dist"
  216. mkdir -p ${WRKBUILD}/ghc-${MODGHC_VER}.${BOOTSTRAP_DATE}-shlibs-$$(arch -s)
  217. ldd ${WRKBUILD}/ghc/stage2/build/tmp/ghc-stage2 | \
  218. awk '$$NF ~ /^\/usr\/(local\/)?lib\// { print $$NF }' | \
  219. xargs -J % cp -p % ${WRKBUILD}/ghc-${MODGHC_VER}.${BOOTSTRAP_DATE}-shlibs-$$(arch -s)
  220. cd ${WRKBUILD} && \
  221. pax -wzf ghc-${MODGHC_VER}.${BOOTSTRAP_DATE}-shlibs-$$(arch -s){.tar.gz,}
  222. .include <bsd.port.mk>
  223. # Silence clang when used by ghc to process assembler files and gets
  224. # flags chat don't make sense for assembly mode. Also, silence warnings
  225. # about macro expansions producing 'defined' (occuring in
  226. # includes/rts/storage/ClosureMacros.h, which has already been fixed
  227. # upstream)
  228. .if ${PROPERTIES:Mclang}
  229. GHC_CC_OPTS += -Wno-unused-command-line-argument -Wno-expansion-to-defined
  230. .endif