| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: haskell.mk,v 1.59 2024/04/28 08:33:44 pho Exp $ | | 1 | # $NetBSD: haskell.mk,v 1.60 2024/04/28 08:55:37 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. |
| @@ -99,39 +99,42 @@ _DEF_VARS.haskell= \ | | | @@ -99,39 +99,42 @@ _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_BIN \ | | 111 | _HASKELL_BIN \ |
| | | 112 | _HASKELL_GLOBAL_PKG_DB \ |
112 | _HASKELL_PKG_BIN \ | | 113 | _HASKELL_PKG_BIN \ |
113 | _HASKELL_PKG_DESCR_FILE_OR_DIR \ | | 114 | _HASKELL_PKG_DESCR_FILE_OR_DIR \ |
114 | _HASKELL_PKG_ID_FILE \ | | 115 | _HASKELL_PKG_ID_FILE \ |
115 | _HASKELL_VERSION \ | | 116 | _HASKELL_VERSION \ |
116 | _HS_ORIG_LD_CMD | | 117 | _HS_ORIG_LD_CMD |
117 | _USE_VARS.haskell= \ | | 118 | _USE_VARS.haskell= \ |
118 | DISTNAME \ | | 119 | DISTNAME \ |
119 | PKG_VERBOSE \ | | 120 | PKG_VERBOSE \ |
120 | BUILDLINK_PREFIX.ghc \ | | 121 | BUILDLINK_PREFIX.ghc \ |
121 | MASTER_SITE_HASKELL_HACKAGE \ | | 122 | MASTER_SITE_HASKELL_HACKAGE \ |
122 | PKGDIR DESTDIR \ | | 123 | PKGDIR DESTDIR \ |
123 | PREFIX \ | | 124 | PREFIX \ |
124 | WRKSRC | | 125 | WRKSRC \ |
| | | 126 | _MAKE_JOBS_N \ |
| | | 127 | _PATH_ORIG |
125 | _SORTED_VARS.haskell= \ | | 128 | _SORTED_VARS.haskell= \ |
126 | HASKELL_UNRESTRICT_DEPENDENCIES | | 129 | HASKELL_UNRESTRICT_DEPENDENCIES |
127 | _LISTED_VARS.haskell= \ | | 130 | _LISTED_VARS.haskell= \ |
128 | BUILDLINK_PASSTHRU_DIRS \ | | 131 | BUILDLINK_PASSTHRU_DIRS \ |
129 | CONFIGURE_ARGS \ | | 132 | CONFIGURE_ARGS \ |
130 | PLIST_SUBST \ | | 133 | PLIST_SUBST \ |
131 | PRINT_PLIST_AWK \ | | 134 | PRINT_PLIST_AWK \ |
132 | FILES_SUBST | | 135 | FILES_SUBST |
133 | _IGN_VARS.haskell= \ | | 136 | _IGN_VARS.haskell= \ |
134 | USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _* | | 137 | USE_TOOLS CONFIGURE_ENV MAKE_ENV WARNINGS _* |
135 | | | 138 | |
136 | PKGNAME?= hs-${DISTNAME} | | 139 | PKGNAME?= hs-${DISTNAME} |
137 | MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/} | | 140 | MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/} |
| @@ -157,26 +160,33 @@ HASKELL_UNRESTRICT_DEPENDENCIES?= # empt | | | @@ -157,26 +160,33 @@ HASKELL_UNRESTRICT_DEPENDENCIES?= # empt |
157 | .include "../../mk/haskell/tools/cpphs.mk" | | 160 | .include "../../mk/haskell/tools/cpphs.mk" |
158 | .include "../../mk/haskell/tools/happy.mk" | | 161 | .include "../../mk/haskell/tools/happy.mk" |
159 | | | 162 | |
160 | # Tools | | 163 | # Tools |
161 | _HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc | | 164 | _HASKELL_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc |
162 | _HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc-pkg | | 165 | _HASKELL_PKG_BIN= ${BUILDLINK_PREFIX.ghc:U${LOCALBASE}}/bin/ghc-pkg |
163 | | | 166 | |
164 | .if !defined(_HASKELL_VERSION) | | 167 | .if !defined(_HASKELL_VERSION) |
165 | _HASKELL_VERSION_CMD= ${_HASKELL_BIN:Q} --numeric-version | | 168 | _HASKELL_VERSION_CMD= ${_HASKELL_BIN:Q} --numeric-version |
166 | _HASKELL_VERSION:= ghc-${_HASKELL_VERSION_CMD:sh} | | 169 | _HASKELL_VERSION:= ghc-${_HASKELL_VERSION_CMD:sh} |
167 | .endif | | 170 | .endif |
168 | MAKEVARS+= _HASKELL_VERSION | | 171 | MAKEVARS+= _HASKELL_VERSION |
169 | | | 172 | |
| | | 173 | # Determine the path to the global Haskell package database. We need this |
| | | 174 | # in our INSTALL and DEINSTALL hooks. |
| | | 175 | .if !defined(_HASKELL_GLOBAL_PKG_DB) |
| | | 176 | _HASKELL_GLOBAL_PKG_DB!= ${_HASKELL_BIN:Q} --print-global-package-db |
| | | 177 | .endif |
| | | 178 | MAKEVARS+= _HASKELL_GLOBAL_PKG_DB |
| | | 179 | |
170 | # By default GHC uses a per-user default environment file if one is | | 180 | # By default GHC uses a per-user default environment file if one is |
171 | # available. Cabal has to be visible in order to compile Setup.?hs, | | 181 | # available. Cabal has to be visible in order to compile Setup.?hs, |
172 | # but per-user default environment files usually don't mark it as | | 182 | # but per-user default environment files usually don't mark it as |
173 | # visible. Tell GHC not to read any environment files. | | 183 | # visible. Tell GHC not to read any environment files. |
174 | _HASKELL_BUILD_SETUP_OPTS= -package-env - | | 184 | _HASKELL_BUILD_SETUP_OPTS= -package-env - |
175 | | | 185 | |
176 | # GHC requires C compiler. | | 186 | # GHC requires C compiler. |
177 | USE_LANGUAGES+= c | | 187 | USE_LANGUAGES+= c |
178 | | | 188 | |
179 | # Haskell packages don't use semvars but they use something similar to it, | | 189 | # Haskell packages don't use semvars but they use something similar to it, |
180 | # which is called Haskell PVP (https://pvp.haskell.org/). Packages usually | | 190 | # which is called Haskell PVP (https://pvp.haskell.org/). Packages usually |
181 | # have version constraints on their dependencies that specify not only | | 191 | # have version constraints on their dependencies that specify not only |
182 | # lower bounds but also upper bounds. The problem is that, while lower | | 192 | # lower bounds but also upper bounds. The problem is that, while lower |
| @@ -296,27 +306,27 @@ _HS_PLIST_STATUS= ok | | | @@ -296,27 +306,27 @@ _HS_PLIST_STATUS= ok |
296 | | | 306 | |
297 | # Starting from GHC 7.10 (or 7.8?), packages are installed in directories | | 307 | # Starting from GHC 7.10 (or 7.8?), packages are installed in directories |
298 | # with a hashed name, which makes it a bit more complicated to generate | | 308 | # with a hashed name, which makes it a bit more complicated to generate |
299 | # the PLIST. | | 309 | # the PLIST. |
300 | # | | 310 | # |
301 | | | 311 | |
302 | # There is no easy way to obtain a platform string such as | | 312 | # There is no easy way to obtain a platform string such as |
303 | # "x86_64-netbsd-ghc-9.0.1". If the package contains a library we | | 313 | # "x86_64-netbsd-ghc-9.0.1". If the package contains a library we |
304 | # could extract it from the description file, but if it's | | 314 | # could extract it from the description file, but if it's |
305 | # executable-only there's no such file. As a workaround we read the | | 315 | # executable-only there's no such file. As a workaround we read the |
306 | # description of "base" (which always exists) and extract the platform | | 316 | # description of "base" (which always exists) and extract the platform |
307 | # from it. | | 317 | # from it. |
308 | .if !defined(_HS_PLIST.platform) | | 318 | .if !defined(_HS_PLIST.platform) |
309 | _HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN} --simple-output field base data-dir | | 319 | _HS_PLIST.platform.cmd= ${_HASKELL_PKG_BIN:Q} --simple-output field base data-dir |
310 | _HS_PLIST.platform:= ${_HS_PLIST.platform.cmd:sh:H:T} | | 320 | _HS_PLIST.platform:= ${_HS_PLIST.platform.cmd:sh:H:T} |
311 | .endif | | 321 | .endif |
312 | MAKEVARS+= _HS_PLIST.platform | | 322 | MAKEVARS+= _HS_PLIST.platform |
313 | # Abbreviated compiler version. Used for shared libraries. | | 323 | # Abbreviated compiler version. Used for shared libraries. |
314 | _HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,} | | 324 | _HS_PLIST.short-ver= ${_HASKELL_VERSION:S,-,,} |
315 | | | 325 | |
316 | PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform} | | 326 | PLIST_SUBST+= HS_PLATFORM=${_HS_PLIST.platform} |
317 | PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION} | | 327 | PLIST_SUBST+= HS_VERSION=${_HASKELL_VERSION} |
318 | PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver} | | 328 | PLIST_SUBST+= HS_VER=${_HS_PLIST.short-ver} |
319 | # Package IDs formatted as "{name}-{version}-{hash}": these only exist if | | 329 | # Package IDs formatted as "{name}-{version}-{hash}": these only exist if |
320 | # the package contains at least one library. | | 330 | # the package contains at least one library. |
321 | _HS_PLIST.subst-libs.cmd= \ | | 331 | _HS_PLIST.subst-libs.cmd= \ |
322 | if [ -f ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} ]; then \ | | 332 | if [ -f ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q} ]; then \ |
| @@ -462,29 +472,30 @@ do-install: | | | @@ -462,29 +472,30 @@ do-install: |
462 | elif [ -f dist/package-description ]; then \ | | 472 | elif [ -f dist/package-description ]; then \ |
463 | ${INSTALL_DATA} dist/package-description \ | | 473 | ${INSTALL_DATA} dist/package-description \ |
464 | ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q}; \ | | 474 | ${DESTDIR:Q}${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q}; \ |
465 | ${INSTALL_DATA} dist/package-id \ | | 475 | ${INSTALL_DATA} dist/package-id \ |
466 | ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \ | | 476 | ${DESTDIR:Q}${_HASKELL_PKG_ID_FILE:Q}; \ |
467 | fi | | 477 | fi |
468 | # Executable-only packages tend to create an empty directory tree in | | 478 | # Executable-only packages tend to create an empty directory tree in |
469 | # lib/ which results in useless @pkgdir in PLIST. | | 479 | # lib/ which results in useless @pkgdir in PLIST. |
470 | ${RUN}${FIND} ${DESTDIR:Q}${PREFIX}/lib -type d | \ | | 480 | ${RUN}${FIND} ${DESTDIR:Q}${PREFIX}/lib -type d | \ |
471 | ${TAIL} -n 1 | \ | | 481 | ${TAIL} -n 1 | \ |
472 | ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE} | | 482 | ${XARGS} ${RMDIR} -p 2>/dev/null || ${TRUE} |
473 | | | 483 | |
474 | # Substitutions for INSTALL and DEINSTALL. | | 484 | # Substitutions for INSTALL and DEINSTALL. |
475 | FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN} | | 485 | FILES_SUBST+= HASKELL_GLOBAL_PKG_DB=${_HASKELL_GLOBAL_PKG_DB:Q} |
476 | FILES_SUBST+= HASKELL_PKG_DESCR_FILE_OR_DIR=${_HASKELL_PKG_DESCR_FILE_OR_DIR} | | 486 | FILES_SUBST+= HASKELL_PKG_BIN=${_HASKELL_PKG_BIN:Q} |
477 | FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE} | | 487 | FILES_SUBST+= HASKELL_PKG_DESCR_FILE_OR_DIR=${_HASKELL_PKG_DESCR_FILE_OR_DIR:Q} |
| | | 488 | FILES_SUBST+= HASKELL_PKG_ID_FILE=${_HASKELL_PKG_ID_FILE:Q} |
478 | FILES_SUBST+= AWK=${AWK:Q} | | 489 | FILES_SUBST+= AWK=${AWK:Q} |
479 | FILES_SUBST+= EXPR=${EXPR:Q} | | 490 | FILES_SUBST+= EXPR=${EXPR:Q} |
480 | FILES_SUBST+= TRUE=${TRUE:Q} | | 491 | FILES_SUBST+= TRUE=${TRUE:Q} |
481 | | | 492 | |
482 | INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in | | 493 | INSTALL_TEMPLATES+= ../../mk/haskell/INSTALL.in |
483 | DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in | | 494 | DEINSTALL_TEMPLATES+= ../../mk/haskell/DEINSTALL.in |
484 | | | 495 | |
485 | # Only present these variables if the definitions can be extracted | | 496 | # Only present these variables if the definitions can be extracted |
486 | # from the files in DESTDIR. | | 497 | # from the files in DESTDIR. |
487 | _DEF_VARS.haskell+= _HS_PLIST.platform | | 498 | _DEF_VARS.haskell+= _HS_PLIST.platform |
488 | _DEF_VARS.haskell+= _HS_PLIST.short-ver | | 499 | _DEF_VARS.haskell+= _HS_PLIST.short-ver |
489 | | | 500 | |
490 | .endif # HASKELL_MK | | 501 | .endif # HASKELL_MK |