ghc.port.mk 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # $OpenBSD: ghc.port.mk,v 1.40 2017/03/02 23:23:28 kili Exp $
  2. # Module for Glasgow Haskell Compiler
  3. # Not yet ported to other architectures
  4. ONLY_FOR_ARCHS = i386 amd64
  5. # Dependency of meta/haskell-platform.
  6. # Please do *not* update without thinking.
  7. MODGHC_VER = 7.10.3
  8. SUBST_VARS += MODGHC_VER
  9. MODGHC_BIN = ${LOCALBASE}/bin/ghc
  10. # The following is for depending ports only. GHC itself just needs
  11. # MODGHC_VER and ONLY_FOR_ARCHS. This is a little bit ugly, but
  12. # depending ports using CABAL tend to install into locations as
  13. # lib/Foo-${FooVersion}/ghc-${MODGHC_VER}, so they need the exact
  14. # version of ghc. Depending ports thus need full depends specs,
  15. # i.e. RUN_DEPENDS = lang/ghc=${MODGHC_VER}, and not
  16. # just lang/ghc.
  17. .if ${PKGPATH} != "lang/ghc"
  18. BUILD_DEPENDS += lang/ghc
  19. # Set to "cabal" to get the typical Cabal targets defined. Add "haddock"
  20. # to generate API documentation using Haddock. Add "register" to create
  21. # and include register/unregister scripts (you'll still have to add the
  22. # necessary tags to your PLIST by hand).
  23. # Add "nort" if the port doesn't depend on the GHC runtime. This will
  24. # also turn off the default "hs-" prefix for PKGNAME.
  25. # If "nort" is not added, MODGHC_PACKAGE_KEY may be set to the 'package
  26. # key' of the library built and will be added to SUBST_VARS.
  27. # Finally, set it to or add "hackage" if the distfiles are available on
  28. # hackage.haskell.org.
  29. MODGHC_BUILD ?=
  30. . if !${MODGHC_BUILD:L:Mnort}
  31. PKGNAME ?= hs-${DISTNAME}
  32. RUN_DEPENDS += lang/ghc=${MODGHC_VER}
  33. CATEGORIES += lang/ghc
  34. MODGHC_PACKAGE_KEY ?=
  35. . if ${MODGHC_PACKAGE_KEY} != ""
  36. SUBST_VARS += MODGHC_PACKAGE_KEY
  37. . endif
  38. . endif
  39. . if ${MODGHC_BUILD:L:Mhackage}
  40. MODGHC_HACKAGE_NAME = ${DISTNAME:C,-[0-9.]*$,,}
  41. MODGHC_HACKAGE_VERSION = ${DISTNAME:C,.*-([0-9.]*)$,\1,}
  42. HOMEPAGE ?= https://hackage.haskell.org/package/${MODGHC_HACKAGE_NAME}
  43. MASTER_SITES = https://hackage.haskell.org/package/${DISTNAME}/
  44. SUBST_VARS += DISTNAME MODGHC_HACKAGE_VERSION
  45. DIST_SUBDIR ?= ghc
  46. . endif
  47. . if ${MODGHC_BUILD:L:Mcabal}
  48. MODGHC_SETUP_SCRIPT ?= Setup.lhs Setup.hs
  49. MODGHC_SETUP_PROG ?= ${WRKSRC}/Setup
  50. MODGHC_SETUP_CONF_ARGS += --with-gcc="${CC}"
  51. MODGHC_SETUP_CONF_ENV ?=
  52. . if !${MODGHC_BUILD:L:Mnort}
  53. MODGHC_SETUP_CONF_ARGS += --datasubdir=hs-\$$pkgid
  54. MODGHC_SETUP_CONF_ARGS += --docdir=\$$datadir/doc/hs-\$$pkgid
  55. MODGHC_SETUP_CONF_ARGS += --libsubdir=ghc/\$$pkgid
  56. MODGHC_SETUP_CONF_ARGS += --enable-library-profiling
  57. . else
  58. # Override Cabal defaults, which are $arch-$os-$compiler/$pkgid for
  59. # datasubdir and libsubdir and $datadir/doc/$arch-$os-$compiler/$pkgid
  60. # for docdir.
  61. MODGHC_SETUP_CONF_ARGS += --datasubdir=\$$pkgid
  62. MODGHC_SETUP_CONF_ARGS += --libsubdir=\$$pkgid
  63. MODGHC_SETUP_CONF_ARGS += --docdir=\$$datadir/doc/\$$pkgid
  64. . endif
  65. # Little hack to let ports still add CONFIGURE_STYLE = autoconf and go
  66. # without a do-configure: target (some Haskell ports are built with
  67. # Cabal but use autohell for the documentation):
  68. MODCABAL_configure = \
  69. cd ${WRKSRC} && \
  70. for s in ${MODGHC_SETUP_SCRIPT}; do \
  71. test -f "$$s" && \
  72. ${MODGHC_BIN} --make \
  73. -o ${MODGHC_SETUP_PROG} "$$s" && \
  74. break; \
  75. done && \
  76. cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} ${MODGHC_SETUP_CONF_ENV} \
  77. ${MODGHC_SETUP_PROG} \
  78. configure -v -g -O --prefix=${PREFIX} \
  79. ${MODGHC_SETUP_CONF_ARGS}
  80. CONFIGURE_STYLE += CABAL
  81. MODGHC_BUILD_TARGET = \
  82. cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} \
  83. ${MODGHC_SETUP_PROG} build -v
  84. . if ${MODGHC_BUILD:L:Mhaddock}
  85. MODGHC_BUILD_TARGET += \
  86. ;cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} \
  87. ${MODGHC_SETUP_PROG} haddock
  88. . endif
  89. . if ${MODGHC_BUILD:L:Mregister}
  90. MODGHC_BUILD_TARGET += \
  91. ;cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} \
  92. ${MODGHC_SETUP_PROG} register --gen-script; \
  93. cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} \
  94. ${MODGHC_SETUP_PROG} unregister --gen-script
  95. . endif
  96. MODGHC_INSTALL_TARGET = \
  97. cd ${WRKBUILD} && ${SETENV} ${MAKE_ENV} \
  98. ${MODGHC_SETUP_PROG} copy --destdir=${DESTDIR}
  99. . if ${MODGHC_BUILD:L:Mregister}
  100. MODGHC_INSTALL_TARGET += \
  101. ;${INSTALL_SCRIPT} ${WRKBUILD}/register.sh ${PREFIX}/lib/ghc/${DISTNAME} \
  102. ;${INSTALL_SCRIPT} ${WRKBUILD}/unregister.sh ${PREFIX}/lib/ghc/${DISTNAME}
  103. . endif
  104. MODGHC_TEST_TARGET = \
  105. cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} \
  106. ${MODGHC_SETUP_PROG} test
  107. . if !target(do-build)
  108. do-build:
  109. @${MODGHC_BUILD_TARGET}
  110. . endif
  111. . if !target(do-install)
  112. do-install:
  113. @${MODGHC_INSTALL_TARGET}
  114. . endif
  115. . if !target(do-test)
  116. do-test:
  117. @${MODGHC_TEST_TARGET}
  118. . endif
  119. . endif
  120. .endif