aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--README.md19
-rwxr-xr-xcontrib/check-notmuch.sh20
3 files changed, 39 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 965d6596..781c63b1 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,8 @@ SHAREDIR?=$(PREFIX)/share/aerc
LIBEXECDIR?=$(PREFIX)/libexec/aerc
MANDIR?=$(PREFIX)/share/man
GO?=go
-GOFLAGS?=
+default_goflags!=GO=$(GO) contrib/check-notmuch.sh 2>/dev/null && echo -tags=notmuch
+GOFLAGS?=$(default_goflags)
BUILD_OPTS?=-trimpath
flags!=echo -- $(GOFLAGS) | base64 | tr -d '\n'
# ignore environment variable
diff --git a/README.md b/README.md
index 92968767..a30020f5 100644
--- a/README.md
+++ b/README.md
@@ -77,9 +77,24 @@ Then compile aerc:
aerc optionally supports notmuch. To enable it, you need to have a recent
version of [notmuch](https://notmuchmail.org/#index7h2), including the header
-files (notmuch.h). Then compile aerc with the necessary build tags:
+files (notmuch.h). The `notmuch` build tag should be automatically added.
- $ GOFLAGS=-tags=notmuch make
+ $ make
+ GOFLAGS have changed, recompiling
+ go build -trimpath -tags=notmuch -ldflags "-X ...
+ ^^^^^^^^^^^^^
+ ...
+
+If it is not, you can force it before building:
+
+ $ export GOFLAGS=-tags=notmuch
+ $ make
+
+If you have notmuch headers available but do not want to build notmuch support
+in aerc, force GOFLAGS to an empty value:
+
+ $ export GOFLAGS=
+ $ make
To install aerc locally:
diff --git a/contrib/check-notmuch.sh b/contrib/check-notmuch.sh
new file mode 100755
index 00000000..6b5beb62
--- /dev/null
+++ b/contrib/check-notmuch.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+set -e
+
+tmp=$(mktemp -d)
+trap "rm -rf $tmp" EXIT
+
+cat > $tmp/src.go <<EOF
+package main
+
+// #cgo LDFLAGS: -lnotmuch
+// #include <notmuch.h>
+import "C"
+
+func main() {
+ C.notmuch_status_to_string(C.NOTMUCH_STATUS_SUCCESS)
+}
+EOF
+
+${GO:-go} build -o $tmp/out $tmp/src.go