Sat May 4 11:21:27 2024 UTC (33d)
mk/haskell.mk: New package-settable variable: HASKELL_DISABLE_LIBRARIES


(pho)
diff -r1.67 -r1.68 pkgsrc/mk/haskell.mk
diff -r0 -r1.1 pkgsrc/mk/haskell/disable-components.awk
diff -r1.2 -r0 pkgsrc/mk/haskell/disable-executables.awk
Sat May 4 20:21:27 2024
Thu Jan 1 09:00:00 1970
pkgsrc/mk/haskell/disable-executables.awk,v

anoncvs not yet been updated

cvs diff -r1.67 -r1.68 pkgsrc/mk/haskell.mk (expand / switch to unified diff)

--- pkgsrc/mk/haskell.mk 2024/04/29 07:58:38 1.67
+++ pkgsrc/mk/haskell.mk 2024/05/04 11:21:26 1.68
@@ -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
149PKGNAME?= hs-${DISTNAME} 158PKGNAME?= hs-${DISTNAME}
150MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/} 159MASTER_SITES?= ${MASTER_SITE_HASKELL_HACKAGE:=${DISTNAME}/}
151HOMEPAGE?= http://hackage.haskell.org/package/${DISTNAME:C/-[^-]*$//} 160HOMEPAGE?= 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.
154UNLIMIT_RESOURCES+= datasize virtualsize 163UNLIMIT_RESOURCES+= datasize virtualsize
155 164
156HASKELL_OPTIMIZATION_LEVEL?= 2 165HASKELL_OPTIMIZATION_LEVEL?= 2
157HASKELL_ENABLE_DYNAMIC_EXECUTABLE?= ${HASKELL_ENABLE_SHARED_LIBRARY} 166HASKELL_ENABLE_DYNAMIC_EXECUTABLE?= ${HASKELL_ENABLE_SHARED_LIBRARY}
158HASKELL_ENABLE_SHARED_LIBRARY?= yes 167HASKELL_ENABLE_SHARED_LIBRARY?= yes
159HASKELL_ENABLE_LIBRARY_PROFILING?= yes 168HASKELL_ENABLE_LIBRARY_PROFILING?= yes
160HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes 169HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes
161HASKELL_ENABLE_TESTS?= no 170HASKELL_ENABLE_TESTS?= no
162HASKELL_DISABLE_EXECUTABLES?= # empty 171HASKELL_DISABLE_EXECUTABLES?= # empty
 172HASKELL_DISABLE_LIBRARIES?= # empty
163HASKELL_UNRESTRICT_DEPENDENCIES?= # empty 173HASKELL_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.
197USE_LANGUAGES+= c 207USE_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)
203SUBST_CLASSES+= exec 213SUBST_CLASSES+= exe
204SUBST_STAGE.exec?= post-extract 214SUBST_STAGE.exe?= post-extract
205SUBST_FILES.exec?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal 215SUBST_FILES.exe?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal
206SUBST_MESSAGE.exec?= Disabling executables: ${HASKELL_DISABLE_EXECUTABLES} 216SUBST_MESSAGE.exe?= Disabling executables: ${HASKELL_DISABLE_EXECUTABLES}
207SUBST_FILTER_CMD.exec= \ 217SUBST_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)
 225SUBST_CLASSES+= lib
 226SUBST_STAGE.lib?= post-extract
 227SUBST_FILES.lib?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal
 228SUBST_MESSAGE.lib?= Disabling libraries: ${HASKELL_DISABLE_LIBRARIES}
 229SUBST_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)
219SUBST_CLASSES+= deps 241SUBST_CLASSES+= deps
220SUBST_STAGE.deps?= post-extract 242SUBST_STAGE.deps?= post-extract
221SUBST_FILES.deps?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal 243SUBST_FILES.deps?= ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal
222SUBST_MESSAGE.deps?= Relaxing version constraints on dependencies 244SUBST_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
450do-build: 473do-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} && \

File Added: pkgsrc/mk/haskell/disable-components.awk
# $NetBSD: disable-components.awk,v 1.1 2024/05/04 11:21:26 pho Exp $
#
# Prevent executables specified with -v "exe=foo bar ..." from being built
# or installed. Do the same for libraries specified with -v "exe=foo bar
# ...".
#
BEGIN {
    split(exe, exev, /[[:space:]]+/);
    split(lib, libv, /[[:space:]]+/);
}

{
    print;

    matched = 0;
    if (tolower($1) == "executable") {
        for (i in exev) {
            if (exev[i] == $2) {
                matched = 1;
                break;
            }
        }
    }
    else if (tolower($1) == "library") {
        for (i in libv) {
            if (libv[i] == $2) {
                matched = 1;
                break;
            }
        }
    }

    if (matched) {
        # The Cabal format requires that indentation levels are
        # aligned. Read the next line and use the same indentation for
        # "buildable: False".
        if ((getline next_line) > 0) {
            match(next_line, /[[:space:]]+/);
            print substr(next_line, RSTART, RLENGTH) "buildable: False";
            print next_line;
        }
        else {
            print "Invalid cabal file: premature end of file right after \"executable\" or \"library\" line." > "/dev/stderr"
            exit 1
        }
    }
}

File Deleted: pkgsrc/mk/haskell/disable-executables.awk