2019-11-10 22:06:17 +08:00
|
|
|
############################################################################
|
|
|
|
# openamp/libmetal.defs
|
|
|
|
#
|
2024-09-10 19:14:02 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
2020-08-23 00:36:57 +08:00
|
|
|
# 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
|
2019-11-10 22:06:17 +08:00
|
|
|
#
|
2020-08-23 00:36:57 +08:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2019-11-10 22:06:17 +08:00
|
|
|
#
|
2020-08-23 00:36:57 +08:00
|
|
|
# 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.
|
2019-11-10 22:06:17 +08:00
|
|
|
#
|
|
|
|
############################################################################
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_OPENAMP),y)
|
|
|
|
|
|
|
|
ifeq ($(CONFIG_ARCH), sim)
|
2022-10-11 11:18:27 +08:00
|
|
|
ifeq ($(CONFIG_HOST_ARM64), y)
|
|
|
|
LIBMETAL_ARCH = aarch64
|
|
|
|
else ifeq ($(CONFIG_HOST_ARM), y)
|
|
|
|
LIBMETAL_ARCH = arm
|
|
|
|
else ifeq ($(CONFIG_HOST_X86), y)
|
|
|
|
LIBMETAL_ARCH = x86
|
|
|
|
else
|
2019-11-10 22:06:17 +08:00
|
|
|
LIBMETAL_ARCH = x86_64
|
2022-10-11 11:18:27 +08:00
|
|
|
endif
|
2020-04-21 20:37:06 +08:00
|
|
|
else ifeq ($(CONFIG_ARCH), risc-v)
|
|
|
|
LIBMETAL_ARCH = riscv
|
2023-03-21 11:10:40 +08:00
|
|
|
else ifeq ($(CONFIG_ARCH), arm64)
|
|
|
|
LIBMETAL_ARCH = aarch64
|
2020-05-08 17:16:20 +08:00
|
|
|
else
|
|
|
|
LIBMETAL_ARCH = $(CONFIG_ARCH)
|
2019-11-10 22:06:17 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
CSRCS += libmetal/lib/system/nuttx/condition.c
|
|
|
|
CSRCS += libmetal/lib/system/nuttx/device.c
|
|
|
|
CSRCS += libmetal/lib/system/nuttx/init.c
|
|
|
|
CSRCS += libmetal/lib/system/nuttx/io.c
|
|
|
|
CSRCS += libmetal/lib/system/nuttx/irq.c
|
|
|
|
CSRCS += libmetal/lib/system/nuttx/shmem.c
|
|
|
|
CSRCS += libmetal/lib/system/nuttx/time.c
|
|
|
|
CSRCS += libmetal/lib/device.c
|
|
|
|
CSRCS += libmetal/lib/dma.c
|
|
|
|
CSRCS += libmetal/lib/init.c
|
|
|
|
CSRCS += libmetal/lib/io.c
|
|
|
|
CSRCS += libmetal/lib/irq.c
|
|
|
|
CSRCS += libmetal/lib/log.c
|
|
|
|
CSRCS += libmetal/lib/shmem.c
|
|
|
|
CSRCS += libmetal/lib/version.c
|
|
|
|
|
2024-08-09 20:29:45 +08:00
|
|
|
ifeq ($(CONFIG_OPENAMP_CACHE),y)
|
|
|
|
CFLAGS += -DMETAL_CACHE
|
|
|
|
endif
|
|
|
|
|
2019-11-10 22:06:17 +08:00
|
|
|
CFLAGS += -DMETAL_INTERNAL
|
|
|
|
|
|
|
|
LIBMETAL_HDRS_SEDEXP := \
|
2020-11-12 17:56:25 +08:00
|
|
|
"s/@PROJECT_VERSION_MAJOR@/0/g; \
|
|
|
|
s/@PROJECT_VERSION_MINOR@/1/g; \
|
|
|
|
s/@PROJECT_VERSION_PATCH@/0/g; \
|
|
|
|
s/@PROJECT_VERSION@/0.1.0/g; \
|
2019-11-10 22:06:17 +08:00
|
|
|
s/@PROJECT_SYSTEM@/nuttx/g; \
|
|
|
|
s/@PROJECT_PROCESSOR@/$(LIBMETAL_ARCH)/g; \
|
|
|
|
s/@PROJECT_MACHINE@/$(CONFIG_ARCH_CHIP)/g; \
|
|
|
|
s/@PROJECT_SYSTEM_UPPER@/nuttx/g; \
|
|
|
|
s/@PROJECT_PROCESSOR_UPPER@/$(LIBMETAL_ARCH)/g; \
|
|
|
|
s/@PROJECT_MACHINE_UPPER@/$(CONFIG_ARCH_CHIP)/g; \
|
2024-08-06 16:00:56 +08:00
|
|
|
s/cmakedefine HAVE_STDATOMIC_H/define HAVE_STDATOMIC_H/g; \
|
2019-11-10 22:06:17 +08:00
|
|
|
s/cmakedefine/undef/g"
|
|
|
|
|
2022-12-08 11:17:47 +08:00
|
|
|
ifeq ($(wildcard libmetal/.git),)
|
2020-04-21 20:37:06 +08:00
|
|
|
libmetal.zip:
|
2022-08-28 00:21:40 +08:00
|
|
|
# Download and unpack tarball if no git repo found
|
2024-10-08 15:30:21 +08:00
|
|
|
$(call DOWNLOAD,https://github.com/OpenAMP/libmetal/archive,$(LIBMETAL_COMMIT).zip,libmetal.zip)
|
2020-04-21 20:37:06 +08:00
|
|
|
$(Q) unzip -o libmetal.zip
|
2024-10-08 15:30:21 +08:00
|
|
|
mv libmetal-$(LIBMETAL_COMMIT) libmetal
|
|
|
|
$(Q) patch -p0 < 0001-lib-errno.h-fix-compile-error.patch
|
|
|
|
$(Q) patch -p0 < 0002-libmetal-atomic-enable-64-bit-atomic-by-toolchain-bu.patch
|
|
|
|
$(Q) patch -p0 < 0003-atomic.h-fix-compiler-error.patch
|
|
|
|
$(Q) patch -p0 < 0004-lib-system-nuttx-fix-unused-parameter-compile-error.patch
|
|
|
|
$(Q) patch -p0 < 0005-libmetal-cmake-set-HAVE_STDATOMIC_H-default-true-in-.patch
|
|
|
|
$(Q) patch -p0 < 0006-lib-system-nuttx-io.c-include-stddef.h-in-nuttx-io.c.patch
|
2020-04-21 20:37:06 +08:00
|
|
|
|
|
|
|
.libmetal_headers: libmetal.zip
|
2022-12-08 11:17:47 +08:00
|
|
|
else
|
|
|
|
.libmetal_headers:
|
|
|
|
endif
|
2020-04-21 20:37:06 +08:00
|
|
|
$(eval headers := $(wildcard libmetal/lib/compiler/gcc/*.h))
|
2024-06-27 09:41:23 +08:00
|
|
|
$(eval headers += $(wildcard libmetal/lib/processor/generic/*.h))
|
2020-04-21 20:37:06 +08:00
|
|
|
$(eval headers += $(wildcard libmetal/lib/system/nuttx/*.h))
|
|
|
|
$(eval headers += $(wildcard libmetal/lib/*.h))
|
|
|
|
$(foreach header,$(headers), \
|
|
|
|
$(eval hobj := $(patsubst libmetal$(DELIM)lib$(DELIM)%,$(TOPDIR)$(DELIM)include$(DELIM)metal$(DELIM)%,$(header))) \
|
2019-11-10 22:06:17 +08:00
|
|
|
$(shell if [ ! -d $(dir $(hobj)) ];then mkdir -p $(dir $(hobj)); fi) \
|
2020-04-21 20:37:06 +08:00
|
|
|
$(shell sed $(LIBMETAL_HDRS_SEDEXP) $(header) > $(hobj)) \
|
2019-11-10 22:06:17 +08:00
|
|
|
)
|
|
|
|
touch $@
|
|
|
|
|
2021-08-29 22:32:27 +08:00
|
|
|
context:: .libmetal_headers
|
2019-11-10 22:06:17 +08:00
|
|
|
|
|
|
|
distclean::
|
|
|
|
$(call DELDIR, $(TOPDIR)$(DELIM)include$(DELIM)metal)
|
2022-08-28 00:21:40 +08:00
|
|
|
ifeq ($(wildcard libmetal/.git),)
|
2020-04-21 20:37:06 +08:00
|
|
|
$(call DELDIR, libmetal)
|
|
|
|
$(call DELFILE, libmetal.zip)
|
2022-08-28 00:21:40 +08:00
|
|
|
endif
|
2019-11-10 22:06:17 +08:00
|
|
|
$(call DELFILE, .libmetal_headers)
|
|
|
|
|
|
|
|
endif
|