forked from yuichitk/libcsuit
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
108 lines (86 loc) · 2.54 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
#
# Copyright (c) 2020-2023 SECOM CO., LTD. All Rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause
#
NAME = libcsuit
CFLAGS ?= -Os
WARNING_CFLAGS ?= -Wall -Wextra -Wformat=2 -Wno-format-nonliteral
LOCAL_CFLAGS = $(WARNING_CFLAGS) -fPIC -I /usr/local/include -I ./inc
LOCAL_CFLAGS += -ffunction-sections -fdata-sections
# link me with -Wl,--gc-sections
ifeq ($(MBEDTLS),1)
# use MbedTLS
LOCAL_CFLAGS += -DLIBCSUIT_PSA_CRYPTO_C=1
else
# use OpenSSL
MBEDTLS=0
endif
SRCS = \
src/suit_common.c \
src/suit_manifest_process.c \
src/suit_manifest_callbacks.c \
src/suit_manifest_decode.c \
src/suit_manifest_encode.c \
src/suit_manifest_print.c \
src/suit_cose.c \
src/suit_digest.c
PUBLIC_INTERFACE = \
inc/csuit/config.h \
inc/csuit/csuit.h \
inc/csuit/suit_common.h \
inc/csuit/suit_cose.h \
inc/csuit/suit_digest.h \
inc/csuit/suit_manifest_decode.h \
inc/csuit/suit_manifest_encode.h \
inc/csuit/suit_manifest_process.h \
inc/csuit/suit_manifest_callbacks.h \
inc/csuit/suit_manifest_print.h
OBJS = $(addprefix ./obj/,$(patsubst %.c,%.o,$(SRCS)))
.PHONY: all
all: ./bin/$(NAME).a
include Makefile.common
.PHONY: so
so: ./bin/$(NAME).so
.PHONY: doc
doc:
doxygen Doxyfile
./bin/$(NAME).a: $(OBJS) | ./bin
$(AR) -r $@ $^
./bin/$(NAME).so: $(OBJS) | ./bin
$(CC) -shared $^ $(LOCAL_CFLAGS) $(CFLAGS) -o $@
./obj/%.o: %.c | ./obj/src
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) -o $@ -c $<
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
define install-header
install -m 644 $1 $2/$(nodir $1)
endef
.PHONY: instal
install: all $(PUBLIC_INTERFACE)
install -d $(DESTDIR)$(PREFIX)/lib/
install -m 644 ./bin/$(NAME).a $(DESTDIR)$(PREFIX)/lib/
install -d $(DESTDIR)$(PREFIX)/include/csuit
$(foreach header,$(PUBLIC_INTERFACE),$(call install-header,$(header),$(DESTDIR)$(PREFIX)/include/csuit))
.PHONY: install_so
install_so: ./bin/$(NAME).so
install -m 755 ./bin/$(NAME).so $(DESTDIR)$(PREFIX)/lib/$(NAME).so.1.0.0
ln -sf ./bin/$(NAME).so.1 $(DESTDIR)$(PREFIX)/lib/$(NAME).so
ln -sf ./bin/$(NAME).so.1.0.0 $(DESTDIR)$(PREFIX)/lib$(NAME).so.1
.PHONY: uninstall
uninstall:
$(RM) -d $(DESTDIR)$(PREFIX)/include/csuit/*
$(RM) -d $(DESTDIR)$(PREFIX)/include/csuit/
$(RM) $(addprefix $(DESTDIR)$(PREFIX)/lib/, \
$(NAME).a $(NAME).so $(NAME).so.1 $(NAME).so.1.0.0)
.PHONY: build_test
build_test: ./bin/$(NAME).a
$(MAKE) -C test MBEDTLS=$(MBEDTLS) CMD_INC="$(CMD_INC)" CMD_LD="$(CMD_LD)"
.PHONY: test
test: build_test
$(MAKE) -C test MBEDTLS=$(MBEDTLS) run
.PHONY: clean
clean:
$(MAKE) -C test clean
$(RM) $(OBJS) ./bin/$(NAME).a ./bin/$(NAME).so