forked from Fraunhofer-SIT/charra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (66 loc) · 2.56 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
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
# main Makefile
CFLAGS = -std=c99 -g -pedantic -Wall -Wextra \
-fdata-sections -ffunction-sections \
-DCHARRA_LOG_USE_COLOR
SRCDIR = src
INCDIR = include
OBJDIR = obj
BINDIR = bin
LIBINCLUDE = -I/usr/include \
-I/usr/local/include
LDPATH = -L/usr/local/lib/ \
-L/usr/lib/x86_64-linux-gnu
LIBS = coap-2 \
qcbor \
crypto ssl \
util tss2-esys tss2-sys tss2-mu tss2-tcti-mssim
# tss2-tcti-device
LDFLAGS_DYNAMIC = $(addprefix -l, $(LIBS))
LDFLAGS_STATIC = $(addprefix -l:lib, $(addsuffix .a, $(LIBS)))
SOURCES = $(shell find $(SRCDIR) -name '*.c')
INCLUDE = -I$(INCDIR)
OBJECTS = $(addsuffix .o, $(addprefix $(OBJDIR)/common/, charra_log))
OBJECTS += $(addsuffix .o, $(addprefix $(OBJDIR)/core/, charra_dto charra_helper charra_key_mgr charra_marshaling))
OBJECTS += $(addsuffix .o, $(addprefix $(OBJDIR)/util/, cbor_util charra_util coap_util tpm2_util))
TARGETS = $(addprefix $(BINDIR)/, attester verifier)
.PHONY: all all.static libs clean cleanlibs cleanall
## --- targets ------------------------------------------------------------ ##
all: LDFLAGS = $(LDFLAGS_DYNAMIC)
all: $(TARGETS)
all.static: LDFLAGS = $(LDFLAGS_STATIC)
all.static: $(TARGETS)
$(BINDIR)/attester: $(SRCDIR)/attester.c $(OBJECTS)
$(CC) $^ $(CFLAGS) $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) -g -o $@ -Wl,--gc-sections
###strip --strip-unneeded $@
$(BINDIR)/verifier: $(SRCDIR)/verifier.c $(OBJECTS)
$(CC) $^ $(CFLAGS) $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) -g -o $@ -Wl,--gc-sections
###strip --strip-unneeded $@
## --- objects ------------------------------------------------------------ ##
$(OBJDIR)/common/%.o: $(SRCDIR)/common/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c
$(OBJDIR)/core/%.o: $(SRCDIR)/core/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c
$(OBJDIR)/util/%.o: $(SRCDIR)/util/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c
## --- libraries ---------------------------------------------------------- ##
libs:
$(MAKE) -C lib/
libs.static:
$(MAKE) -C lib/ all.static
libs.install:
$(MAKE) -C lib/ install
libs.uninstall:
$(MAKE) -C lib/ uninstall
## --- clean -------------------------------------------------------------- ##
clean:
$(RM) bin/*
$(RM) obj/common/*.*
$(RM) obj/core/*.*
$(RM) obj/util/*.*
$(RM) obj/*.*
cleanlibs: clean
$(MAKE) -C lib/ clean
cleanall: cleanlibs clean