aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 26609015a45310fbd24dbd4c0f3ce8ae61bbcb5b (plain) (blame)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)


BIN =\
	bsum\
	b2sum

OBJ =\
	$(BIN:=.o)\
	common.o\
	test.o

HDR =\
	arg.h\
	common.h

ALIASES =\
	b224sum\
	b256sum\
	b384sum\
	b512sum

SRC =\
	$(OBJ:.o=.c)\
	$(HDR)\
	test.c

# Known answers tests 
KAT_FILES =\
        kat/blake2b\
        kat/blake2bp\
        kat/blake2s\
        kat/blake2sp\
        kat/blake2xb\
        kat/blake2xs


all: $(BIN) test
$(OBJ): $(HDR)

.c.o:
	$(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS)

bsum: bsum.o common.o
	$(CC) -o $@ $@.o common.o $(LDFLAGS)

b2sum: b2sum.o common.o
	$(CC) -o $@ $@.o common.o $(LDFLAGS)

test: test.o
	$(CC) -o $@ $@.o $(LDFLAGS)

check: test $(BIN) $(KAT_FILES)
	./test

install: $(BIN)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1/"
	cp -- $(BIN) "$(DESTDIR)$(PREFIX)/bin/"
	ln -sf -- bsum "$(DESTDIR)$(PREFIX)/bin/b224sum"
	ln -sf -- bsum "$(DESTDIR)$(PREFIX)/bin/b256sum"
	ln -sf -- bsum "$(DESTDIR)$(PREFIX)/bin/b384sum"
	ln -sf -- bsum "$(DESTDIR)$(PREFIX)/bin/b512sum"
	cp -- $(BIN:=.1) $(ALIASES:=.1) "$(DESTDIR)$(MANPREFIX)/man1/"

uninstall:
	-cd -- "$(DESTDIR)$(PREFIX)/bin/" && rm -f -- $(BIN) $(ALIASES)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man1/" && rm -f -- $(BIN:=.1) $(ALIASES:=.1)

clean:
	-rm -f -- *.o *.su *.gcov *.gcno *.gcda
	-rm -f -- $(BIN) test

.SUFFIXES:
.SUFFIXES: .o .c

.PHONY: all check install uninstall clean