pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk Move lengthy awk and shell scripts out of haskell.mk



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ef7547c158ae
branches:  trunk
changeset: 451791:ef7547c158ae
user:      pho <pho%pkgsrc.org@localhost>
date:      Sat May 01 15:06:26 2021 +0000

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

diffstat:

 mk/haskell.mk             |  39 +++++++++------------------------------
 mk/haskell/build-type.awk |  23 +++++++++++++++++++++++
 mk/haskell/gen-setup.sh   |  24 ++++++++++++++++++++++++
 3 files changed, 56 insertions(+), 30 deletions(-)

diffs (108 lines):

diff -r 11e9160717c1 -r ef7547c158ae mk/haskell.mk
--- a/mk/haskell.mk     Sat May 01 14:42:46 2021 +0000
+++ b/mk/haskell.mk     Sat May 01 15:06:26 2021 +0000
@@ -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 @@
 # 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 || \
diff -r 11e9160717c1 -r ef7547c158ae mk/haskell/build-type.awk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/haskell/build-type.awk Sat May 01 15:06:26 2021 +0000
@@ -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
+}
diff -r 11e9160717c1 -r ef7547c158ae mk/haskell/gen-setup.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/haskell/gen-setup.sh   Sat May 01 15:06:26 2021 +0000
@@ -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