bp/Makefile

78 lines
3.1 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-07-06 11:45:40 -07:00
CFLAGS=-std=c99 -Werror -D_XOPEN_SOURCE=700 -D_POSIX_C_SOURCE=200809L -flto
CWARN=-Wall -Wextra
# -Wpedantic -Wsign-conversion -Wtype-limits -Wunused-result -Wnull-dereference \
# -Waggregate-return -Walloc-zero -Walloca -Warith-conversion -Wcast-align -Wcast-align=strict \
# -Wdangling-else -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches \
# -Wduplicated-cond -Wexpansion-to-defined -Wfloat-conversion -Wfloat-equal -Wformat-nonliteral \
# -Wformat-security -Wformat-signedness -Wframe-address -Winline -Winvalid-pch -Wjump-misses-init \
# -Wlogical-op -Wlong-long -Wmissing-format-attribute -Wmissing-include-dirs -Wmissing-noreturn \
# -Wnull-dereference -Woverlength-strings -Wpacked -Wpacked-not-aligned -Wpointer-arith \
# -Wredundant-decls -Wshadow -Wshadow=compatible-local -Wshadow=global -Wshadow=local \
# -Wsign-conversion -Wstack-protector -Wsuggest-attribute=const -Wswitch-default -Wswitch-enum \
# -Wsync-nand -Wtrampolines -Wundef -Wunsuffixed-float-constants -Wunused -Wunused-but-set-variable \
# -Wunused-const-variable -Wunused-local-typedefs -Wunused-macros -Wvariadic-macros -Wvector-operation-performance \
# -Wvla -Wwrite-strings
OSFLAGS != case $$(uname -s) in *BSD|Darwin) echo '-D_BSD_SOURCE';; Linux) echo '-D_GNU_SOURCE';; *) echo '-D_DEFAULT_SOURCE';; esac
2021-01-15 18:32:56 -08:00
EXTRA=
2021-01-02 13:57:04 -08:00
G=
O=-O3
2021-07-06 11:45:40 -07:00
ALL_FLAGS=$(CFLAGS) $(OSFLAGS) -DBP_NAME="\"$(NAME)\"" $(EXTRA) $(CWARN) $(G) $(O)
2020-09-07 23:05:38 -07:00
CFILES=pattern.c definitions.c utils.c match.c files.c print.c json.c utf8.c
2020-09-11 01:28:06 -07:00
OBJFILES=$(CFILES:.c=.o)
all: $(NAME) bp.1
2020-09-07 23:05:38 -07:00
2021-05-20 15:27:24 -07:00
%.o: %.c %.h types.h utf8.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
bp.1: bp.1.md
pandoc --lua-filter=.pandoc/bold-code.lua -s $< -t man -o $@
2021-01-18 15:12:01 -08:00
tags: $(CFILES) bp.c
ctags *.c *.h
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
test: $(NAME)
./$(NAME) -g ./grammars/bp.bp -p Grammar ./grammars/bp.bp
2021-05-10 23:43:54 -07:00
leaktest:
2021-01-15 18:32:56 -08:00
make G=-ggdb O=-O0 EXTRA=-DDEBUG_HEAP clean bp
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:55:05 -08:00
splint -posix-lib -weak -unrecog -initallelements -fullinitblock $(CFILES) bp.c
#splint:
# splint -posix-lib -checks -mustfreefresh -mustfreeonly -temptrans -immediatetrans -branchstate \
# -compmempass -nullret -nullpass -nullderef -kepttrans -boolops -initallelements -fullinitblock \
# -compdef -usereleased -unrecog -dependenttrans -predboolothers -ownedtrans -unqualifiedtrans \
# -onlytrans -usedef -nullassign -compdestroy -globstate -nullstate -statictrans -predboolint \
# $(CFILES) bp.c
2021-01-18 09:15:25 -08:00
2021-05-19 22:03:34 -07:00
install: $(NAME) bp.1
2021-07-03 21:43:56 -07:00
mkdir -p -m 755 "$(PREFIX)/man/man1" "$(PREFIX)/bin" "$(SYSCONFDIR)/$(NAME)"
cp -r grammars/* "$(SYSCONFDIR)/$(NAME)/"
cp bp.1 "$(PREFIX)/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-07-03 21:43:56 -07:00
rm -rf "$(PREFIX)/bin/$(NAME)" "$(PREFIX)/man/man1/$(NAME).1" "$(SYSCONFDIR)/$(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-05-10 23:43:54 -07:00
.PHONY: all clean install uninstall leaktest splint test