forked from Fraunhofer-SIT/charra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
195 lines (153 loc) · 6.61 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
################################################################################
# Copyright 2023, Fraunhofer Institute for Secure Information Technology SIT. #
# All rights reserved. #
# ---------------------------------------------------------------------------- #
# Main Makefile for CHARRA. #
# ---------------------------------------------------------------------------- #
# Author: Michael Eckel <michael.eckel@sit.fraunhofer.de> #
# Date Modified: 2023-05-22T13:37:42+02:00 #
# Date Created: 2019-06-26T09:23:15+02:00 #
################################################################################
# ------------------------------------------------------------------------------
# --- arguments + variables ----------------------------------------------------
# ------------------------------------------------------------------------------
## TCTI module
## (typically, TCTI implementations are stored at /usr/local/lib/libtss2-*.so*)
TCTI_MODULE ?= tctildr
tcti_module := tss2-$(TCTI_MODULE)
## logging
enable_logging := 1
flags_logging :=
ifeq ($(ENABLE_LOGGING),0)
enable_logging := 0
flags_logging := -DCHARRA_LOG_DISABLE
endif
## colored logging
enable_logging_color := 1
flags_logging_color :=
ifeq ($(ENABLE_LOGGING_COLOR),0)
enable_logging_color := 0
flags_logging_color := -DCHARRA_LOG_DISABLE_COLOR
endif
## AddressSanitizer (ASan)
enable_address_sanitizer := 0
flags_address_sanitizer :=
ifeq ($(ENABLE_ADDRESS_SANITIZER),)
enable_address_sanitizer := 0
flags_address_sanitizer :=
else ifneq ($(ENABLE_ADDRESS_SANITIZER),0)
enable_address_sanitizer := 1
flags_address_sanitizer := -fsanitize=address
endif
## LeakSanitizer (LSan)
enable_leak_sanitizer := 0
flags_leak_sanitizer :=
ifeq ($(ENABLE_LEAK_SANITIZER),)
enable_leak_sanitizer := 0
flags_leak_sanitizer :=
else ifneq ($(ENABLE_LEAK_SANITIZER),0)
enable_leak_sanitizer := 1
flags_leak_sanitizer := -fsanitize=leak
endif
## position-independent code (PIC)
enable_pic := 1
flags_pic := -fPIC
ifeq ($(ENABLE_PIC),0)
enable_pic := 0
flags_pic :=
endif
## strip unneeded
enable_stripping := 1
ifeq ($(ENABLE_STRIPPING),0)
enable_stripping := 0
endif
## link mode
LINK_MODE ?= dynamic
link_mode := $(if $(filter static,$(LINK_MODE)), -static)
# ------------------------------------------------------------------------------
# --- directories --------------------------------------------------------------
# ------------------------------------------------------------------------------
SRCDIR = src
INCDIR = include
OBJDIR = obj
BINDIR = bin
# ------------------------------------------------------------------------------
# --- arguments + flags --------------------------------------------------------
# ------------------------------------------------------------------------------
CFLAGS = -std=c99 -g -pedantic -Wall -Wextra -Wimplicit-fallthrough \
-Wno-missing-field-initializers -Wl,--gc-sections \
-fdata-sections -ffunction-sections \
$(flags_pic) \
$(flags_address_sanitizer) \
$(flags_leak_sanitizer) \
$(flags_logging) \
$(flags_logging_color)
LIBINCLUDE = -I/usr/include \
-I/usr/local/include
LDPATH = -L/usr/local/lib/ \
-L/usr/lib/x86_64-linux-gnu
LIBS = coap-3-tinydtls \
yaml \
qcbor m \
crypto ssl \
mbedcrypto \
util \
tss2-esys tss2-sys tss2-mu tss2-tctildr \
$(tcti_module)
LDFLAGS = $(addprefix -l, $(LIBS))
# ------------------------------------------------------------------------------
# --- sources + targets --------------------------------------------------------
# ------------------------------------------------------------------------------
SOURCES = $(shell find $(SRCDIR) -name '*.c')
INCLUDE = -I$(INCDIR)
OBJECTS = $(addsuffix .o, $(addprefix $(OBJDIR)/common/, charra_log))
OBJECTS += $(addsuffix .o, $(addprefix $(OBJDIR)/core/, charra_helper charra_key_mgr charra_rim_mgr))
OBJECTS += $(addsuffix .o, $(addprefix $(OBJDIR)/core/charra_tap/, charra_tap_cbor))
OBJECTS += $(addsuffix .o, $(addprefix $(OBJDIR)/util/, charra_util coap_util crypto_util io_util tpm2_tools_util tpm2_util parser_util))
OBJECTS += $(addsuffix .o, $(addprefix $(OBJDIR)/util/cli/, cli_util_attester cli_util_verifier cli_util_common))
TARGETS = $(addprefix $(BINDIR)/, attester verifier)
.PHONY: all attester verifier clean
all: $(TARGETS)
attester: $(BINDIR)/attester
verifier: $(BINDIR)/verifier
# ------------------------------------------------------------------------------
# --- productions --------------------------------------------------------------
# ------------------------------------------------------------------------------
## --- apps --------------------------------------------------------------------
$(BINDIR)/attester: $(SRCDIR)/attester.c $(OBJECTS)
$(CC) $^ $(CFLAGS) $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) -g -o $@ -Wl,--gc-sections $(link_mode)
ifeq ($(enable_stripping),1)
strip --strip-unneeded $@
endif
$(BINDIR)/verifier: $(SRCDIR)/verifier.c $(OBJECTS)
$(CC) $^ $(CFLAGS) $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) -g -o $@ -Wl,--gc-sections $(link_mode)
ifeq ($(enable_stripping),1)
strip --strip-unneeded $@
endif
## --- objects -----------------------------------------------------------------
$(OBJDIR)/common/%.o: $(SRCDIR)/common/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c $(link_mode)
$(OBJDIR)/core/%.o: $(SRCDIR)/core/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c $(link_mode)
$(OBJDIR)/core/charra_tap/%.o: $(SRCDIR)/core/charra_tap/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c $(link_mode)
$(OBJDIR)/util/%.o: $(SRCDIR)/util/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c $(link_mode)
$(OBJDIR)/util/%.o: $(SRCDIR)/util/cli/%.c
@mkdir -p $(@D)
$(CC) $< $(INCLUDE) $(LIBINCLUDE) $(LDPATH) $(LDFLAGS) $(CFLAGS) -g -o $@ -c $(link_mode)
# ------------------------------------------------------------------------------
# --- clean --------------------------------------------------------------------
# ------------------------------------------------------------------------------
clean:
$(RM) bin/*
$(RM) obj/common/*.*
$(RM) obj/core/*.*
$(RM) obj/core/charra_tap/*.*
$(RM) obj/util/*.*
$(RM) obj/util/cli/*.*
$(RM) obj/*.*