CC := clang STD := c17 DEBUG ?= 1 SANITIZE ?= 1 CFLAGS := -std=$(STD) \ -Wall \ -Wextra \ -Wshadow \ -Wpedantic \ -Wconversion \ -Wstrict-prototypes \ -Wsign-conversion \ -Wmissing-prototypes ifeq ($(DEBUG),1) CFLAGS += -g -fno-omit-frame-pointer else CFLAGS += -O2 endif ifeq ($(SANITIZE),1) CFLAGS += -fsanitize=address,undefined LDFLAGS += -fsanitize=address,undefined endif TARGET := mkproj SRC := mkproj.c PREFIX ?= /usr/local bindir := $(DESTDIR)$(PREFIX)/bin mandir := $(DESTDIR)$(PREFIX)/share/man/man1 bashdir := $(DESTDIR)$(PREFIX)/share/bash-completion/completions zshdir := $(DESTDIR)$(PREFIX)/share/zsh/site-functions fishdir := $(DESTDIR)$(PREFIX)/share/fish/vendor_completions.d all: $(TARGET) $(TARGET): $(SRC) $(CC) $(CFLAGS) $< -o $@ $(LDFLAGS) check: bear -- make clean all cppcheck --enable=warning,style,performance,portability \ --project=compile_commands.json \ --error-exitcode=1 test: $(TARGET) @sh tests.sh clean: rm -rf $(TARGET) $(TARGET).dSYM install: mkproj.1 make DEBUG=0 SANITIZE=0 clean all install -d $(bindir) install -m 755 $(TARGET) $(bindir)/$(TARGET) install -d $(mandir) install -m 644 mkproj.1 $(mandir)/mkproj.1 install -d $(bashdir) $(zshdir) $(fishdir) ./$(TARGET) --completions bash > $(bashdir)/mkproj ./$(TARGET) --completions zsh > $(zshdir)/_mkproj ./$(TARGET) --completions fish > $(fishdir)/mkproj.fish uninstall: rm -f $(bindir)/$(TARGET) rm -f $(mandir)/mkproj.1 rm -f $(bashdir)/mkproj rm -f $(zshdir)/_mkproj rm -f $(fishdir)/mkproj.fish .PHONY: all check test clean install uninstall