huangcm
2025-08-25 f350412dc55c15118d0a7925d1071877498e5e24
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
196
197
198
199
200
201
202
203
204
205
206
207
#!/usr/bin/make -f
 
#variables are set by configure
prefix = @prefix@
installdir = $(prefix)/
epidinstalldir = $(installdir)/epid-sdk
CC = @CC@
CXX = @CXX@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
RANLIB = @RANLIB@
TSS_PATH = @TSS_PATH@
TINY = @TINY@
 
#set performance affecting flags
SIZE_CFLAGS := -O2
 
#gcc flags
CC_FLAGS := $(CFLAGS) $(SIZE_CFLAGS) -Werror -Wall -Wextra -Wno-missing-braces \
   -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-unused-function \
   -fno-strict-aliasing -Wno-unused-but-set-variable -Wno-comment -Wformat \
   -Wformat-security -fstack-protector -DNDEBUG -D_FORTIFY_SOURCE=2
 
#intel c compiler flags
ICC_FLAGS := $(CFLAGS) $(SIZE_CFLAGS) -Werror -Wall -Wextra -DNDEBUG \
   -fstack-protector -D_FORTIFY_SOURCE=2 \
   -Wformat -Wformat-security
 
ifneq ($(OS),Windows_NT)
   CC_FLAGS += -fPIC
   ICC_FLAGS += -fPIC
   CXX11_FLAG = -std=c++0x
   EXE_EXTENSION =
else
   CC_FLAGS += -D__int64='long long'
   CXX11_FLAG = -std=gnu++11
   EXE_EXTENSION = .exe
endif
 
#g++ flags
CXX_FLAGS := $(CC_FLAGS) $(CXX11_FLAG)
 
#intel c++ compiler flags
ICPC_FLAGS := $(ICC_FLAGS) $(CXX11_FLAG)
 
#check if architecture was specified
#or take it by shell command
ifeq ($(findstring -m32,$(CFLAGS)),-m32)
   ARCH = x86
   CXXFLAGS += -m32
   LDFLAGS += -m32
else ifeq ($(findstring -m64,$(CFLAGS)),-m64)
   ARCH = x86_64
   CXXFLAGS += -m64
   LDFLAGS += -m64
else
   ifeq ($(findstring arm-,$(CC)),arm-)
       ARCH = arm
 
       ifneq (,$(findstring gnueabihf,$(CC)))
           ARCH := $(addsuffix hf,$(ARCH))
       endif
 
   else
       ARCH := $(shell uname -m)
   endif
endif
 
#set ippflags
IPP_FLAGS := -D_IPP_v50_ -D_IPP_DEBUG -D_DISABLE_ALG_MD5_ -D_DISABLE_ALG_SM3_
 
#set tools and flags depending on specified compiler
ifeq ($(findstring icc,$(CC)),icc)
   CFLAGS := $(ICC_FLAGS)
   CXXFLAGS := $(ICPC_FLAGS)
   AR = $(subst icc,xiar,$(CC))
else
   CFLAGS := $(CC_FLAGS)
   CXXFLAGS := $(CXX_FLAGS)
endif
 
# ld flags
LDFLAGS += -fstack-protector
ifneq ($(OS),Windows_NT)
  LDFLAGS += -z noexecstack -z relro -z now -pie
endif
 
#gtest defines
GTEST_DEFINES := -DGTEST_HAS_PTHREAD=0 -D_VARIADIC_MAX=10
 
#set flags for unit tests executables
GTEST_FLAGS = --gtest_color=yes \
   --gtest_print_time=1 \
   --gtest_output=xml
 
export CC LDFLAGS ARCH CFLAGS
export CXX CXXFLAGS
export AR RANLIB
export epidinstalldir
export GTEST_FLAGS GTEST_DEFINES IPP_FLAGS
export EXE_EXTENSION
export TSS_PATH
export TINY
 
#output of the main parameters
$(info $$ccompiler is [${CC}])
$(info $$cxxcompiler is [${CXX}])
$(info $$architecture is [${ARCH}])
#targets part
all:
   $(MAKE) ipp common member verifier argtable3 examples_util
   $(MAKE) examples epid_tools
 
clean:
   $(MAKE) -C ./ext/ipp/sources/ippcp clean
   $(MAKE) -C ./epid/common/ clean
   $(MAKE) -C ./epid/member/ clean
   $(MAKE) -C ./epid/verifier/ clean
   $(MAKE) -C ./example/util/ clean
   $(MAKE) -C ./example/ clean
   $(MAKE) -C ./tools/ clean
   $(MAKE) -C ./ext/gtest/ clean
   $(MAKE) -C ./epid/common-testhelper/ clean
   $(MAKE) -C ./ext/argtable3/ clean
ifneq ("$(wildcard ./ext/google_benchmark)","")
   $(MAKE) -C ./ext/google_benchmark/ clean
endif
 
install:
   $(MAKE) -C ./ext/ipp/sources/ippcp install
   $(MAKE) -C ./epid/common/ install
   $(MAKE) -C ./epid/member/ install
   $(MAKE) -C ./epid/verifier/ install
   $(MAKE) -C ./example/ install
   $(MAKE) -C ./tools/ install
   $(MAKE) -C ./epid/common-testhelper/ install
 
uninstall:
   rm -rf  $(epidinstalldir)
 
ipp:
   $(MAKE) -C ./ext/ipp/sources/ippcp all
 
common-testhelper:
   $(MAKE) -C ./epid/common-testhelper/ all
 
common-testhelper_utest:
   $(MAKE) -C ./epid/common-testhelper/ utest
 
common:
   $(MAKE) -C ./epid/common/ all
 
common_utest:
   $(MAKE) -C ./epid/common/ utest
 
member:
   $(MAKE) -C ./epid/member/ all
 
member_utest:
   $(MAKE) -C ./epid/member/ utest
 
verifier:
   $(MAKE) -C ./epid/verifier/ all
 
verifier_utest:
   $(MAKE) -C ./epid/verifier/ utest
 
gtest:
   $(MAKE) -C ./ext/gtest/ all
 
argtable3:
   $(MAKE) -C ./ext/argtable3/ all
 
examples_util:
   $(MAKE) -C ./example/util/ all
 
utest:
   $(MAKE) gtest common-testhelper
   $(MAKE) common-testhelper_utest common_utest member_utest verifier_utest
 
run_utest:
   $(MAKE) -C ./epid/common-testhelper/ run_utest
   $(MAKE) -C ./epid/common/ run_utest
   $(MAKE) -C ./epid/member/ run_utest
   $(MAKE) -C ./epid/verifier/ run_utest
 
check:
   $(MAKE) utest
   $(MAKE) run_utest
 
examples:
   $(MAKE) -C ./example/ all
 
epid_tools:
   $(MAKE) -C ./tools/ all
 
perf:
ifneq ("$(wildcard ./ext/google_benchmark/)","")
   $(MAKE) -C ./ext/google_benchmark/ all
   $(MAKE) -C ./ext/google_benchmark/ utest
   $(MAKE) -C ./ext/google_benchmark/ run_utest
endif
 
build:
   $(MAKE) all
   $(MAKE) check
   $(MAKE) install