-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
48 lines (34 loc) · 991 Bytes
/
Makefile
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
TARGET_TEST ?= test
TARGET_EXEC ?= base45
TARGET_LIB ?= libbase45.a
SRC_DIRS ?= .
SRCS := base45.c
OBJS := $(SRCS:.c=.o)
DEPS := $(OBJS:.o=.d)
OBJS_TEST := test.o
INC_DIRS :=
INC_FLAGS :=
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
tests: all $(TARGET_TEST)
./test
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 17 19 41 42 43 103 1002 10009 100007 1000001 0; do \
openssl rand $$i > $$TMPDIR/x; \
cat $$TMPDIR/x | ./base45 | ./base45 -d > $$TMPDIR/y; \
diff $$TMPDIR/x $$TMPDIR/y || exit 1; \
done; \
rm $$TMPDIR/x $$TMPDIR/y
all: $(TARGET_EXEC) $(TARGET_LIB)
$(TARGET_EXEC): $(SRCS)
$(CC) $(SRCS) -DBASE45_UTIL -o $@ $(LDFLAGS)
$(TARGET_TEST): $(OBJS_TEST) $(TARGET_LIB)
$(CC) $(OBJS_TEST) -o $@ $(LDFLAGS) -lbase45 -L.
$(TARGET_LIB): $(OBJS)
ar -rcs $@ $<
# c source
%.c.o: %.c base64.h
$(MKDIR_P) $(dir $@)
$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
.PHONY: clean
clean:
$(RM) -f $(OBJS) $ $(OBJS_TEST) $(TARGET_EXEC) $(DEPS) $(TARGET_LIB)
-include $(DEPS)