bp/Makefile

52 lines
1.6 KiB
Makefile
Raw Normal View History

NAME=bp
2021-01-02 13:57:04 -08:00
CC=cc
2020-09-11 01:28:06 -07:00
PREFIX=/usr/local
2021-01-04 17:32:56 -08:00
SYSCONFDIR=/etc
2021-01-02 13:57:04 -08:00
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
2021-01-15 18:32:56 -08:00
EXTRA=
2021-01-02 13:57:04 -08:00
G=
O=-O3
2021-01-15 18:32:56 -08:00
ALL_FLAGS=$(CFLAGS) -DBP_NAME="\"$(NAME)\"" $(EXTRA) $(CWARN) $(G) $(O)
2020-09-07 23:05:38 -07:00
2021-01-15 19:35:39 -08:00
CFILES=pattern.c definitions.c utils.c match.c files.c print.c json.c
2020-09-11 01:28:06 -07:00
OBJFILES=$(CFILES:.c=.o)
2020-09-11 01:54:26 -07:00
all: $(NAME)
2020-09-07 23:05:38 -07:00
%.o: %.c %.h types.h
2021-01-15 18:32:56 -08:00
$(CC) -c $(ALL_FLAGS) -o $@ $<
2020-09-07 23:05:38 -07:00
2021-01-15 18:02:12 -08:00
$(NAME): $(OBJFILES) bp.c
2021-01-15 18:32:56 -08:00
$(CC) $(ALL_FLAGS) -o $@ $(OBJFILES) bp.c
2020-09-11 01:28:06 -07:00
clean:
2020-09-11 01:54:26 -07:00
rm -f $(NAME) $(OBJFILES)
2020-09-07 23:05:38 -07:00
leaktest:
2021-01-15 18:32:56 -08:00
make G=-ggdb O=-O0 EXTRA=-DDEBUG_HEAP clean bp
2021-01-17 23:26:24 -08:00
valgrind --leak-check=full ./bp -l -g grammars/bp.bp -p Grammar grammars/bp.bp
2021-01-18 09:15:25 -08:00
splint:
2021-01-18 11:15:53 -08:00
splint -posix-lib -standard -mustfreefresh -mustfreeonly -temptrans -immediatetrans -branchstate \
-compmempass -nullret -nullpass -nullderef -kepttrans -boolops -initallelements -fullinitblock \
-compdef -usereleased -unrecog -dependenttrans -predboolothers -ownedtrans -unqualifiedtrans \
-onlytrans $(CFILES) bp.c
2021-01-18 09:15:25 -08:00
2020-09-11 01:54:26 -07:00
install: $(NAME)
2021-01-15 18:32:56 -08:00
mkdir -p -m 755 "$(PREFIX)/share/man/man1" "$(PREFIX)/bin" "$(SYSCONFDIR)/xdg/$(NAME)"
2021-01-17 23:39:29 -08:00
cp -r grammars/* "$(SYSCONFDIR)/xdg/$(NAME)/"
cp bp.1 "$(PREFIX)/share/man/man1/$(NAME).1"
2021-01-04 17:32:56 -08:00
rm -f "$(PREFIX)/bin/$(NAME)"
2021-01-17 23:39:29 -08:00
cp $(NAME) "$(PREFIX)/bin/"
2020-09-11 01:54:26 -07:00
uninstall:
2021-01-17 23:40:21 -08:00
rm -rf "$(PREFIX)/bin/$(NAME)" "$(PREFIX)/share/man/man1/$(NAME).1" "$(SYSCONFDIR)/xdg/$(NAME)"
2021-01-04 17:32:56 -08:00
@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
2021-01-18 09:15:25 -08:00
.PHONY: all clean install uninstall leaktest splint