summaryrefslogtreecommitdiffstats
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
parente89b125d341c9ade21a6aef97ea5ed8aa3084c93 (diff)
downloadbfs-08fa9bdae7e550666d5bc6ca7d089f70bd7f3cf1.tar.xz
Standardize WITH_* make variables for configuring dependencies
-rw-r--r--Makefile59
-rw-r--r--eval.c2
-rw-r--r--expr.h2
-rw-r--r--parse.c2
-rw-r--r--regex.h (renamed from regexp.h)16
-rw-r--r--util.c2
-rw-r--r--util.h3
7 files changed, 54 insertions, 32 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)
diff --git a/eval.c b/eval.c
index b5dfeed..5babf27 100644
--- a/eval.c
+++ b/eval.c
@@ -37,7 +37,7 @@
#include "time.h"
#include "trie.h"
#include "util.h"
-#include "regexp.h"
+#include "regex.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/expr.h b/expr.h
index a4e6c0d..6f0ebec 100644
--- a/expr.h
+++ b/expr.h
@@ -25,7 +25,7 @@
#include "eval.h"
#include "exec.h"
#include "printf.h"
-#include "regexp.h"
+#include "regex.h"
#include "stat.h"
#include <stdbool.h>
#include <stddef.h>
diff --git a/parse.c b/parse.c
index 2bf5992..acab8d5 100644
--- a/parse.c
+++ b/parse.c
@@ -41,7 +41,7 @@
#include "time.h"
#include "typo.h"
#include "util.h"
-#include "regexp.h"
+#include "regex.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/regexp.h b/regex.h
index 8654b58..1a95239 100644
--- a/regexp.h
+++ b/regex.h
@@ -1,7 +1,7 @@
/****************************************************************************
* bfs *
- * Copyright (C) 2022 Tavian Barnes <tavianator@tavianator.com> and *
- * BFS contributors *
+ * Copyright (C) 2022 Tavian Barnes <tavianator@tavianator.com> and bfs *
+ * contributors *
* *
* Permission to use, copy, modify, and/or distribute this software for any *
* purpose with or without fee is hereby granted. *
@@ -15,13 +15,13 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
****************************************************************************/
-#ifndef BFS_REGEXP_H
-#define BFS_REGEXP_H
+#ifndef BFS_REGEX_H
+#define BFS_REGEX_H
-#if BFS_USE_ONIGURUMA == 1
- #include <onigposix.h>
+#if BFS_WITH_ONIGURUMA
+# include <onigposix.h>
#else
- #include <regex.h>
+# include <regex.h>
#endif
-#endif // BFS_REGEXP_H
+#endif // BFS_REGEX_H
diff --git a/util.c b/util.c
index 9e221a8..e737c09 100644
--- a/util.c
+++ b/util.c
@@ -16,7 +16,7 @@
#include "util.h"
#include "dstring.h"
-#include "regexp.h"
+#include "regex.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
diff --git a/util.h b/util.h
index 893651e..c0551a2 100644
--- a/util.h
+++ b/util.h
@@ -20,7 +20,8 @@
#ifndef BFS_UTIL_H
#define BFS_UTIL_H
-#include "regexp.h"
+
+#include "regex.h"
#include <fcntl.h>
#include <fnmatch.h>
#include <stdbool.h>