blob: 492b88bee1439a9c599874a25e8b4640df74b532 (
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
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
|
--- canlock2b/Makefile
+++ canlock2b/Makefile
@@ -1,33 +1,35 @@
-CFLAGS = -Iinclude
-LDFLAGS = -L. -lcanlock
+CFLAGS += -Iinclude
+LIBS = -L. -lcanlock
CC = gcc
-STATIC_LIB = libcanlock.a
-all: hmactest canlocktest $(STATIC_LIB)
+all: shared static
-sha1test: t/sha1test.c $(STATIC_LIB)
- $(CC) $(CFLAGS) t/$@.c -o $@ $(LDFLAGS)
+sha1test: t/sha1test.c shared
+ $(CC) $(CFLAGS) t/$@.c -o $@ $(LIBS) $(LDFLAGS)
-hmactest: t/hmactest.c $(STATIC_LIB)
- $(CC) $(CFLAGS) t/$@.c -o $@ $(LDFLAGS)
+hmactest: t/hmactest.c shared
+ $(CC) $(CFLAGS) t/$@.c -o $@ $(LIBS) $(LDFLAGS)
-canlocktest: t/canlocktest.c $(STATIC_LIB)
- $(CC) $(CFLAGS) t/$@.c -o $@ $(LDFLAGS)
+canlocktest: t/canlocktest.c shared
+ $(CC) $(CFLAGS) t/$@.c -o $@ $(LIBS) $(LDFLAGS)
-$(STATIC_LIB):
- cd src && make
- ln -s src/libcanlock.a libcanlock.a
+static:
+ cd src && $(MAKE) libcanlock.a
+ ln -sf src/libcanlock.a libcanlock.a
+
+shared:
+ cd src && $(MAKE) libcanlock.so.2.0.0
clean:
rm -f src/*.o t/*.o t/*.out *.gmon gmon.*
- cd src && make clean
+ cd src && $(MAKE) clean
rm -f *.a canlocktest hmactest sha1test *.exe *.h lib-stamp
install: all
- cd src && make install DESTDIR=$(DESTDIR)
+ cd src && $(MAKE) install DESTDIR=$(DESTDIR)
install --mode=644 include/canlock.h $(DESTDIR)/usr/include
-
-test: all
+
+test: hmactest canlocktest
@echo "hmactest: "
@./hmactest > t/hmactest.out || echo hmm
@diff t/hmactest.shouldbe t/hmactest.out && echo " Pass." || (echo " **FAIL**" ; exit 1)
--- canlock2b/src/Makefile
+++ canlock2b/src/Makefile
@@ -1,9 +1,11 @@
-LIBOBJS = base64.lo canlock.lo hmac_sha1.lo sha1.lo
CC = gcc
+AR = ar
+RANLIB = ranlib
LIBTOOL = libtool
-CFLAGS = -I../include
+CFLAGS += -I../include
SOURCES = base64.c canlock.c hmac_sha1.c sha1.c
-OBJS = base64.o canlock.o hmac_sha1.o sha1.o
+OBJS := $(SOURCES:.c=.o)
+LIBOBJS := $(SOURCES:.c=.lo)
SHARELINKFLAGS = -Wl,-soname -Wl,libcanlock.so.2
SHAREDFLAGS = -fPIC -DPIC
LIBS = libcanlock.a libcanlock.so.2.0.0
@@ -11,22 +13,25 @@
all: $(LIBS)
-libcanlock.a:
- $(CC) $(CFLAGS) -c $(SOURCES)
- ar cru libcanlock.a $(OBJS)
- ranlib libcanlock.a
- rm $(OBJS)
-
-libcanlock.so.2.0.0:
- $(CC) $(CFLAGS) $(SHAREDFLAGS) -c $(SOURCES)
- $(CC) -shared $(OBJS) $(SHARELINKFLAGS) -o libcanlock.so.2.0.0
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+%.lo: %.c
+ $(CC) $(CFLAGS) $(SHAREDFLAGS) -c -o $@ $<
+
+libcanlock.a: $(OBJS)
+ $(AR) cru libcanlock.a $(OBJS)
+ $(RANLIB) libcanlock.a
+
+libcanlock.so.2.0.0: $(LIBOBJS)
+ $(CC) -shared $(LIBOBJS) $(LDFLAGS) $(SHARELINKFLAGS) -o libcanlock.so.2.0.0
install: all
$(INSTALL) libcanlock.so.2.0.0 $(DESTDIR)/usr/lib
cd $(DESTDIR)/usr/lib && ln -s libcanlock.so.2.0.0 libcanlock.so.2
cd $(DESTDIR)/usr/lib && ln -s libcanlock.so.2.0.0 libcanlock.so
$(INSTALL) libcanlock.a $(DESTDIR)/usr/lib/libcanlock.a
- ranlib $(DESTDIR)/usr/lib/libcanlock.a
-
+ $(RANLIB) $(DESTDIR)/usr/lib/libcanlock.a
+
clean:
- rm -f $(OBJS) $(LIBS)
+ rm -f $(OBJS) $(LIBOBJS) $(LIBS)
|