aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 8871eaa2de4b512318cf1cd475396ae4c66fc137 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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=200112L
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 params.o util.o eprintf.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) -t $(DESTDIR)$(PREFIX)$(bindir)
	install -Dm644 ./data/* -t $(DESTDIR)$(PREFIX)$(datarootdir)/$(PROG)
	install -Dm644 $(MANPAGE) -t $(DESTDIR)$(PREFIX)$(mandir)/man1

clean:
	$(RM) $(OBJ) $(OBJ:.o=.d) $(PROG)

-include $(OBJ:.o=.d)

.PHONY: all debug install clean