summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-02-24 10:22:23 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-02-24 10:23:13 -0500
commit5da4a17cee4a4ba161fcd6aedbd99094446e6502 (patch)
treea9e339d6a5f1b7272d3c3ddcdb58534fcfee5202
parentcc70b2224d64ab38cbec569ff3df3dfde75bf017 (diff)
downloadbfs-5da4a17cee4a4ba161fcd6aedbd99094446e6502.tar.xz
Makefile: Automatically discover the right flags to build with Oniguruma
Fixes #82.
-rw-r--r--.github/workflows/freebsd.yml2
-rw-r--r--Makefile15
2 files changed, 12 insertions, 5 deletions
diff --git a/.github/workflows/freebsd.yml b/.github/workflows/freebsd.yml
index 40ed994..cdfa158 100644
--- a/.github/workflows/freebsd.yml
+++ b/.github/workflows/freebsd.yml
@@ -30,4 +30,4 @@ jobs:
run: |
muon=$(tailscale ip -6 muon)
rsync -rl --delete . "[$muon]:bfs"
- ssh "$muon" 'gmake -C bfs -j$(sysctl -n hw.ncpu) distcheck EXTRA_CPPFLAGS="-I/usr/local/include" EXTRA_LDFLAGS="-L/usr/local/lib"'
+ ssh "$muon" 'gmake -C bfs -j$(sysctl -n hw.ncpu) distcheck
diff --git a/Makefile b/Makefile
index 7c5cdcc..c22a9a7 100644
--- a/Makefile
+++ b/Makefile
@@ -73,8 +73,15 @@ WITH_ONIGURUMA := y
endif
ifdef WITH_ONIGURUMA
+LOCAL_CPPFLAGS += -DBFS_WITH_ONIGURUMA=1
+
+ONIG_CONFIG := $(shell command -v onig-config 2>/dev/null)
+ifdef ONIG_CONFIG
+LOCAL_CFLAGS += $(shell $(ONIG_CONFIG) --cflags)
+LOCAL_LDLIBS += $(shell $(ONIG_CONFIG) --libs)
+else
LOCAL_LDLIBS += -lonig
-LOCAL_CFLAGS += -DBFS_WITH_ONIGURUMA=1
+endif
endif
ifeq ($(OS),Linux)
@@ -87,19 +94,19 @@ endif
ifdef WITH_ACL
LOCAL_LDLIBS += -lacl
else
-LOCAL_CFLAGS += -DBFS_HAS_SYS_ACL=0
+LOCAL_CPPFLAGS += -DBFS_HAS_SYS_ACL=0
endif
ifdef WITH_ATTR
LOCAL_LDLIBS += -lattr
else
-LOCAL_CFLAGS += -DBFS_HAS_SYS_XATTR=0
+LOCAL_CPPFLAGS += -DBFS_HAS_SYS_XATTR=0
endif
ifdef WITH_LIBCAP
LOCAL_LDLIBS += -lcap
else
-LOCAL_CFLAGS += -DBFS_HAS_SYS_CAPABILITY=0
+LOCAL_CPPFLAGS += -DBFS_HAS_SYS_CAPABILITY=0
endif
LOCAL_LDFLAGS += -Wl,--as-needed