aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-24 20:33:47 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-24 20:33:47 -0400
commit4ec3e11b9f542a0239de7bedad9d732b0a20d68b (patch)
tree276f2c56ccd63016a6ba1a3b12923d5c631b0555 /Makefile
parent3d5944a732e34b6dd01921dee991dee54af47e18 (diff)
parentfe6da3015573079229a0da3166eb4b5f36520dbb (diff)
Merge branch 'main' of github.com:bruce-hill/bp
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile37
1 files changed, 24 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 9c646bb..12cac3e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,23 @@
+ifeq ($(wildcard config.mk),)
+all: config.mk
+ $(MAKE) all
+install: config.mk
+ $(MAKE) install
+install-files: config.mk
+ $(MAKE) install-files
+install-lib: config.mk
+ $(MAKE) install-lib
+test: config.mk
+ $(MAKE) test
+config.mk: configure.sh
+ bash ./configure.sh
+else
+
+include config.mk
NAME=bp
CC=cc
-PREFIX=/usr/local
-SYSCONFDIR=/etc
-CFLAGS=-std=c11 -Werror -D_XOPEN_SOURCE=800 -D_POSIX_C_SOURCE=200809L -fPIC -flto=auto -fvisibility=hidden \
- -fsanitize=signed-integer-overflow -fno-sanitize-recover
+CFLAGS=-std=c2x -Werror -D_GNU_SOURCE -fPIC -flto=auto -fvisibility=hidden \
+ -fsanitize=signed-integer-overflow -fno-sanitize-recover -DBP_PREFIX='"$(PREFIX)"'
CWARN=-Wall -Wextra -Wno-format -Wshadow
# -Wpedantic -Wsign-conversion -Wtype-limits -Wunused-result -Wnull-dereference \
# -Waggregate-return -Walloc-zero -Walloca -Warith-conversion -Wcast-align -Wcast-align=strict \
@@ -34,7 +48,7 @@ $(NAME): $(OBJFILES) bp.c
$(LIBFILE): pattern.o utils.o match.o utf8.o
$(CC) $^ $(ALL_FLAGS) -Wl,-soname,$(LIBFILE) -shared -o $@
-all: $(NAME) $(LIBFILE) bp.1 lua
+all: $(NAME) bp.1
%.o: %.c %.h utf8.h
$(CC) -c $(ALL_FLAGS) -o $@ $<
@@ -80,8 +94,8 @@ splint:
# $(CFILES) bp.c
install: $(NAME) bp.1
- mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/bin" "$(SYSCONFDIR)/$(NAME)"
- cp -r grammars/* "$(SYSCONFDIR)/$(NAME)/"
+ mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/bin" "$(PREFIX)/share/$(NAME)"
+ cp -r grammars "$(PREFIX)/share/$(NAME)/"
cp bp.1 "$(PREFIX)/man/man1/$(NAME).1"
rm -f "$(PREFIX)/bin/$(NAME)"
cp $(NAME) "$(PREFIX)/bin/"
@@ -92,12 +106,7 @@ install-lib: $(LIBFILE) bp.1
cp pattern.h match.h "$(PREFIX)/include/$(NAME)"
uninstall:
- rm -rf "$(PREFIX)/bin/$(NAME)" "$(PREFIX)/man/man1/$(NAME).1" "$(SYSCONFDIR)/$(NAME)"
- @if [ -d ~/.config/$(NAME) ]; then \
- printf 'Config files exist in ~/.config/$(NAME) Do you want to delete them? [Y/n] '; \
- read confirm; \
- [ "$$confirm" != n ] && rm -rf ~/.config/$(NAME); \
- fi
+ rm -rf "$(PREFIX)/bin/$(NAME)" "$(PREFIX)/man/man1/$(NAME).1" "$(PREFIX)/share/$(NAME)"
profile_grammar: bp
perf stat -r 100 -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores -e cycles ./bp -f plain -g bp -p Grammar grammars/bp.bp >/dev/null
@@ -105,4 +114,6 @@ profile_grammar: bp
profile_pattern: bp
perf stat -r 1 -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores -e cycles ./bp -f plain -p 'id parens' /usr/include/*.h >/dev/null
+endif
+
.PHONY: all clean install install-lib uninstall leaktest splint test tutorial lua profile luatest