Received: by mail.netbsd.org (Postfix, from userid 605) id 766308531B; Sat, 1 May 2021 15:06:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id B28D9852CF for ; Sat, 1 May 2021 15:06:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id e7u1isNHZFQR for ; Sat, 1 May 2021 15:06:27 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 20CF8850EA for ; Sat, 1 May 2021 15:06:27 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 1A63FFA95; Sat, 1 May 2021 15:06:27 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1619881587262220" MIME-Version: 1.0 Date: Sat, 1 May 2021 15:06:27 +0000 From: "Masatake Daimon" Subject: CVS commit: pkgsrc/mk To: pkgsrc-changes@NetBSD.org Reply-To: pho@netbsd.org X-Mailer: log_accum Message-Id: <20210501150627.1A63FFA95@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1619881587262220 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" 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. --_----------=_1619881587262220 Content-Disposition: inline Content-Length: 3455 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii 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 --_----------=_1619881587262220--