summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-01-29 16:24:44 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-01-29 16:24:44 -0500
commit08fa9bdae7e550666d5bc6ca7d089f70bd7f3cf1 (patch)
tree1c4ff9c873176f6096597875f8141f3af42c21eb /Makefile
parente89b125d341c9ade21a6aef97ea5ed8aa3084c93 (diff)
downloadbfs-08fa9bdae7e550666d5bc6ca7d089f70bd7f3cf1.tar.xz
Standardize WITH_* make variables for configuring dependencies
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile59
1 files changed, 40 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 8af4a99..6b0ed4d 100644
--- a/Makefile
+++ b/Makefile
@@ -64,38 +64,64 @@ LOCAL_CFLAGS := -std=c99
LOCAL_LDFLAGS :=
LOCAL_LDLIBS :=
-ASAN_CFLAGS := -fsanitize=address
-MSAN_CFLAGS := -fsanitize=memory -fsanitize-memory-track-origins
-UBSAN_CFLAGS := -fsanitize=undefined
+ASAN := $(filter asan,$(MAKECMDGOALS))
+MSAN := $(filter msan,$(MAKECMDGOALS))
+UBSAN := $(filter ubsan,$(MAKECMDGOALS))
ifeq ($(OS),Linux)
-LOCAL_LDFLAGS += -Wl,--as-needed
-LOCAL_LDLIBS += -lacl -lcap -lattr -lrt
+ifndef MSAN # These libraries are not built with msan
+WITH_ACL := y
+WITH_ATTR := y
+WITH_LIBCAP := y
+endif
-# These libraries are not built with msan, so disable them
-MSAN_CFLAGS += -DBFS_HAS_SYS_ACL=0 -DBFS_HAS_SYS_CAPABILITY=0 -DBFS_HAS_SYS_XATTR=0
+ifdef WITH_ACL
+LOCAL_LDLIBS += -lacl
+else
+LOCAL_CFLAGS += -DBFS_HAS_SYS_ACL=0
+endif
-DISTCHECK_FLAGS := TEST_FLAGS="--verbose --all --sudo"
+ifdef WITH_ATTR
+LOCAL_LDLIBS += -lattr
else
+LOCAL_CFLAGS += -DBFS_HAS_SYS_XATTR=0
+endif
+
+ifdef WITH_LIBCAP
+LOCAL_LDLIBS += -lcap
+else
+LOCAL_CFLAGS += -DBFS_HAS_SYS_CAPABILITY=0
+endif
+
+LOCAL_LDFLAGS += -Wl,--as-needed
+LOCAL_LDLIBS += -lrt
+
+DISTCHECK_FLAGS := TEST_FLAGS="--verbose --all --sudo"
+else # Linux
DISTCHECK_FLAGS := TEST_FLAGS="--verbose"
endif
+ifdef WITH_ONIGURUMA
+LOCAL_LDLIBS += -lonig
+LOCAL_CFLAGS += -DBFS_WITH_ONIGURUMA=1
+endif
+
ifeq ($(OS),NetBSD)
LOCAL_LDLIBS += -lutil
endif
-ifneq ($(filter asan,$(MAKECMDGOALS)),)
-LOCAL_CFLAGS += $(ASAN_CFLAGS)
+ifdef ASAN
+LOCAL_CFLAGS += -fsanitize=address
SANITIZE := y
endif
-ifneq ($(filter msan,$(MAKECMDGOALS)),)
-LOCAL_CFLAGS += $(MSAN_CFLAGS)
+ifdef MSAN
+LOCAL_CFLAGS += -fsanitize=memory -fsanitize-memory-track-origins
SANITIZE := y
endif
-ifneq ($(filter ubsan,$(MAKECMDGOALS)),)
-LOCAL_CFLAGS += $(UBSAN_CFLAGS)
+ifdef UBSAN
+LOCAL_CFLAGS += -fsanitize=undefined
SANITIZE := y
endif
@@ -111,11 +137,6 @@ ifneq ($(filter release,$(MAKECMDGOALS)),)
CFLAGS := $(DEFAULT_CFLAGS) -O3 -flto -DNDEBUG
endif
-ifeq ($(USE_ONIGURUMA),1)
-LOCAL_LDLIBS += -lonig
-LOCAL_CFLAGS += -DBFS_USE_ONIGURUMA=1
-endif
-
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
ALL_CFLAGS = $(ALL_CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) $(DEPFLAGS)
ALL_LDFLAGS = $(ALL_CFLAGS) $(LOCAL_LDFLAGS) $(LDFLAGS)