pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/mk



Module Name:    pkgsrc
Committed By:   pho
Date:           Sat May  4 11:21:27 UTC 2024

Modified Files:
        pkgsrc/mk: haskell.mk
Added Files:
        pkgsrc/mk/haskell: disable-components.awk
Removed Files:
        pkgsrc/mk/haskell: disable-executables.awk

Log Message:
mk/haskell.mk: New package-settable variable: HASKELL_DISABLE_LIBRARIES


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 pkgsrc/mk/haskell.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/haskell/disable-components.awk
cvs rdiff -u -r1.2 -r0 pkgsrc/mk/haskell/disable-executables.awk

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/mk/haskell.mk
diff -u pkgsrc/mk/haskell.mk:1.67 pkgsrc/mk/haskell.mk:1.68
--- pkgsrc/mk/haskell.mk:1.67   Mon Apr 29 07:58:38 2024
+++ pkgsrc/mk/haskell.mk        Sat May  4 11:21:26 2024
@@ -1,4 +1,4 @@
-# $NetBSD: haskell.mk,v 1.67 2024/04/29 07:58:38 pho Exp $
+# $NetBSD: haskell.mk,v 1.68 2024/05/04 11:21:26 pho Exp $
 #
 # This Makefile fragment handles Haskell Cabal packages. Package
 # configuration, building, installation, registration and unregistration
@@ -48,6 +48,13 @@
 #
 #      Default value: empty
 #
+# HASKELL_DISABLE_LIBRARIES
+#      A list of libraries that we don't want to build or install. Listing
+#      libraries in this variable will cause the *.cabal file to be
+#      rewritten so that they won't be built.
+#
+#      Default value: empty
+#
 # HASKELL_UNRESTRICT_DEPENDENCIES
 #      A list of Cabal packages that the package depends on, whose version
 #      constraints are way too restricted to solve. Listing packages in
@@ -101,6 +108,7 @@ _PKG_VARS.haskell= \
        HASKELL_OPTIMIZATION_LEVEL \
        HASKELL_PKG_NAME \
        HASKELL_DISABLE_EXECUTABLES \
+       HASKELL_DISABLE_LIBRARIES \
        HASKELL_UNRESTRICT_DEPENDENCIES \
        PKGNAME HOMEPAGE MASTER_SITES
 _DEF_VARS.haskell= \
@@ -136,6 +144,7 @@ _USE_VARS.haskell= \
        _PATH_ORIG
 _SORTED_VARS.haskell= \
        HASKELL_DISABLE_EXECUTABLES \
+       HASKELL_DISABLE_LIBRARIES \
        HASKELL_UNRESTRICT_DEPENDENCIES
 _LISTED_VARS.haskell= \
        BUILDLINK_PASSTHRU_DIRS \
@@ -160,6 +169,7 @@ HASKELL_ENABLE_LIBRARY_PROFILING?=  yes
 HASKELL_ENABLE_HADDOCK_DOCUMENTATION?= yes
 HASKELL_ENABLE_TESTS?=                 no
 HASKELL_DISABLE_EXECUTABLES?=          # empty
+HASKELL_DISABLE_LIBRARIES?=            # empty
 HASKELL_UNRESTRICT_DEPENDENCIES?=      # empty
 
 .include "../../lang/ghc96/buildlink3.mk"
@@ -196,17 +206,29 @@ _HASKELL_BUILD_SETUP_OPTS=        -package-env 
 # GHC requires C compiler.
 USE_LANGUAGES+=        c
 
-# Some Haskell libraries builds and installs example executables that are
-# useless aside from debugging the libraries, and we don't want them to be
+# Some Haskell packages build and install example executables that are
+# useless aside from debugging the packages, and we don't want them to be
 # installed.
 .if !empty(HASKELL_DISABLE_EXECUTABLES)
-SUBST_CLASSES+=                exec
-SUBST_STAGE.exec?=     post-extract
-SUBST_FILES.exec?=     ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal
-SUBST_MESSAGE.exec?=   Disabling executables: ${HASKELL_DISABLE_EXECUTABLES}
-SUBST_FILTER_CMD.exec= \
-       ${AWK} -f "${.CURDIR}/../../mk/haskell/disable-executables.awk" \
-               -v exec=${HASKELL_DISABLE_EXECUTABLES:Q}
+SUBST_CLASSES+=                exe
+SUBST_STAGE.exe?=      post-extract
+SUBST_FILES.exe?=      ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal
+SUBST_MESSAGE.exe?=    Disabling executables: ${HASKELL_DISABLE_EXECUTABLES}
+SUBST_FILTER_CMD.exe=  \
+       ${AWK} -f "${.CURDIR}/../../mk/haskell/disable-components.awk" \
+               -v exe=${HASKELL_DISABLE_EXECUTABLES:Q}
+.endif
+
+# Some Haskell packages build and install libraries that are useless aside
+# from debugging the packages, and we don't want them to be installed.
+.if !empty(HASKELL_DISABLE_LIBRARIES)
+SUBST_CLASSES+=                lib
+SUBST_STAGE.lib?=      post-extract
+SUBST_FILES.lib?=      ${HASKELL_PKG_NAME:C/-[[:digit:].]+$//}.cabal
+SUBST_MESSAGE.lib?=    Disabling libraries: ${HASKELL_DISABLE_LIBRARIES}
+SUBST_FILTER_CMD.lib=  \
+       ${AWK} -f "${.CURDIR}/../../mk/haskell/disable-components.awk" \
+               -v lib=${HASKELL_DISABLE_LIBRARIES:Q}
 .endif
 
 # Haskell packages don't use semvars but they use something similar to it,
@@ -440,6 +462,7 @@ do-configure:
                        $$setup_src '"$$@"' >> Setup; \
                ${CHMOD} +x Setup; \
        else \
+               ${ECHO} "[mk/haskell.mk] Failed to interpret $$setup_src; falling back to compilation"; \
                ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -dynamic || \
                        ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -static; \
                ${SETENV} ${CONFIGURE_ENV} \

Added files:

Index: pkgsrc/mk/haskell/disable-components.awk
diff -u /dev/null pkgsrc/mk/haskell/disable-components.awk:1.1
--- /dev/null   Sat May  4 11:21:27 2024
+++ pkgsrc/mk/haskell/disable-components.awk    Sat May  4 11:21:26 2024
@@ -0,0 +1,47 @@
+# $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
+        }
+    }
+}



Home | Main Index | Thread Index | Old Index