From 08fa9bdae7e550666d5bc6ca7d089f70bd7f3cf1 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sat, 29 Jan 2022 16:24:44 -0500 Subject: Standardize WITH_* make variables for configuring dependencies --- Makefile | 59 ++++++++++++++++++++++++++++++++++++++++------------------- eval.c | 2 +- expr.h | 2 +- parse.c | 2 +- regex.h | 27 +++++++++++++++++++++++++++ regexp.h | 27 --------------------------- util.c | 2 +- util.h | 3 ++- 8 files changed, 73 insertions(+), 51 deletions(-) create mode 100644 regex.h delete mode 100644 regexp.h 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 #include #include 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 #include 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 #include #include diff --git a/regex.h b/regex.h new file mode 100644 index 0000000..1a95239 --- /dev/null +++ b/regex.h @@ -0,0 +1,27 @@ +/**************************************************************************** + * bfs * + * Copyright (C) 2022 Tavian Barnes and bfs * + * contributors * + * * + * Permission to use, copy, modify, and/or distribute this software for any * + * purpose with or without fee is hereby granted. * + * * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * + ****************************************************************************/ + +#ifndef BFS_REGEX_H +#define BFS_REGEX_H + +#if BFS_WITH_ONIGURUMA +# include +#else +# include +#endif + +#endif // BFS_REGEX_H diff --git a/regexp.h b/regexp.h deleted file mode 100644 index 8654b58..0000000 --- a/regexp.h +++ /dev/null @@ -1,27 +0,0 @@ -/**************************************************************************** - * bfs * - * Copyright (C) 2022 Tavian Barnes and * - * BFS contributors * - * * - * Permission to use, copy, modify, and/or distribute this software for any * - * purpose with or without fee is hereby granted. * - * * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - ****************************************************************************/ - -#ifndef BFS_REGEXP_H -#define BFS_REGEXP_H - -#if BFS_USE_ONIGURUMA == 1 - #include -#else - #include -#endif - -#endif // BFS_REGEXP_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 #include #include 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 #include #include -- cgit v1.2.3