forked from yuichitk/libteep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
94 lines (72 loc) · 2.04 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
#
# Copyright (c) 2020 SECOM CO., LTD. All Rights reserved.
#
# SPDX-License-Identifier: BSD-2-Clause
#
NAME = libteep
CFLAGS = -Wall -g -fPIC
INC = $(CMD_INC) -I ./inc
SRCS = \
src/teep_common.c \
src/teep_cose.c \
src/teep_message_decode.c \
src/teep_message_encode.c \
src/teep_message_print.c
PUBLIC_INTERFACE = \
inc/teep/teep.h \
inc/teep/teep_common.h \
inc/teep/teep_message_data.h \
inc/teep/teep_cose.h \
inc/teep/teep_message_print.h
OBJDIR = ./obj
OBJS = $(addprefix $(OBJDIR)/,$(patsubst %.c,%.o,$(SRCS)))
ifeq ($(MBEDTLS),1)
# use MbedTLS
CFLAGS += -DLIBTEEP_PSA_CRYPTO_C=1
else
# use OpenSSL
MBEDTLS=0
endif
ifdef suit
CFLAGS += -DPARSE_SUIT
INC += -I ../libcsuit/inc -I ../libcsuit/examples/inc
endif
.PHONY: all so install uninstall build_test test clean
all: $(NAME).a
so: $(NAME).so
include Makefile.common
$(NAME).a: $(OBJS)
$(AR) -r $@ $^
$(NAME).so: $(OBJS)
$(CC) -shared $^ $(CFLAGS) $(INC) -o $@
$(OBJDIR)/%.o: %.c | $(OBJDIR) $(OBJDIR)/src
$(CC) $(CFLAGS) $(INC) -o $@ -c $<
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
define install-header
install -m 644 $1 $2/$(nodir $1)
endef
install: $(NAME).a $(PUBLIC_INTERFACE)
install -d $(DESTDIR)$(PREFIX)/lib/
install -m 644 $(NAME).a $(DESTDIR)$(PREFIX)/lib/
install -d $(DESTDIR)$(PREFIX)/include/teep
$(foreach header,$(PUBLIC_INTERFACE),$(call install-header,$(header),$(DESTDIR)$(PREFIX)/include/teep))
install_so: $(NAME).so
install -m 755 $(NAME).so $(DESTDIR)$(PREFIX)/lib/$(NAME).so.1.0.0
ln -sf $(NAME).so.1 $(DESTDIR)$(PREFIX)/lib/$(NAME).so
ln -sf $(NAME).so.1.0.0 $(DESTDIR)$(PREFIX)/lib/$(NAME).so.1
uninstall: $(NAME).a $(PUBLIC_INTERFACE)
$(RM) -d $(DESTDIR)$(PREFIX)/include/teep/*
$(RM) -d $(DESTDIR)$(PREFIX)/include/teep/
$(RM) $(addprefix $(DESTDIR)$(PREFIX)/lib/, \
$(NAME).a $(NAME).so $(NAME).so.1 $(NAME).so.1.0.0)
build_test:
$(MAKE) -C test MBEDTLS=$(MBEDTLS)
test: build_test
$(MAKE) -C test MBEDTLS=$(MBEDTLS) run
generate:
$(MAKE) -C testfiles
clean:
$(RM) $(OBJS) $(NAME).a $(NAME).so
$(MAKE) -C test clean