forked from paullouisageneau/libjuice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (56 loc) · 1.35 KB
/
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
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
# libjuice
NAME=libjuice
CC=$(CROSS)gcc
AR=$(CROSS)ar
RM=rm -f
CFLAGS=-O2 -pthread -fPIC -Wno-address-of-packed-member
LDFLAGS=-pthread
LIBS=
INCLUDES=-Iinclude/juice
LDLIBS=
USE_NETTLE ?= 0
ifneq ($(USE_NETTLE), 0)
CFLAGS+=-DUSE_NETTLE=1
LIBS+=nettle
else
CFLAGS+=-DUSE_NETTLE=0
endif
NO_SERVER ?= 0
ifneq ($(NO_SERVER), 0)
CFLAGS+=-DNO_SERVER
endif
NO_ATOMICS ?= 0
ifneq ($(NO_ATOMICS), 0)
CFLAGS+=-DNO_ATOMICS
endif
ifneq ($(LIBS), "")
INCLUDES+=$(if $(LIBS),$(shell pkg-config --cflags $(LIBS)),)
LDLIBS+=$(if $(LIBS), $(shell pkg-config --libs $(LIBS)),)
endif
SRCS=$(shell printf "%s " src/*.c)
OBJS=$(subst .c,.o,$(SRCS))
TEST_SRCS=$(shell printf "%s " test/*.c)
TEST_OBJS=$(subst .c,.o,$(TEST_SRCS))
all: $(NAME).a $(NAME).so tests
src/%.o: src/%.c
$(CC) $(CFLAGS) $(INCLUDES) -MMD -MP -o $@ -c $<
test/%.o: test/%.c
$(CC) $(CFLAGS) $(INCLUDES) -Iinclude -Isrc -MMD -MP -o $@ -c $<
-include $(subst .c,.d,$(SRCS))
$(NAME).a: $(OBJS)
$(AR) crf $@ $(OBJS)
$(NAME).so: $(OBJS)
$(CC) $(LDFLAGS) -shared -o $@ $(OBJS) $(LDLIBS)
tests: $(NAME).a $(TEST_OBJS)
$(CC) $(LDFLAGS) -o $@ $(TEST_OBJS) $(LDLIBS) $(NAME).a
clean:
-$(RM) include/juice/*.d *.d
-$(RM) src/*.o src/*.d
-$(RM) test/*.o test/*.d
dist-clean: clean
-$(RM) $(NAME).a
-$(RM) $(NAME).so
-$(RM) tests
-$(RM) include/*~
-$(RM) src/*~
-$(RM) test/*~