| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: haskell.mk,v 1.67 2024/04/29 07:58:38 pho Exp $ | | 1 | # $NetBSD: haskell.mk,v 1.68 2024/05/04 11:21:26 pho Exp $ |
2 | # | | 2 | # |
3 | # This Makefile fragment handles Haskell Cabal packages. Package | | 3 | # This Makefile fragment handles Haskell Cabal packages. Package |
4 | # configuration, building, installation, registration and unregistration | | 4 | # configuration, building, installation, registration and unregistration |
5 | # are fully automated. See also mk/haskell/README.md for a packaging guide. | | 5 | # are fully automated. See also mk/haskell/README.md for a packaging guide. |
6 | # | | 6 | # |
7 | # Package-settable variables: | | 7 | # Package-settable variables: |
8 | # | | 8 | # |
9 | # PKGNAME | | 9 | # PKGNAME |
10 | # Defaults to hs-${DISTNAME}. | | 10 | # Defaults to hs-${DISTNAME}. |
11 | # | | 11 | # |
12 | # HOMEPAGE | | 12 | # HOMEPAGE |
13 | # MASTER_SITES | | 13 | # MASTER_SITES |
14 | # Default to HackageDB URLs. | | 14 | # Default to HackageDB URLs. |
| @@ -38,26 +38,33 @@ | | | @@ -38,26 +38,33 @@ |
38 | # default. Enabling it also defines the target "do-test" unless the | | 38 | # default. Enabling it also defines the target "do-test" unless the |
39 | # Makefile already defines one. | | 39 | # Makefile already defines one. |
40 | # | | 40 | # |
41 | # Possible values: yes, no | | 41 | # Possible values: yes, no |
42 | # Default value: no | | 42 | # Default value: no |
43 | # | | 43 | # |
44 | # HASKELL_DISABLE_EXECUTABLES | | 44 | # HASKELL_DISABLE_EXECUTABLES |
45 | # A list of executables that we don't want to build or | | 45 | # A list of executables that we don't want to build or |
46 | # install. Listing executables in this variable will cause the | | 46 | # install. Listing executables in this variable will cause the |
47 | # *.cabal file to be rewritten so that they won't be built. | | 47 | # *.cabal file to be rewritten so that they won't be built. |
48 | # | | 48 | # |
49 | # Default value: empty | | 49 | # Default value: empty |
50 | # | | 50 | # |
| | | 51 | # HASKELL_DISABLE_LIBRARIES |
| | | 52 | # A list of libraries that we don't want to build or install. Listing |
| | | 53 | # libraries in this variable will cause the *.cabal file to be |
| | | 54 | # rewritten so that they won't be built. |
| | | 55 | # |
| | | 56 | # Default value: empty |
| | | 57 | # |
51 | # HASKELL_UNRESTRICT_DEPENDENCIES | | 58 | # HASKELL_UNRESTRICT_DEPENDENCIES |
52 | # A list of Cabal packages that the package depends on, whose version | | 59 | # A list of Cabal packages that the package depends on, whose version |
53 | # constraints are way too restricted to solve. Listing packages in | | 60 | # constraints are way too restricted to solve. Listing packages in |
54 | # this variable will cause the *.cabal file to be rewritten so that | | 61 | # this variable will cause the *.cabal file to be rewritten so that |
55 | # any version is accepted. Use this with care, because not all | | 62 | # any version is accepted. Use this with care, because not all |
56 | # incompatibilities are caught during build time. | | 63 | # incompatibilities are caught during build time. |
57 | # | | 64 | # |
58 | # Default value: empty | | 65 | # Default value: empty |
59 | # | | 66 | # |
60 | # User-settable variables: | | 67 | # User-settable variables: |
61 | # | | 68 | # |
62 | # HASKELL_ENABLE_SHARED_LIBRARY | | 69 | # HASKELL_ENABLE_SHARED_LIBRARY |
63 | # Whether shared library should be built or not. | | 70 | # Whether shared library should be built or not. |
| @@ -91,26 +98,27 @@ BUILD_DEFS+= HASKELL_ENABLE_HADDOCK_DOCU | | | @@ -91,26 +98,27 @@ BUILD_DEFS+= HASKELL_ENABLE_HADDOCK_DOCU |
91 | # Declarations for ../../mk/misc/show.mk | | 98 | # Declarations for ../../mk/misc/show.mk |
92 | _VARGROUPS+= haskell | | 99 | _VARGROUPS+= haskell |
93 | _USER_VARS.haskell= \ | | 100 | _USER_VARS.haskell= \ |
94 | HASKELL_ENABLE_SHARED_LIBRARY \ | | 101 | HASKELL_ENABLE_SHARED_LIBRARY \ |
95 | HASKELL_ENABLE_LIBRARY_PROFILING \ | | 102 | HASKELL_ENABLE_LIBRARY_PROFILING \ |
96 | HASKELL_ENABLE_HADDOCK_DOCUMENTATION \ | | 103 | HASKELL_ENABLE_HADDOCK_DOCUMENTATION \ |
97 | HS_UPDATE_PLIST | | 104 | HS_UPDATE_PLIST |
98 | _PKG_VARS.haskell= \ | | 105 | _PKG_VARS.haskell= \ |
99 | HASKELL_ENABLE_DYNAMIC_EXECUTABLE \ | | 106 | HASKELL_ENABLE_DYNAMIC_EXECUTABLE \ |
100 | HASKELL_ENABLE_TESTS \ | | 107 | HASKELL_ENABLE_TESTS \ |
101 | HASKELL_OPTIMIZATION_LEVEL \ | | 108 | HASKELL_OPTIMIZATION_LEVEL \ |
102 | HASKELL_PKG_NAME \ | | 109 | HASKELL_PKG_NAME \ |
103 | HASKELL_DISABLE_EXECUTABLES \ | | 110 | HASKELL_DISABLE_EXECUTABLES \ |
| | | 111 | HASKELL_DISABLE_LIBRARIES \ |
104 | HASKELL_UNRESTRICT_DEPENDENCIES \ | | 112 | HASKELL_UNRESTRICT_DEPENDENCIES \ |
105 | PKGNAME HOMEPAGE MASTER_SITES | | 113 | PKGNAME HOMEPAGE MASTER_SITES |
106 | _DEF_VARS.haskell= \ | | 114 | _DEF_VARS.haskell= \ |
107 | BUILDLINK_PASSTHRU_DIRS \ | | 115 | BUILDLINK_PASSTHRU_DIRS \ |
108 | USE_LANGUAGES \ | | 116 | USE_LANGUAGES \ |
109 | CONFIGURE_ARGS \ | | 117 | CONFIGURE_ARGS \ |
110 | PLIST_SUBST \ | | 118 | PLIST_SUBST \ |
111 | PRINT_PLIST_AWK \ | | 119 | PRINT_PLIST_AWK \ |
112 | GENERATE_PLIST \ | | 120 | GENERATE_PLIST \ |
113 | PLIST_SRC \ | | 121 | PLIST_SRC \ |
114 | FILES_SUBST \ | | 122 | FILES_SUBST \ |
115 | INSTALLATION_DIRS \ | | 123 | INSTALLATION_DIRS \ |
116 | INSTALL_TEMPLATES \ | | 124 | INSTALL_TEMPLATES \ |
| @@ -126,50 +134,52 @@ _DEF_VARS.haskell= \ | | | @@ -126,50 +134,52 @@ _DEF_VARS.haskell= \ |
126 | _HASKELL_VERSION | | 134 | _HASKELL_VERSION |
127 | _USE_VARS.haskell= \ | | 135 | _USE_VARS.haskell= \ |
128 | DISTNAME \ | | 136 | DISTNAME \ |
129 | PKG_VERBOSE \ | | 137 | PKG_VERBOSE \ |
130 | BUILDLINK_PREFIX.ghc \ | | 138 | BUILDLINK_PREFIX.ghc \ |
131 | MASTER_SITE_HASKELL_HACKAGE \ | | 139 | MASTER_SITE_HASKELL_HACKAGE \ |
132 | PKGDIR DESTDIR \ | | 140 | PKGDIR DESTDIR \ |
133 | PREFIX \ | | 141 | PREFIX \ |
134 | WRKSRC \ | | 142 | WRKSRC \ |
135 | _MAKE_JOBS_N \ | | 143 | _MAKE_JOBS_N \ |
136 | _PATH_ORIG | | 144 | _PATH_ORIG |
137 | _SORTED_VARS.haskell= \ | | 145 | _SORTED_VARS.haskell= \ |
138 | HASKELL_DISABLE_EXECUTABLES \ | | 146 | HASKELL_DISABLE_EXECUTABLES \ |
| | | 147 | HASKELL_DISABLE_LIBRARIES \ |
139 | HASKELL_UNRESTRICT_DEPENDENCIES | | 148 | HASKELL_UNRESTRICT_DEPENDENCIES |
140 | _LISTED_VARS.haskell= \ | | 149 | _LISTED_VARS.haskell= \ |
141 | BUILDLINK_PASSTHRU_DIRS \ | | 150 | BUILDLINK_PASSTHRU_DIRS \ |
142 | CONFIGURE_ARGS \ | | 151 | CONFIGURE_ARGS \ |
143 | PLIST_SUBST \ | | 152 | PLIST_SUBST \ |
144 | PRINT_PLIST_AWK \ | | 153 | PRINT_PLIST_AWK \ |
145 | FILES_SUBST | | 154 | FILES_SUBST |
146 | _IGN_VARS.haskell= \ | | 155 | _IGN_VARS.haskell= \ |
147 | USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _* | | 156 | USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _* |
148 | | | 157 | |
149 | PKGNAME?= hs-${DISTNAME} | | 158 | PKGNAME?= hs-${DISTNAME} |
150 | MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/} | | 159 | MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/} |
151 | HOMEPAGE?= http://hackage.haskell.org/package/${DISTNAME:C/-[^-]*$//} | | 160 | HOMEPAGE?= http://hackage.haskell.org/package/${DISTNAME:C/-[^-]*$//} |
152 | | | 161 | |
153 | # GHC can be a memory hog, so don't apply regular limits. | | 162 | # GHC can be a memory hog, so don't apply regular limits. |
154 | UNLIMIT_RESOURCES+= datasize virtualsize | | 163 | UNLIMIT_RESOURCES+= datasize virtualsize |
155 | | | 164 | |
156 | HASKELL_OPTIMIZATION_LEVEL?= 2 | | 165 | HASKELL_OPTIMIZATION_LEVEL?= 2 |
157 | HASKELL_ENABLE_DYNAMIC_EXECUTABLE?= ${HASKELL_ENABLE_SHARED_LIBRARY} | | 166 | HASKELL_ENABLE_DYNAMIC_EXECUTABLE?= ${HASKELL_ENABLE_SHARED_LIBRARY} |
158 | HASKELL_ENABLE_SHARED_LIBRARY?= yes | | 167 | HASKELL_ENABLE_SHARED_LIBRARY?= yes |
159 | HASKELL_ENABLE_LIBRARY_PROFILING?= yes | | 168 | HASKELL_ENABLE_LIBRARY_PROFILING?= yes |
160 | HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes | | 169 | HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes |
161 | HASKELL_ENABLE_TESTS?= no | | 170 | HASKELL_ENABLE_TESTS?= no |
162 | HASKELL_DISABLE_EXECUTABLES?= # empty | | 171 | HASKELL_DISABLE_EXECUTABLES?= # empty |
| | | 172 | HASKELL_DISABLE_LIBRARIES?= # empty |
163 | HASKELL_UNRESTRICT_DEPENDENCIES?= # empty | | 173 | HASKELL_UNRESTRICT_DEPENDENCIES?= # empty |
164 | | | 174 | |
165 | .include "../../lang/ghc96/buildlink3.mk" | | 175 | .include "../../lang/ghc96/buildlink3.mk" |
166 | | | 176 | |
167 | # Some Cabal packages requires preprocessors to build, and we don't | | 177 | # Some Cabal packages requires preprocessors to build, and we don't |
168 | # want them to implicitly depend on such tools. Place dummy scripts by | | 178 | # want them to implicitly depend on such tools. Place dummy scripts by |
169 | # default. | | 179 | # default. |
170 | .include "../../mk/haskell/tools/alex.mk" | | 180 | .include "../../mk/haskell/tools/alex.mk" |
171 | .include "../../mk/haskell/tools/cpphs.mk" | | 181 | .include "../../mk/haskell/tools/cpphs.mk" |
172 | .include "../../mk/haskell/tools/happy.mk" | | 182 | .include "../../mk/haskell/tools/happy.mk" |
173 | | | 183 | |
174 | # Define some useful targets for pkgsrc developers. | | 184 | # Define some useful targets for pkgsrc developers. |
175 | .include "../../mk/haskell/developer.mk" | | 185 | .include "../../mk/haskell/developer.mk" |
| @@ -186,37 +196,49 @@ _HASKELL_VERSION= ghc-${_HASKELL_VERSION | | | @@ -186,37 +196,49 @@ _HASKELL_VERSION= ghc-${_HASKELL_VERSION |
186 | # in our INSTALL and DEINSTALL hooks. | | 196 | # in our INSTALL and DEINSTALL hooks. |
187 | _HASKELL_GLOBAL_PKG_DB_CMD= ${_HASKELL_BIN:Q} --print-global-package-db | | 197 | _HASKELL_GLOBAL_PKG_DB_CMD= ${_HASKELL_BIN:Q} --print-global-package-db |
188 | _HASKELL_GLOBAL_PKG_DB= ${_HASKELL_GLOBAL_PKG_DB_CMD:sh} | | 198 | _HASKELL_GLOBAL_PKG_DB= ${_HASKELL_GLOBAL_PKG_DB_CMD:sh} |
189 | | | 199 | |
190 | # By default GHC uses a per-user default environment file if one is | | 200 | # By default GHC uses a per-user default environment file if one is |
191 | # available. Cabal has to be visible in order to compile (or interpret) | | 201 | # available. Cabal has to be visible in order to compile (or interpret) |
192 | # Setup.hs, but per-user default environment files usually don't mark it as | | 202 | # Setup.hs, but per-user default environment files usually don't mark it as |
193 | # visible. Tell GHC not to read any environment files. | | 203 | # visible. Tell GHC not to read any environment files. |
194 | _HASKELL_BUILD_SETUP_OPTS= -package-env - | | 204 | _HASKELL_BUILD_SETUP_OPTS= -package-env - |
195 | | | 205 | |
196 | # GHC requires C compiler. | | 206 | # GHC requires C compiler. |
197 | USE_LANGUAGES+= c | | 207 | USE_LANGUAGES+= c |
198 | | | 208 | |
199 | # Some Haskell libraries builds and installs example executables that are | | 209 | # Some Haskell packages build and install example executables that are |
200 | # useless aside from debugging the libraries, and we don't want them to be | | 210 | # useless aside from debugging the packages, and we don't want them to be |
201 | # installed. | | 211 | # installed. |
202 | .if !empty(HASKELL_DISABLE_EXECUTABLES) | | 212 | .if !empty(HASKELL_DISABLE_EXECUTABLES) |
203 | SUBST_CLASSES+= exec | | 213 | SUBST_CLASSES+= exe |
204 | SUBST_STAGE.exec?= post-extract | | 214 | SUBST_STAGE.exe?= post-extract |
205 | SUBST_FILES.exec?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal | | 215 | SUBST_FILES.exe?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal |
206 | SUBST_MESSAGE.exec?= Disabling executables: ${HASKELL_DISABLE_EXECUTABLES} | | 216 | SUBST_MESSAGE.exe?= Disabling executables: ${HASKELL_DISABLE_EXECUTABLES} |
207 | SUBST_FILTER_CMD.exec= \ | | 217 | SUBST_FILTER_CMD.exe= \ |
208 | ${AWK} -f "${.CURDIR}/../../mk/haskell/disable-executables.awk" \ | | 218 | ${AWK} -f "${.CURDIR}/../../mk/haskell/disable-components.awk" \ |
209 | -v exec=${HASKELL_DISABLE_EXECUTABLES:Q} | | 219 | -v exe=${HASKELL_DISABLE_EXECUTABLES:Q} |
| | | 220 | .endif |
| | | 221 | |
| | | 222 | # Some Haskell packages build and install libraries that are useless aside |
| | | 223 | # from debugging the packages, and we don't want them to be installed. |
| | | 224 | .if !empty(HASKELL_DISABLE_LIBRARIES) |
| | | 225 | SUBST_CLASSES+= lib |
| | | 226 | SUBST_STAGE.lib?= post-extract |
| | | 227 | SUBST_FILES.lib?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal |
| | | 228 | SUBST_MESSAGE.lib?= Disabling libraries: ${HASKELL_DISABLE_LIBRARIES} |
| | | 229 | SUBST_FILTER_CMD.lib= \ |
| | | 230 | ${AWK} -f "${.CURDIR}/../../mk/haskell/disable-components.awk" \ |
| | | 231 | -v lib=${HASKELL_DISABLE_LIBRARIES:Q} |
210 | .endif | | 232 | .endif |
211 | | | 233 | |
212 | # Haskell packages don't use semvars but they use something similar to it, | | 234 | # Haskell packages don't use semvars but they use something similar to it, |
213 | # which is called Haskell PVP (https://pvp.haskell.org/). Packages usually | | 235 | # which is called Haskell PVP (https://pvp.haskell.org/). Packages usually |
214 | # have version constraints on their dependencies that specify not only | | 236 | # have version constraints on their dependencies that specify not only |
215 | # lower bounds but also upper bounds. The problem is that, while lower | | 237 | # lower bounds but also upper bounds. The problem is that, while lower |
216 | # bounds are mostly accurate, package authors can not be sure about upper | | 238 | # bounds are mostly accurate, package authors can not be sure about upper |
217 | # bounds so they tend to be too pessimistic about compatibility. | | 239 | # bounds so they tend to be too pessimistic about compatibility. |
218 | .if !empty(HASKELL_UNRESTRICT_DEPENDENCIES) | | 240 | .if !empty(HASKELL_UNRESTRICT_DEPENDENCIES) |
219 | SUBST_CLASSES+= deps | | 241 | SUBST_CLASSES+= deps |
220 | SUBST_STAGE.deps?= post-extract | | 242 | SUBST_STAGE.deps?= post-extract |
221 | SUBST_FILES.deps?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal | | 243 | SUBST_FILES.deps?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal |
222 | SUBST_MESSAGE.deps?= Relaxing version constraints on dependencies | | 244 | SUBST_MESSAGE.deps?= Relaxing version constraints on dependencies |
| @@ -430,26 +452,27 @@ do-configure: | | | @@ -430,26 +452,27 @@ do-configure: |
430 | setup_src=Setup.hs; \ | | 452 | setup_src=Setup.hs; \ |
431 | else \ | | 453 | else \ |
432 | setup_src=Setup.lhs; \ | | 454 | setup_src=Setup.lhs; \ |
433 | fi; \ | | 455 | fi; \ |
434 | if ${SETENV} ${CONFIGURE_ENV} \ | | 456 | if ${SETENV} ${CONFIGURE_ENV} \ |
435 | ${_HASKELL_INTERP_BIN} ${_HASKELL_BUILD_SETUP_OPTS:%=--ghc-arg=%} \ | | 457 | ${_HASKELL_INTERP_BIN} ${_HASKELL_BUILD_SETUP_OPTS:%=--ghc-arg=%} \ |
436 | $$setup_src configure ${PKG_VERBOSE:D-v} ${CONFIGURE_ARGS}; then \ | | 458 | $$setup_src configure ${PKG_VERBOSE:D-v} ${CONFIGURE_ARGS}; then \ |
437 | ${ECHO} '#!/bin/sh' > Setup; \ | | 459 | ${ECHO} '#!/bin/sh' > Setup; \ |
438 | ${ECHO} 'exec' ${_HASKELL_INTERP_BIN} \ | | 460 | ${ECHO} 'exec' ${_HASKELL_INTERP_BIN} \ |
439 | ${_HASKELL_BUILD_SETUP_OPTS:%=--ghc-arg=%} \ | | 461 | ${_HASKELL_BUILD_SETUP_OPTS:%=--ghc-arg=%} \ |
440 | $$setup_src '"$$@"' >> Setup; \ | | 462 | $$setup_src '"$$@"' >> Setup; \ |
441 | ${CHMOD} +x Setup; \ | | 463 | ${CHMOD} +x Setup; \ |
442 | else \ | | 464 | else \ |
| | | 465 | ${ECHO} "[mk/haskell.mk] Failed to interpret $$setup_src; falling back to compilation"; \ |
443 | ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -dynamic || \ | | 466 | ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -dynamic || \ |
444 | ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -static; \ | | 467 | ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -static; \ |
445 | ${SETENV} ${CONFIGURE_ENV} \ | | 468 | ${SETENV} ${CONFIGURE_ENV} \ |
446 | ./Setup configure ${PKG_VERBOSE:D-v} ${CONFIGURE_ARGS}; \ | | 469 | ./Setup configure ${PKG_VERBOSE:D-v} ${CONFIGURE_ARGS}; \ |
447 | fi | | 470 | fi |
448 | | | 471 | |
449 | # Define build target. _MAKE_JOBS_N is defined in build/build.mk | | 472 | # Define build target. _MAKE_JOBS_N is defined in build/build.mk |
450 | do-build: | | 473 | do-build: |
451 | ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \ | | 474 | ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \ |
452 | ${SETENV} ${MAKE_ENV} \ | | 475 | ${SETENV} ${MAKE_ENV} \ |
453 | ./Setup build ${PKG_VERBOSE:D-v} -j${_MAKE_JOBS_N} | | 476 | ./Setup build ${PKG_VERBOSE:D-v} -j${_MAKE_JOBS_N} |
454 | .if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes" | | 477 | .if ${HASKELL_ENABLE_HADDOCK_DOCUMENTATION} == "yes" |
455 | ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \ | | 478 | ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC:Q} && \ |