| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: haskell.mk,v 1.58 2023/11/01 17:55:08 pho Exp $ | | 1 | # $NetBSD: haskell.mk,v 1.59 2024/04/28 08:33:44 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. |
| @@ -98,32 +98,32 @@ _PKG_VARS.haskell= \ | | | @@ -98,32 +98,32 @@ _PKG_VARS.haskell= \ |
98 | _DEF_VARS.haskell= \ | | 98 | _DEF_VARS.haskell= \ |
99 | BUILDLINK_PASSTHRU_DIRS \ | | 99 | BUILDLINK_PASSTHRU_DIRS \ |
100 | USE_LANGUAGES \ | | 100 | USE_LANGUAGES \ |
101 | CONFIGURE_ARGS \ | | 101 | CONFIGURE_ARGS \ |
102 | PLIST_SUBST \ | | 102 | PLIST_SUBST \ |
103 | PRINT_PLIST_AWK \ | | 103 | PRINT_PLIST_AWK \ |
104 | GENERATE_PLIST \ | | 104 | GENERATE_PLIST \ |
105 | PLIST_SRC \ | | 105 | PLIST_SRC \ |
106 | FILES_SUBST \ | | 106 | FILES_SUBST \ |
107 | INSTALLATION_DIRS \ | | 107 | INSTALLATION_DIRS \ |
108 | INSTALL_TEMPLATES \ | | 108 | INSTALL_TEMPLATES \ |
109 | DEINSTALL_TEMPLATES \ | | 109 | DEINSTALL_TEMPLATES \ |
110 | UNLIMIT_RESOURCES \ | | 110 | UNLIMIT_RESOURCES \ |
111 | _HASKELL_VERSION_CMD \ | | | |
112 | _HASKELL_BIN \ | | 111 | _HASKELL_BIN \ |
113 | _HASKELL_PKG_BIN \ | | 112 | _HASKELL_PKG_BIN \ |
114 | _HASKELL_PKG_DESCR_FILE_OR_DIR \ | | 113 | _HASKELL_PKG_DESCR_FILE_OR_DIR \ |
115 | _HASKELL_PKG_ID_FILE \ | | 114 | _HASKELL_PKG_ID_FILE \ |
116 | _HASKELL_VERSION | | 115 | _HASKELL_VERSION \ |
| | | 116 | _HS_ORIG_LD_CMD |
117 | _USE_VARS.haskell= \ | | 117 | _USE_VARS.haskell= \ |
118 | DISTNAME \ | | 118 | DISTNAME \ |
119 | PKG_VERBOSE \ | | 119 | PKG_VERBOSE \ |
120 | BUILDLINK_PREFIX.ghc \ | | 120 | BUILDLINK_PREFIX.ghc \ |
121 | MASTER_SITE_HASKELL_HACKAGE \ | | 121 | MASTER_SITE_HASKELL_HACKAGE \ |
122 | PKGDIR DESTDIR \ | | 122 | PKGDIR DESTDIR \ |
123 | PREFIX \ | | 123 | PREFIX \ |
124 | WRKSRC | | 124 | WRKSRC |
125 | _SORTED_VARS.haskell= \ | | 125 | _SORTED_VARS.haskell= \ |
126 | HASKELL_UNRESTRICT_DEPENDENCIES | | 126 | HASKELL_UNRESTRICT_DEPENDENCIES |
127 | _LISTED_VARS.haskell= \ | | 127 | _LISTED_VARS.haskell= \ |
128 | BUILDLINK_PASSTHRU_DIRS \ | | 128 | BUILDLINK_PASSTHRU_DIRS \ |
129 | CONFIGURE_ARGS \ | | 129 | CONFIGURE_ARGS \ |
| @@ -148,31 +148,34 @@ HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= y | | | @@ -148,31 +148,34 @@ HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= y |
148 | HASKELL_ENABLE_TESTS?= no | | 148 | HASKELL_ENABLE_TESTS?= no |
149 | HASKELL_UNRESTRICT_DEPENDENCIES?= # empty | | 149 | HASKELL_UNRESTRICT_DEPENDENCIES?= # empty |
150 | | | 150 | |
151 | .include "../../lang/ghc96/buildlink3.mk" | | 151 | .include "../../lang/ghc96/buildlink3.mk" |
152 | | | 152 | |
153 | # Some Cabal packages requires preprocessors to build, and we don't | | 153 | # Some Cabal packages requires preprocessors to build, and we don't |
154 | # want them to implicitly depend on such tools. Place dummy scripts by | | 154 | # want them to implicitly depend on such tools. Place dummy scripts by |
155 | # default. | | 155 | # default. |
156 | .include "../../mk/haskell/tools/alex.mk" | | 156 | .include "../../mk/haskell/tools/alex.mk" |
157 | .include "../../mk/haskell/tools/cpphs.mk" | | 157 | .include "../../mk/haskell/tools/cpphs.mk" |
158 | .include "../../mk/haskell/tools/happy.mk" | | 158 | .include "../../mk/haskell/tools/happy.mk" |
159 | | | 159 | |
160 | # Tools | | 160 | # Tools |
161 | _HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${PREFIX}}/bin/ghc | | 161 | _HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc |
162 | _HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${PREFIX}}/bin/ghc-pkg | | 162 | _HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc-pkg |
163 | | | 163 | |
164 | _HASKELL_VERSION_CMD= ${_HASKELL_BIN} -V 2>/dev/null | ${CUT} -d ' ' -f 8 | | 164 | .if !defined(_HASKELL_VERSION) |
165 | _HASKELL_VERSION= ghc-${_HASKELL_VERSION_CMD:sh} | | 165 | _HASKELL_VERSION_CMD= ${_HASKELL_BIN:Q} --numeric-version |
| | | 166 | _HASKELL_VERSION:= ghc-${_HASKELL_VERSION_CMD:sh} |
| | | 167 | .endif |
| | | 168 | MAKEVARS+= _HASKELL_VERSION |
166 | | | 169 | |
167 | # By default GHC uses a per-user default environment file if one is | | 170 | # By default GHC uses a per-user default environment file if one is |
168 | # available. Cabal has to be visible in order to compile Setup.?hs, | | 171 | # available. Cabal has to be visible in order to compile Setup.?hs, |
169 | # but per-user default environment files usually don't mark it as | | 172 | # but per-user default environment files usually don't mark it as |
170 | # visible. Tell GHC not to read any environment files. | | 173 | # visible. Tell GHC not to read any environment files. |
171 | _HASKELL_BUILD_SETUP_OPTS= -package-env - | | 174 | _HASKELL_BUILD_SETUP_OPTS= -package-env - |
172 | | | 175 | |
173 | # GHC requires C compiler. | | 176 | # GHC requires C compiler. |
174 | USE_LANGUAGES+= c | | 177 | USE_LANGUAGES+= c |
175 | | | 178 | |
176 | # Haskell packages don't use semvars but they use something similar to it, | | 179 | # Haskell packages don't use semvars but they use something similar to it, |
177 | # which is called Haskell PVP (https://pvp.haskell.org/). Packages usually | | 180 | # which is called Haskell PVP (https://pvp.haskell.org/). Packages usually |
178 | # have version constraints on their dependencies that specify not only | | 181 | # have version constraints on their dependencies that specify not only |
| @@ -250,27 +253,27 @@ CONFIGURE_ARGS+= --enable-split-sections | | | @@ -250,27 +253,27 @@ CONFIGURE_ARGS+= --enable-split-sections |
250 | .endif | | 253 | .endif |
251 | | | 254 | |
252 | # Support RELRO. When PKGSRC_USE_RELRO isn't set to "no", | | 255 | # Support RELRO. When PKGSRC_USE_RELRO isn't set to "no", |
253 | # mk/compiler/{ghc,clang}.mk add "-Wl,-z,relro" and optionally | | 256 | # mk/compiler/{ghc,clang}.mk add "-Wl,-z,relro" and optionally |
254 | # "-Wl,-z,now" to LDFLAGS. Since Cabal doesn't respect the environment | | 257 | # "-Wl,-z,now" to LDFLAGS. Since Cabal doesn't respect the environment |
255 | # variable LDFLAGS, we need to be explicit about it. Note that -optl | | 258 | # variable LDFLAGS, we need to be explicit about it. Note that -optl |
256 | # is a GHC option which specifies options to be passed to CC, not LD, | | 259 | # is a GHC option which specifies options to be passed to CC, not LD, |
257 | # while linking executables and shared libraries. | | 260 | # while linking executables and shared libraries. |
258 | CONFIGURE_ARGS+= ${LDFLAGS:S/^/--ghc-options=-optl\ /} | | 261 | CONFIGURE_ARGS+= ${LDFLAGS:S/^/--ghc-options=-optl\ /} |
259 | # GHC heavily uses "ld -r" to combine multiple .o files but our ld | | 262 | # GHC heavily uses "ld -r" to combine multiple .o files but our ld |
260 | # wrapper is going to inject the relro flags. In this case these flags | | 263 | # wrapper is going to inject the relro flags. In this case these flags |
261 | # don't make sense so ld(1) emits warnings. Use the original, | | 264 | # don't make sense so ld(1) emits warnings. Use the original, |
262 | # non-wrapped ld(1) for merging objects as a dirty workaround. | | 265 | # non-wrapped ld(1) for merging objects as a dirty workaround. |
263 | _HS_ORIG_LD_CMD= ${SETENV} PATH=${_PATH_ORIG} which ld | | 266 | _HS_ORIG_LD_CMD= ${SETENV} PATH=${_PATH_ORIG} which ${LD} |
264 | CONFIGURE_ARGS+= --ghc-options=-pgmlm\ ${_HS_ORIG_LD_CMD:sh} | | 267 | CONFIGURE_ARGS+= --ghc-options=-pgmlm\ ${_HS_ORIG_LD_CMD:sh} |
265 | CONFIGURE_ARGS+= --ghc-options=-optlm\ -r | | 268 | CONFIGURE_ARGS+= --ghc-options=-optlm\ -r |
266 | | | 269 | |
267 | # When a Template Haskell splice is to be evaluated by a dynamically-linked | | 270 | # When a Template Haskell splice is to be evaluated by a dynamically-linked |
268 | # GHC, it first compiles the splice and creates a .so file like | | 271 | # GHC, it first compiles the splice and creates a .so file like |
269 | # /tmp/ghc_XXXX/libghc_XX.so, then it dlopen's it. When the source file | | 272 | # /tmp/ghc_XXXX/libghc_XX.so, then it dlopen's it. When the source file |
270 | # contains more than one splice, subsequent splices will refer to previous | | 273 | # contains more than one splice, subsequent splices will refer to previous |
271 | # ones via "-L/tmp/ghc_XXXX -Wl,-rpath,/tmp/ghc_XXXX -lghc_XX". This means | | 274 | # ones via "-L/tmp/ghc_XXXX -Wl,-rpath,/tmp/ghc_XXXX -lghc_XX". This means |
272 | # /tmp/ghc_* must be protected from getting removed by our wrappers. We | | 275 | # /tmp/ghc_* must be protected from getting removed by our wrappers. We |
273 | # also want to be explicit about the path to be chosen for temporary files. | | 276 | # also want to be explicit about the path to be chosen for temporary files. |
274 | CONFIGURE_ARGS+= --ghc-options=-tmpdir\ ${TMPDIR:U/tmp:Q} | | 277 | CONFIGURE_ARGS+= --ghc-options=-tmpdir\ ${TMPDIR:U/tmp:Q} |
275 | BUILDLINK_PASSTHRU_DIRS+= ${TMPDIR:U/tmp} | | 278 | BUILDLINK_PASSTHRU_DIRS+= ${TMPDIR:U/tmp} |
276 | | | 279 | |
| @@ -292,28 +295,31 @@ _HS_PLIST_STATUS= ok | | | @@ -292,28 +295,31 @@ _HS_PLIST_STATUS= ok |
292 | .endif | | 295 | .endif |
293 | | | 296 | |
294 | # Starting from GHC 7.10 (or 7.8?), packages are installed in directories | | 297 | # Starting from GHC 7.10 (or 7.8?), packages are installed in directories |
295 | # with a hashed name, which makes it a bit more complicated to generate | | 298 | # with a hashed name, which makes it a bit more complicated to generate |
296 | # the PLIST. | | 299 | # the PLIST. |
297 | # | | 300 | # |
298 | | | 301 | |
299 | # There is no easy way to obtain a platform string such as | | 302 | # There is no easy way to obtain a platform string such as |
300 | # "x86_64-netbsd-ghc-9.0.1". If the package contains a library we | | 303 | # "x86_64-netbsd-ghc-9.0.1". If the package contains a library we |
301 | # could extract it from the description file, but if it's | | 304 | # could extract it from the description file, but if it's |
302 | # executable-only there's no such file. As a workaround we read the | | 305 | # executable-only there's no such file. As a workaround we read the |
303 | # description of "base" (which always exists) and extract the platform | | 306 | # description of "base" (which always exists) and extract the platform |
304 | # from it. | | 307 | # from it. |
| | | 308 | .if !defined(_HS_PLIST.platform) |
305 | _HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN} --simple-output field base data-dir | | 309 | _HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN} --simple-output field base data-dir |
306 | _HS_PLIST.platform= ${_HS_PLIST.platform.cmd:sh:H:T} | | 310 | _HS_PLIST.platform:= ${_HS_PLIST.platform.cmd:sh:H:T} |
| | | 311 | .endif |
| | | 312 | MAKEVARS+= _HS_PLIST.platform |
307 | # Abbreviated compiler version. Used for shared libraries. | | 313 | # Abbreviated compiler version. Used for shared libraries. |
308 | _HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,} | | 314 | _HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,} |
309 | | | 315 | |
310 | PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform} | | 316 | PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform} |
311 | PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION} | | 317 | PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION} |
312 | PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver} | | 318 | PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver} |
313 | # Package IDs formatted as "{name}-{version}-{hash}": these only exist if | | 319 | # Package IDs formatted as "{name}-{version}-{hash}": these only exist if |
314 | # the package contains at least one library. | | 320 | # the package contains at least one library. |
315 | _HS_PLIST.subst-libs.cmd= \ | | 321 | _HS_PLIST.subst-libs.cmd= \ |
316 | if [ -f ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} ]; then \ | | 322 | if [ -f ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} ]; then \ |
317 | n=`${WC} -l ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} | ${AWK} '{print $$1}'`; \ | | 323 | n=`${WC} -l ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} | ${AWK} '{print $$1}'`; \ |
318 | if [ "$$n" -eq 1 ]; then \ | | 324 | if [ "$$n" -eq 1 ]; then \ |
319 | pkg_id=`${CAT} ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}`; \ | | 325 | pkg_id=`${CAT} ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}`; \ |