2021-01-18 09:57:33 +01:00
|
|
|
############################################################################
|
|
|
|
# apps/crypto/mbedtls/Makefile
|
|
|
|
#
|
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership. The
|
|
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance with the
|
|
|
|
# License. You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
|
|
|
# under the License.
|
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
include $(APPDIR)/Make.defs
|
|
|
|
|
|
|
|
# Mbed TLS crypto library
|
|
|
|
|
|
|
|
# Set up build configuration and environment
|
|
|
|
|
|
|
|
MBEDTLS_URL ?= "https://github.com/ARMmbed/mbedtls/archive"
|
|
|
|
|
|
|
|
MBEDTLS_VERSION = $(patsubst "%",%,$(strip $(CONFIG_MBEDTLS_VERSION)))
|
|
|
|
MBEDTLS_ZIP = v$(MBEDTLS_VERSION).zip
|
|
|
|
|
|
|
|
MBEDTLS_UNPACKNAME = mbedtls
|
|
|
|
UNPACK ?= unzip -q -o
|
|
|
|
|
|
|
|
MBEDTLS_UNPACKLIBDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)library
|
|
|
|
MBEDTLS_UNPACKPROGDIR = $(MBEDTLS_UNPACKNAME)$(DELIM)programs
|
|
|
|
|
|
|
|
# This lets Mbed TLS better use some of the POSIX features we have
|
2022-11-09 16:00:20 +01:00
|
|
|
CFLAGS += ${DEFINE_PREFIX}__unix__
|
2021-01-18 09:57:33 +01:00
|
|
|
|
2023-02-22 10:28:35 +01:00
|
|
|
library/bignum.c_CFLAGS += -fno-lto
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_ARCH_SIM),y)
|
|
|
|
CFLAGS += -O0
|
|
|
|
endif
|
|
|
|
|
2021-01-18 09:57:33 +01:00
|
|
|
CSRCS = $(wildcard $(MBEDTLS_UNPACKLIBDIR)$(DELIM)*.c)
|
|
|
|
|
|
|
|
$(MBEDTLS_ZIP):
|
|
|
|
@echo "Downloading: $(MBEDTLS_URL)/$(MBEDTLS_ZIP)"
|
|
|
|
$(Q) curl -O -L $(MBEDTLS_URL)/$(MBEDTLS_ZIP)
|
|
|
|
|
|
|
|
$(MBEDTLS_UNPACKNAME): $(MBEDTLS_ZIP)
|
|
|
|
@echo "Unpacking: $(MBEDTLS_ZIP) -> $(MBEDTLS_UNPACKNAME)"
|
|
|
|
$(Q) $(UNPACK) $(MBEDTLS_ZIP)
|
|
|
|
$(Q) mv mbedtls-$(MBEDTLS_VERSION) $(MBEDTLS_UNPACKNAME)
|
|
|
|
$(Q) touch $(MBEDTLS_UNPACKNAME)
|
|
|
|
|
2022-08-27 08:15:16 +02:00
|
|
|
# Download and unpack tarball if no git repo found
|
|
|
|
ifeq ($(wildcard $(MBEDTLS_UNPACKNAME)/.git),)
|
2021-01-18 09:57:33 +01:00
|
|
|
context:: $(MBEDTLS_UNPACKNAME)
|
|
|
|
|
|
|
|
distclean::
|
|
|
|
$(call DELDIR, $(MBEDTLS_UNPACKNAME))
|
|
|
|
$(call DELFILE, $(MBEDTLS_ZIP))
|
2022-08-27 08:15:16 +02:00
|
|
|
endif
|
2021-01-18 09:57:33 +01:00
|
|
|
|
|
|
|
# Configuration Applications
|
|
|
|
|
|
|
|
ifneq ($(CONFIG_MBEDTLS_APPS),)
|
|
|
|
|
|
|
|
MODULE = $(CONFIG_MBEDTLS_APPS)
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_MBEDTLS_APP_BENCHMARK),y)
|
|
|
|
|
|
|
|
PROGNAME += $(CONFIG_MBEDTLS_APP_BENCHMARK_PROGNAME)
|
|
|
|
PRIORITY += $(CONFIG_MBEDTLS_APP_BENCHMARK_PRIORITY)
|
|
|
|
STACKSIZE += $(CONFIG_MBEDTLS_APP_BENCHMARK_STACKSIZE)
|
|
|
|
|
|
|
|
MAINSRC += $(MBEDTLS_UNPACKPROGDIR)/test/benchmark.c
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_MBEDTLS_APP_SELFTEST),y)
|
|
|
|
|
|
|
|
PROGNAME += $(CONFIG_MBEDTLS_APP_SELFTEST_PROGNAME)
|
|
|
|
PRIORITY += $(CONFIG_MBEDTLS_APP_SELFTEST_PRIORITY)
|
|
|
|
STACKSIZE += $(CONFIG_MBEDTLS_APP_SELFTEST_STACKSIZE)
|
|
|
|
|
|
|
|
MAINSRC += $(MBEDTLS_UNPACKPROGDIR)/test/selftest.c
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
2023-07-18 15:44:38 +02:00
|
|
|
# Configuration alternative implementation
|
|
|
|
|
2023-08-04 14:47:16 +02:00
|
|
|
ifeq ($(CONFIG_MBEDTLS_ENTROPY_HARDWARE_ALT),y)
|
|
|
|
CSRCS += $(APPDIR)/crypto/mbedtls/source/entropy_alt.c
|
|
|
|
endif
|
|
|
|
|
2023-07-18 15:44:38 +02:00
|
|
|
ifeq ($(CONFIG_MBEDTLS_ALT),y)
|
|
|
|
|
|
|
|
CSRCS += $(APPDIR)/crypto/mbedtls/source/dev_alt.c
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_MBEDTLS_SHA1_ALT),y)
|
|
|
|
CSRCS += $(APPDIR)/crypto/mbedtls/source/sha1_alt.c
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
2021-01-18 09:57:33 +01:00
|
|
|
include $(APPDIR)/Application.mk
|