From 8b26dc1d62c8ec258707527953bd0d2195684adf Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sun, 5 Mar 2023 23:51:52 +0100 Subject: mk: speed up notmuch detection Use gcc instead of go to build a basic program and determine if notmuch is available. Building a minimal go program takes more than 300ms on a fast machine. A minimal C counterpart takes less than 100ms. To avoid lag when doing bash completion, avoid running any shell commands directly during make evaluation. Rename check-notmuch.sh to goflags.sh and make that script print the goflags directly. Signed-off-by: Robin Jarry Tested-by: Inwit --- contrib/check-notmuch.sh | 20 -------------------- contrib/goflags.sh | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 20 deletions(-) delete mode 100755 contrib/check-notmuch.sh create mode 100755 contrib/goflags.sh (limited to 'contrib') diff --git a/contrib/check-notmuch.sh b/contrib/check-notmuch.sh deleted file mode 100755 index 6b5beb62..00000000 --- a/contrib/check-notmuch.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -tmp=$(mktemp -d) -trap "rm -rf $tmp" EXIT - -cat > $tmp/src.go < -import "C" - -func main() { - C.notmuch_status_to_string(C.NOTMUCH_STATUS_SUCCESS) -} -EOF - -${GO:-go} build -o $tmp/out $tmp/src.go diff --git a/contrib/goflags.sh b/contrib/goflags.sh new file mode 100755 index 00000000..90e4d9ee --- /dev/null +++ b/contrib/goflags.sh @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +tags= + +if ${CC:-cc} -x c - -o/dev/null -lnotmuch; then + tags="$tags,notmuch" +fi < + +void main(void) { + notmuch_status_to_string(NOTMUCH_STATUS_SUCCESS); +} +EOF + +if [ -n "$tags" ]; then + printf -- '-tags=%s\n' "${tags#,}" +fi -- cgit