aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile43
1 files changed, 43 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..f1abf21
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,43 @@
+VERSION != git describe --tags 2>/dev/null || echo "0.1"
+PROG := hktool
+MANPAGE := hktool.1
+
+WARNINGS := -Wall -Wcast-align -Wcast-qual -Wextra -Wpedantic -Wformat=2 \
+ -Winit-self -Wmissing-prototypes -Wpointer-arith -Wshadow \
+ -Wstrict-prototypes -Wsuggest-attribute=format \
+ -Wsuggest-attribute=noreturn
+
+PKG_CONFIG ?= pkg-config
+
+LIBS := libusb-1.0
+CPPFLAGS = -DVERSION=\"$(VERSION)\" -D_POSIX_C_SOURCE=200809L
+CFLAGS = -std=c11 -O2 -flto $(WARNINGS) -MMD -MP $(shell $(PKG_CONFIG) --cflags $(LIBS))
+LDFLAGS = -Wl,--as-needed -O2 -flto
+LDLIBS = $(shell $(PKG_CONFIG) --libs $(LIBS))
+
+OBJ := hktool.o halfkay.o log.o params.o util.o
+
+PREFIX ?= /usr/local
+
+bindir = /bin
+datarootdir = /share
+mandir = /man
+
+all: $(PROG)
+$(PROG): $(OBJ)
+
+debug: all
+debug: CFLAGS += -ggdb -Og -Werror
+debug: LDFLAGS += -ggdb -Og
+
+install: $(PROG) $(MANPAGE)
+ install -Dm755 -s $(PROG) $(DESTDIR)$(PREFIX)$(bindir)
+ install -Dm644 ./data/* -t $(DESTDIR)$(PREFIX)$(datarootdir)/$(PROG)/
+ install -Dm644 $(MANPAGE) $(DESTDIR)$(PREFIX)$(mandir)/man1/
+
+clean:
+ $(RM) $(OBJ) $(OBJ:.o=.d) $(PROG)
+
+-include $(OBJ:.o=.d)
+
+.PHONY: all debug install clean