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  1 15:06:27 UTC 2021

Modified Files:
        pkgsrc/mk: haskell.mk
Added Files:
        pkgsrc/mk/haskell: build-type.awk gen-setup.sh

Log Message:
Move lengthy awk and shell scripts out of haskell.mk


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 pkgsrc/mk/haskell.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/mk/haskell/build-type.awk \
    pkgsrc/mk/haskell/gen-setup.sh

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.31 pkgsrc/mk/haskell.mk:1.32
--- pkgsrc/mk/haskell.mk:1.31   Sat May  1 14:24:21 2021
+++ pkgsrc/mk/haskell.mk        Sat May  1 15:06:26 2021
@@ -1,4 +1,4 @@
-# $NetBSD: haskell.mk,v 1.31 2021/05/01 14:24:21 pho Exp $
+# $NetBSD: haskell.mk,v 1.32 2021/05/01 15:06:26 pho Exp $
 #
 # This Makefile fragment handles Haskell Cabal packages.
 # Package configuration, building, installation, registration and
@@ -222,35 +222,14 @@ do-configure:
 # actually lack it. The problem is that its expected content depends
 # on the build-type field in *.cabal so we have to read it.
        ${RUN} if ! ${TEST} -f ${WRKSRC}/Setup.hs -o -f ${WRKSRC}/Setup.lhs; then \
-               getBuildType=' \
-                       BEGIN { buildTypeLine=0 } \
-                       tolower($$1) ~ /^build-type:/ { \
-                               if ($$2) { \
-                                       print tolower($$2); exit \
-                               } \
-                               else { \
-                                       buildTypeLine=1; next \
-                               } \
-                       } \
-                       buildTypeLine { \
-                               print tolower($$1); exit \
-                       } \
-               '; \
-               buildType=`${CAT} ${WRKSRC}/*.cabal | ${AWK} "$$getBuildType"`; \
-               case "$$buildType" in \
-                       simple) \
-                               echo  >${WRKSRC}/Setup.hs 'import Distribution.Simple'; \
-                               echo >>${WRKSRC}/Setup.hs 'main = defaultMain';; \
-                       configure) \
-                               echo  >${WRKSRC}/Setup.hs 'import Distribution.Simple'; \
-                               echo >>${WRKSRC}/Setup.hs 'main = defaultMainWithHooks autoconfUserHooks';; \
-                       make) \
-                               echo  >${WRKSRC}/Setup.hs 'import Distribution.Make'; \
-                               echo >>${WRKSRC}/Setup.hs 'main = defaultMain';; \
-                       *) \
-                               echo >&2 "Unknown Build-Type: $$buildType"; \
-                               exit 1;; \
-               esac; \
+               buildType=`${AWK} -f ../../mk/haskell/build-type.awk ${WRKSRC}/*.cabal`; \
+               ${SH} ../../mk/haskell/gen-setup.sh "$$buildType" > ${WRKDIR}/.setup.hs; \
+               ret=$$?; \
+               if ${TEST} $$ret -eq 0; then \
+                       ${MV} -f ${WRKDIR}/.setup.hs ${WRKSRC}/Setup.hs; \
+               else \
+                       exit $$ret; \
+               fi; \
        fi
        ${RUN} ${_ULIMIT_CMD} cd ${WRKSRC} && \
                ( ${_HASKELL_BIN:Q} ${_HASKELL_BUILD_SETUP_OPTS} --make Setup -dynamic || \

Added files:

Index: pkgsrc/mk/haskell/build-type.awk
diff -u /dev/null pkgsrc/mk/haskell/build-type.awk:1.1
--- /dev/null   Sat May  1 15:06:27 2021
+++ pkgsrc/mk/haskell/build-type.awk    Sat May  1 15:06:26 2021
@@ -0,0 +1,23 @@
+# $NetBSD: build-type.awk,v 1.1 2021/05/01 15:06:26 pho Exp $
+#
+# Extract the field "Build-Type" out of a Cabal package description.
+#
+BEGIN {
+    buildTypeLine = 0
+}
+
+tolower($1) ~ /^build-type:/ {
+    if ($2) {
+        print tolower($2);
+        exit
+    }
+    else {
+        buildTypeLine = 1;
+        next
+    }
+}
+
+buildTypeLine {
+    print tolower($1);
+    exit
+}
Index: pkgsrc/mk/haskell/gen-setup.sh
diff -u /dev/null pkgsrc/mk/haskell/gen-setup.sh:1.1
--- /dev/null   Sat May  1 15:06:27 2021
+++ pkgsrc/mk/haskell/gen-setup.sh      Sat May  1 15:06:26 2021
@@ -0,0 +1,24 @@
+# $NetBSD: gen-setup.sh,v 1.1 2021/05/01 15:06:26 pho Exp $
+#
+# Generate the standard Setup.hs script for a given Cabal package.
+#
+: ${AWK=awk}
+
+# Usage: $0 BUILD-TYPE
+case "$1" in
+    simple)
+        echo 'import Distribution.Simple'
+        echo 'main = defaultMain'
+        ;;
+    configure)
+        echo 'import Distribution.Simple'
+        echo 'main = defaultMainWithHooks autoconfUserHooks'
+        ;;
+    make)
+        echo 'import Distribution.Make'
+        echo 'main = defaultMain'
+        ;;
+    *)
+        echo >&2 "Unknown Build-Type: $1"
+        exit 1
+esac



Home | Main Index | Thread Index | Old Index