-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
186 lines (147 loc) · 5.79 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
# @file
# Makefile containing rules for generating keys and signing images.
#
# Set PATH_OPENSSL_DIR to OPENSSL dir on your machine.
#
INSTALL ?= install
BIN_DEST_DIR ?= /usr/bin
LIB_HASH_DRBG_NAME = hash_drbg
LIB_HASH_DRBG_PATH = lib_$(LIB_HASH_DRBG_NAME)
LIB_HASH_DRBG = $(LIB_HASH_DRBG_PATH)/lib$(LIB_HASH_DRBG_NAME).a
LIB_HASH_DRBG_INCLUDE_PATH = $(LIB_HASH_DRBG_PATH)/include
#
# Should debug output be generated from LIB?
#
# VERBOSITY=0: Print no debug output
# VERBOSITY=1: Print error messages, when the Hash_DRBG fails to operation correctly
# VERBOSITY=2: Print some informational messages during normal operation
#
LIB_VERBOSITY ?= 0
CC=gcc
LD=gcc
RM=rm -f
ifneq ($(OPENSSL_LIB_PATH),)
LDFLAGS += -L$(OPENSSL_LIB_PATH)
endif
ifneq ($(OPENSSL_INC_PATH),)
CCFLAGS += -I$(OPENSSL_INC_PATH)
endif
LIBS += -lssl -lcrypto -ldl
genkeys_OBJS = gen_keys.o
genotpmk_OBJS = gen_otpmk_drbg.o
gendrv_OBJS = gen_drv_drbg.o
gen_sign_OBJS = gen_sign.o crypto_utils.o
sign_embed_OBJS = sign_embed.o
create_hdr_isbc_SRCS = $(wildcard common/*.c) \
$(wildcard taal/*.c) \
$(wildcard tools/header_generation/*.c) \
$(wildcard tools/header_generation/create_hdr_isbc/*.c) \
$(wildcard tools/header_generation/create_hdr_isbc/taal_api/*.c)
create_hdr_isbc_OBJS = $(basename $(create_hdr_isbc_SRCS))
create_hdr_isbc_OBJS := $(notdir $(create_hdr_isbc_OBJS))
create_hdr_isbc_OBJS := $(create_hdr_isbc_OBJS:%=%.o)
create_hdr_esbc_SRCS = $(wildcard common/*.c) \
$(wildcard taal/*.c) \
$(wildcard tools/header_generation/*.c) \
$(wildcard tools/header_generation/create_hdr_esbc/*.c) \
$(wildcard tools/header_generation/create_hdr_esbc/taal_api/*.c)
create_hdr_esbc_OBJS = $(basename $(create_hdr_esbc_SRCS))
create_hdr_esbc_OBJS := $(notdir $(create_hdr_esbc_OBJS))
create_hdr_esbc_OBJS := $(create_hdr_esbc_OBJS:%=%.o)
create_hdr_pbi_SRCS = $(wildcard common/*.c) \
$(wildcard taal/*.c) \
$(wildcard tools/header_generation/*.c) \
$(wildcard tools/header_generation/create_hdr_pbi/*.c) \
$(wildcard tools/pbi_creation/*.c) \
$(wildcard tools/header_generation/create_hdr_pbi/taal_api/*.c)
create_hdr_pbi_OBJS = $(basename $(create_hdr_pbi_SRCS))
create_hdr_pbi_OBJS := $(notdir $(create_hdr_pbi_OBJS))
create_hdr_pbi_OBJS := $(create_hdr_pbi_OBJS:%=%.o)
create_hdr_cf_SRCS = $(wildcard common/*.c) \
$(wildcard taal/*.c) \
$(wildcard tools/header_generation/*.c) \
$(wildcard tools/header_generation/create_hdr_cf/*.c) \
$(wildcard tools/header_generation/create_hdr_cf/taal_api/*.c)
create_hdr_cf_OBJS = $(basename $(create_hdr_cf_SRCS))
create_hdr_cf_OBJS := $(notdir $(create_hdr_cf_OBJS))
create_hdr_cf_OBJS := $(create_hdr_cf_OBJS:%=%.o)
gen_fusescr_SRCS = $(wildcard common/*.c) \
$(wildcard taal/*.c) \
$(wildcard tools/fuse_provisioning/*.c)
gen_fusescr_OBJS = $(basename $(gen_fusescr_SRCS))
gen_fusescr_OBJS := $(notdir $(gen_fusescr_OBJS))
gen_fusescr_OBJS := $(gen_fusescr_OBJS:%=%.o)
vpath %.c common/ taal/ tools/header_generation/ \
tools/header_generation/create_hdr_isbc/ tools/header_generation/create_hdr_isbc/taal_api/ \
tools/header_generation/create_hdr_esbc/ tools/header_generation/create_hdr_esbc/taal_api/ \
tools/header_generation/create_hdr_pbi/ tools/header_generation/create_hdr_pbi/taal_api/ \
tools/header_generation/create_hdr_cf/ tools/header_generation/create_hdr_cf/taal_api/ \
tools/key_generation/ \
tools/pbi_creation/ \
tools/signature_generation/ \
tools/fuse_provisioning \
INCLUDES = -Itools/header_generation/create_hdr_isbc/include/ \
-Itools/header_generation/create_hdr_esbc/include/ \
-Itools/header_generation/create_hdr_pbi/include/ \
-Itools/header_generation/create_hdr_cf/include/ \
-Itools/fuse_provisioning/include/ \
-Itaal/include -Icommon/include \
-I$(LIB_HASH_DRBG_INCLUDE_PATH)
CCFLAGS= -g -Wall -Wno-strict-aliasing -Werror $(INCLUDES)
INSTALL_BINARIES = create_hdr_isbc create_hdr_esbc \
create_hdr_pbi create_hdr_cf \
gen_keys gen_otpmk_drbg gen_drv_drbg \
gen_sign sign_embed gen_fusescr \
# targets that are not files
.PHONY: all clean
# make targets
all: $(LIB_HASH_DRBG) ${INSTALL_BINARIES}
cp -rf scripts/* ./
@echo
@echo "#########################################"
@echo "# Tools Compiled:"
@echo "# ${INSTALL_BINARIES}"
@echo "#########################################"
@echo
create_hdr_isbc: ${create_hdr_isbc_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
create_hdr_esbc: ${create_hdr_esbc_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
create_hdr_pbi: ${create_hdr_pbi_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
create_hdr_cf: ${create_hdr_cf_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
gen_sign: ${gen_sign_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
sign_embed: ${sign_embed_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
gen_keys: ${genkeys_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
gen_otpmk_drbg: ${genotpmk_OBJS} $(LIB_HASH_DRBG)
${LD} ${LDFLAGS} -o $@ $^
gen_drv_drbg: ${gendrv_OBJS} $(LIB_HASH_DRBG)
${LD} ${LDFLAGS} -o $@ $^
gen_fusescr: ${gen_fusescr_OBJS}
${LD} ${LDFLAGS} -o $@ $^ ${LIBS}
$(LIB_HASH_DRBG):
@echo "#########################################"
@echo "### Building Shared Library hash_drbg ###"
@echo "#########################################"
make LIB_HASH_DRBG_PATH=$(LIB_HASH_DRBG_PATH) \
VERBOSITY=-DVERBOSITY=$(LIB_VERBOSITY) \
-f $(LIB_HASH_DRBG_PATH)/src/Makefile
@echo "#########################################"
@echo "### Build Complete for hash_drbg ###"
@echo "#########################################"
%.o: %.c
${CC} -c ${CCFLAGS} ${CFLAGS} $<
install: $(foreach binary,$(INSTALL_BINARIES),install-$(binary))
cp -rf input_files $(DESTDIR)$(BIN_DEST_DIR)/cst/
cp -rf scripts/* $(DESTDIR)$(BIN_DEST_DIR)/cst/
install-%: %
$(INSTALL) -d $(DESTDIR)$(BIN_DEST_DIR)/cst
$(INSTALL) -m 755 $< $(DESTDIR)$(BIN_DEST_DIR)/cst/
clean:
${RM} *.o ${INSTALL_BINARIES}
distclean: clean
${RM} *.pub *.pri $(LIB_HASH_DRBG)