aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/goflags.sh
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-03-05 23:51:52 +0100
committerRobin Jarry <robin@jarry.cc>2023-03-06 23:54:06 +0100
commit8b26dc1d62c8ec258707527953bd0d2195684adf (patch)
tree49adb1d8e033e67a61ed4d1ec067a8bef3192255 /contrib/goflags.sh
parent4d3b1cb98bee1bed18fa6f47192186f8f3eb6e0e (diff)
downloadaerc-8b26dc1d62c8ec258707527953bd0d2195684adf.tar.gz
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 <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'contrib/goflags.sh')
-rwxr-xr-xcontrib/goflags.sh19
1 files changed, 19 insertions, 0 deletions
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 <<EOF
+#include <notmuch.h>
+
+void main(void) {
+ notmuch_status_to_string(NOTMUCH_STATUS_SUCCESS);
+}
+EOF
+
+if [ -n "$tags" ]; then
+ printf -- '-tags=%s\n' "${tags#,}"
+fi