aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-01-15 18:32:56 -0800
committerBruce Hill <bruce@bruce-hill.com>2021-01-15 18:32:56 -0800
commit631e59bfa7e2f2c0050ad1a84ff70feb8768626d (patch)
treec3d9310b365537f6b5cc74f08d3a71718c4b4ff5 /Makefile
parentd31d2e89850d3132850e0f2e1ce6d973bd482073 (diff)
Fully supporting NAME make argument
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile15
1 files changed, 8 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index 5a57bd4..a0cf193 100644
--- a/Makefile
+++ b/Makefile
@@ -4,9 +4,10 @@ PREFIX=/usr/local
SYSCONFDIR=/etc
CFLAGS=-std=c99 -Werror -D_XOPEN_SOURCE=700 -D_GNU_SOURCE -D_POSIX_C_SOURCE=200809L
CWARN=-Wall -Wpedantic -Wextra -Wsign-conversion -Wtype-limits -Wunused-result
-EXTRA_FLAGS=
+EXTRA=
G=
O=-O3
+ALL_FLAGS=$(CFLAGS) -DBP_NAME="\"$(NAME)\"" $(EXTRA) $(CWARN) $(G) $(O)
CFILES=compiler.c grammar.c utils.c vm.c file_loader.c printing.c json.c
OBJFILES=$(CFILES:.c=.o)
@@ -14,27 +15,27 @@ OBJFILES=$(CFILES:.c=.o)
all: $(NAME)
%.o: %.c %.h types.h
- $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(CWARN) $(G) $(O) -o $@ $<
+ $(CC) -c $(ALL_FLAGS) -o $@ $<
$(NAME): $(OBJFILES) bp.c
- $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CWARN) $(G) $(O) -o $@ $(OBJFILES) bp.c
+ $(CC) $(ALL_FLAGS) -o $@ $(OBJFILES) bp.c
clean:
rm -f $(NAME) $(OBJFILES)
leaktest:
- make G=-ggdb O=-O0 EXTRA_CFLAGS=-DDEBUG_HEAP clean bp
+ make G=-ggdb O=-O0 EXTRA=-DDEBUG_HEAP clean bp
valgrind --leak-check=full ./bp -l -g grammars/bpeg.bp -p Grammar grammars/bpeg.bp
install: $(NAME)
- mkdir -p -m 755 "$(PREFIX)/share/man/man1" "$(PREFIX)/bin" "$(SYSCONFDIR)/xdg/bp"
- cp -rv grammars/* "$(SYSCONFDIR)/xdg/bp/"
+ mkdir -p -m 755 "$(PREFIX)/share/man/man1" "$(PREFIX)/bin" "$(SYSCONFDIR)/xdg/$(NAME)"
+ cp -rv grammars/* "$(SYSCONFDIR)/xdg/$(NAME)/"
cp -v bp.1 "$(PREFIX)/share/man/man1/$(NAME).1"
rm -f "$(PREFIX)/bin/$(NAME)"
cp -v $(NAME) "$(PREFIX)/bin/"
uninstall:
- rm -rvf "$(PREFIX)/bin/$(NAME)" "$(PREFIX)/share/man/man1/$(NAME).1" "$(SYSCONFDIR)/xdg/bp";
+ rm -rvf "$(PREFIX)/bin/$(NAME)" "$(PREFIX)/share/man/man1/$(NAME).1" "$(SYSCONFDIR)/xdg/$(NAME)";
@if [ -d ~/.config/$(NAME) ]; then \
printf 'Config files exist in ~/.config/$(NAME) Do you want to delete them? [Y/n] '; \
read confirm; \