|
| 1 | + |
| 2 | +############################################################################ |
| 3 | +# libs/libm/openlibm/Make.defs |
| 4 | +# |
| 5 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 6 | +# contributor license agreements. See the NOTICE file distributed with |
| 7 | +# this work for additional information regarding copyright ownership. The |
| 8 | +# ASF licenses this file to you under the Apache License, Version 2.0 (the |
| 9 | +# "License"); you may not use this file except in compliance with the |
| 10 | +# License. You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, software |
| 15 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | +# License for the specific language governing permissions and limitations |
| 18 | +# under the License. |
| 19 | +# |
| 20 | +############################################################################ |
| 21 | + |
| 22 | +OPENLIBM_VERSION=0.8.1 |
| 23 | + |
| 24 | +openlibm-$(OPENLIBM_VERSION).zip: |
| 25 | + $(call DOWNLOAD,https://github.com/JuliaMath/openlibm/archive/refs/tags,v$(OPENLIBM_VERSION).zip,openlibm.zip) |
| 26 | + |
| 27 | +openlibm/openlibm: openlibm-$(OPENLIBM_VERSION).zip |
| 28 | + $(Q) unzip -o openlibm.zip |
| 29 | + $(Q) mv openlibm-$(OPENLIBM_VERSION) openlibm/openlibm |
| 30 | + $(Q) patch -p0 < openlibm/0001-fix-build-float_t-error-float_t-has-not-been-declare.patch |
| 31 | + $(Q) patch -p0 < openlibm/0002-add-math.h-and-complex.h-to-openlibm.patch |
| 32 | + |
| 33 | +ifeq ($(wildcard openlibm/openlibm/.git),) |
| 34 | +distclean:: |
| 35 | + $(call DELFILE, openlibm.zip) |
| 36 | + $(call DELDIR, openlibm/openlibm) |
| 37 | +context:: openlibm/openlibm |
| 38 | +else |
| 39 | +distclean:: |
| 40 | +context:: |
| 41 | +endif |
| 42 | + |
| 43 | +# OS-specific stuff |
| 44 | +# Get ARCH, it is used to read source code file list form $(ARCH)/Make.files |
| 45 | +ifeq ($(CONFIG_ARCH),sim) |
| 46 | + ifeq ($(CONFIG_SIM_M32),y) |
| 47 | + ARCH = i387 |
| 48 | + else ifeq ($(CONFIG_HOST_ARM64),y) |
| 49 | + ARCH = aarch64 |
| 50 | + else ifeq ($(CONFIG_HOST_ARM),y) |
| 51 | + ARCH = arm |
| 52 | + else ifeq ($(CONFIG_HOST_X86),y) |
| 53 | + ARCH = i387 |
| 54 | + else |
| 55 | + ARCH = amd64 |
| 56 | + endif |
| 57 | +else ifeq ($(CONFIG_ARCH),risc-v) |
| 58 | + ARCH = riscv64 |
| 59 | +else ifeq ($(CONFIG_ARCH),arm) |
| 60 | + ARCH = arm |
| 61 | +else ifeq ($(CONFIG_ARCH),arm64) |
| 62 | + ARCH = arm64 |
| 63 | +else ifeq ($(CONFIG_ARCH),x86) |
| 64 | + ARCH = i387 |
| 65 | +else ifeq ($(CONFIG_ARCH),x86_64) |
| 66 | + ARCH = amd64 |
| 67 | +else |
| 68 | + ARCH = $(CONFIG_ARCH) |
| 69 | +endif |
| 70 | + |
| 71 | +# Get source code lits from Make.files,and append to variable SRCS |
| 72 | +# (1) Override CUR_SRCS to xxx_SRCS(for example src_SRCS etc.), then in xxx/Make.files CUR_SRCS is changed to xxx_SRCS. |
| 73 | +# (2) Include Make.files |
| 74 | +# (3) Get variable xxx_SRCS from Make.files, and append it to variable SRCS |
| 75 | +define INC_template |
| 76 | + ifneq ($(wildcard $(1)/Make.files),) |
| 77 | + override CUR_SRCS = $(2)_SRCS |
| 78 | + include $(1)/Make.files |
| 79 | + SRCS += $$($(2)_SRCS) |
| 80 | + endif |
| 81 | +endef |
| 82 | + |
| 83 | +# Determines whether `long double` is the same as `double` on this arch. |
| 84 | +# linux x86_64, for instance, `long double` is 80 bits wide, whereas on macOS aarch64, |
| 85 | +# `long double` is the same as `double`. |
| 86 | +ifneq ($(filter $(ARCH),i387 amd64),) # Add ld80 directory on x86 and x64 |
| 87 | +$(eval $(call INC_template,openlibm/openlibm/ld80)) |
| 88 | +VPATH += :openlibm/openlibm/ld80 |
| 89 | +else ifneq ($(filter $(ARCH),aarch64),) # Add ld128 directory on aarch64 |
| 90 | +$(eval $(call INC_template,openlibm/openlibm/ld128)) |
| 91 | +VPATH += :openlibm/openlibm/ld128 |
| 92 | +endif |
| 93 | + |
| 94 | +$(eval $(call INC_template,openlibm/openlibm/src,src)) |
| 95 | +$(eval $(call INC_template,openlibm/openlibm/$(ARCH),$(ARCH))) |
| 96 | +$(eval $(call INC_template,openlibm/openlibm/bsdsrc,bsdsrc)) |
| 97 | + |
| 98 | +VPATH += :openlibm/openlibm/src |
| 99 | +VPATH += :openlibm/openlibm/$(ARCH) |
| 100 | +VPATH += :openlibm/openlibm/bsdsrc |
| 101 | + |
| 102 | +CFLAGS += ${INCDIR_PREFIX}openlibm/openlibm |
| 103 | +CFLAGS += ${INCDIR_PREFIX}openlibm/openlibm/$(ARCH) |
| 104 | +CFLAGS += ${INCDIR_PREFIX}openlibm/openlibm/src |
| 105 | +CFLAGS += ${DEFINE_PREFIX}__BSD_VISIBLE |
| 106 | + |
| 107 | +AFLAGS += ${INCDIR_PREFIX}openlibm/openlibm |
| 108 | +AFLAGS += ${INCDIR_PREFIX}openlibm/openlibm/$(ARCH) |
| 109 | +AFLAGS += ${INCDIR_PREFIX}openlibm/openlibm/src |
| 110 | +AFLAGS += ${DEFINE_PREFIX}__BSD_VISIBLE |
| 111 | + |
| 112 | +CSRCS := $(sort $(filter %.c,$(SRCS))) |
| 113 | +ASRCS := $(sort $(filter %.S,$(SRCS))) |
| 114 | + |
| 115 | +# CSRCS and ASRCS have the same name files, we use .S files,so remove them from CSRCS |
| 116 | +CSRCS := $(filter-out $(patsubst %.S,%.c,$(ASRCS)),$(CSRCS)) |
0 commit comments