aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: d1eec8654ab390f7c7429ca9110800d4c59a7be3 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
.POSIX:

CONFIGFILE = config.mk
include $(CONFIGFILE)

OS = linux
# Linux:   linux
# Mac OS:  macos
# Windows: windows
include mk/$(OS).mk


LIB_MAJOR = 1
LIB_MINOR = 0
LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)


HDR =\
	libsha1.h\
	common.h

OBJ =\
	algorithm_output_size.o\
	behex_lower.o\
	behex_upper.o\
	digest.o\
	hmac_digest.o\
	hmac_init.o\
	hmac_marshal.o\
	hmac_state_output_size.o\
	hmac_unmarshal.o\
	hmac_update.o\
	init.o\
	marshal.o\
	process.o\
	state_output_size.o\
	sum_fd.o\
	unhex.o\
	unmarshal.o\
	update.o

MAN0 =\
	libsha1.h.0

MAN3 =\
	libsha1_algorithm_output_size.3\
	libsha1_behex_lower.3\
	libsha1_behex_upper.3\
	libsha1_digest.3\
	libsha1_hmac_digest.3\
	libsha1_hmac_init.3\
	libsha1_hmac_marshal.3\
	libsha1_hmac_state_output_size.3\
	libsha1_hmac_unmarshal.3\
	libsha1_hmac_update.3\
	libsha1_init.3\
	libsha1_marshal.3\
	libsha1_state_output_size.3\
	libsha1_sum_fd.3\
	libsha1_unhex.3\
	libsha1_unmarshal.3\
	libsha1_update.3

LOBJ = $(OBJ:.o=.lo)


all: libsha1.a libsha1.$(LIBEXT) test
$(OBJ): $(HDR)
$(LOBJ): $(HDR)

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

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

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

libsha1.$(LIBEXT): $(LOBJ)
	$(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)

libsha1.a: $(OBJ)
	-rm -f -- $@
	$(AR) rc $@ $(OBJ)
	$(AR) -s $@

check: test
	./test

install: libsha1.a libsha1.$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man0"
	mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man3"
	cp -- libsha1.a "$(DESTDIR)$(PREFIX)/lib"
	cp -- libsha1.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libsha1.$(LIBMINOREXT)"
	$(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libsha1.$(LIBMINOREXT)"
	ln -sf -- "libsha1.$(LIBMINOREXT).$(LIB_MINOR)" "$(DESTDIR)$(PREFIX)/lib/libsha1.$(LIBMAJOREXT)"
	ln -sf -- "libsha1.$(LIBMAJOREXT)" "$(DESTDIR)$(PREFIX)/lib/libsha1.$(LIBEXT)"
	cp -- libsha1.h "$(DESTDIR)$(PREFIX)/include"
	cp -- $(MAN0) "$(DESTDIR)$(MANPREFIX)/man0"
	cp -- $(MAN3) "$(DESTDIR)$(MANPREFIX)/man3"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha1.a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha1.$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha1.$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsha1.$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libsha1.h"
	-cd -- "$(DESTDIR)$(MANPREFIX)/man0" && rm -f -- $(MAN0)
	-cd -- "$(DESTDIR)$(MANPREFIX)/man3" && rm -f -- $(MAN3)

clean:
	-rm -f -- *.o *.lo *.su *.a *.so test

.SUFFIXES:
.SUFFIXES: .lo .o .c

.PHONY: all check install uninstall clean