|
| 1 | +# |
| 2 | +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. |
| 3 | +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | +# |
| 5 | +# This code is free software; you can redistribute it and/or modify it |
| 6 | +# under the terms of the GNU General Public License version 2 only, as |
| 7 | +# published by the Free Software Foundation. Oracle designates this |
| 8 | +# particular file as subject to the "Classpath" exception as provided |
| 9 | +# by Oracle in the LICENSE file that accompanied this code. |
| 10 | +# |
| 11 | +# This code is distributed in the hope that it will be useful, but WITHOUT |
| 12 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 14 | +# version 2 for more details (a copy is included in the LICENSE file that |
| 15 | +# accompanied this code). |
| 16 | +# |
| 17 | +# You should have received a copy of the GNU General Public License version |
| 18 | +# 2 along with this work; if not, write to the Free Software Foundation, |
| 19 | +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | +# |
| 21 | +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 22 | +# or visit www.oracle.com if you need additional information or have any |
| 23 | +# questions. |
| 24 | +# |
| 25 | + |
| 26 | +################################################################################ |
| 27 | + |
| 28 | +default: all |
| 29 | + |
| 30 | +include $(SPEC) |
| 31 | +include MakeBase.gmk |
| 32 | + |
| 33 | +include CopyFiles.gmk |
| 34 | +include Execute.gmk |
| 35 | + |
| 36 | +################################################################################ |
| 37 | +# This file is responsible for updating the generated sleef source code files |
| 38 | +# that are checked in to the JDK repo, and that are actually used when building. |
| 39 | +# This target needs to be re-run every time the source code of libsleef is |
| 40 | +# updated from upstream. |
| 41 | +################################################################################ |
| 42 | + |
| 43 | +ifneq ($(COMPILE_TYPE), cross) |
| 44 | + $(error Only cross-compilation of libsleef is currently supported) |
| 45 | +endif |
| 46 | + |
| 47 | +ifeq ($(CMAKE), ) |
| 48 | + $(error CMake not found. Please install cmake and rerun configure) |
| 49 | +endif |
| 50 | + |
| 51 | +ifneq ($(OPENJDK_BUILD_OS), linux) |
| 52 | + $(error This target is only supported on linux) |
| 53 | +endif |
| 54 | + |
| 55 | +SLEEF_SUPPORT_DIR := $(MAKESUPPORT_OUTPUTDIR)/sleef |
| 56 | +SLEEF_SOURCE_BASE_DIR := $(TOPDIR)/src/jdk.incubator.vector/linux/native/libsleef |
| 57 | +SLEEF_SOURCE_DIR := $(SLEEF_SOURCE_BASE_DIR)/upstream |
| 58 | +SLEEF_TARGET_DIR := $(SLEEF_SOURCE_BASE_DIR)/generated |
| 59 | +SLEEF_NATIVE_BUILD_DIR := $(SLEEF_SUPPORT_DIR)/native |
| 60 | +SLEEF_CROSS_BUILD_DIR := $(SLEEF_SUPPORT_DIR)/cross |
| 61 | + |
| 62 | +ifeq ($(OPENJDK_TARGET_CPU), aarch64) |
| 63 | + CROSS_COMPILATION_FILENAMES := sleefinline_advsimd.h sleefinline_sve.h |
| 64 | + EXTRA_CROSS_OPTIONS := -DSLEEF_ENFORCE_SVE=TRUE |
| 65 | +else ifeq ($(OPENJDK_TARGET_CPU), riscv64) |
| 66 | + CROSS_COMPILATION_FILENAMES := sleefinline_rvvm1.h |
| 67 | + EXTRA_CROSS_OPTIONS := -DSLEEF_ENFORCE_RVVM1=TRUE |
| 68 | +else |
| 69 | + $(error Unsupported platform) |
| 70 | +endif |
| 71 | +CROSS_COMPILATION_SRC_FILES := $(addprefix $(SLEEF_CROSS_BUILD_DIR)/include/, \ |
| 72 | + $(CROSS_COMPILATION_FILENAMES)) |
| 73 | + |
| 74 | +ifeq ($(TOOLCHAIN_TYPE), clang) |
| 75 | + SLEEF_TOOLCHAIN_TYPE := llvm |
| 76 | +else |
| 77 | + SLEEF_TOOLCHAIN_TYPE := $(TOOLCHAIN_TYPE) |
| 78 | +endif |
| 79 | + |
| 80 | +SLEEF_CMAKE_FILE := toolchains/$(OPENJDK_TARGET_CPU)-$(SLEEF_TOOLCHAIN_TYPE).cmake |
| 81 | + |
| 82 | +# We need to run CMake twice, first using it to configure the build, and then |
| 83 | +# to actually build; and we need to do this twice, once for a native build |
| 84 | +# and once for the cross-compilation build. |
| 85 | + |
| 86 | +$(eval $(call SetupExecute, sleef_native_config, \ |
| 87 | + INFO := Configuring native sleef build, \ |
| 88 | + OUTPUT_DIR := $(SLEEF_NATIVE_BUILD_DIR), \ |
| 89 | + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) -S . -B \ |
| 90 | + $(SLEEF_NATIVE_BUILD_DIR), \ |
| 91 | +)) |
| 92 | + |
| 93 | +TARGETS := $(sleef_native_config) |
| 94 | + |
| 95 | +$(eval $(call SetupExecute, sleef_native_build, \ |
| 96 | + INFO := Building native sleef, \ |
| 97 | + DEPS := $(sleef_native_config), \ |
| 98 | + OUTPUT_DIR := $(SLEEF_NATIVE_BUILD_DIR), \ |
| 99 | + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) --build \ |
| 100 | + $(SLEEF_NATIVE_BUILD_DIR) -j, \ |
| 101 | +)) |
| 102 | + |
| 103 | +TARGETS := $(sleef_native_build) |
| 104 | + |
| 105 | +$(eval $(call SetupExecute, sleef_cross_config, \ |
| 106 | + INFO := Configuring cross-compiling sleef build, \ |
| 107 | + DEPS := $(sleef_native_build), \ |
| 108 | + OUTPUT_DIR := $(SLEEF_CROSS_BUILD_DIR), \ |
| 109 | + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) -S . -B \ |
| 110 | + $(SLEEF_CROSS_BUILD_DIR) \ |
| 111 | + -DCMAKE_C_COMPILER=$(CC) \ |
| 112 | + -DCMAKE_TOOLCHAIN_FILE=$(SLEEF_CMAKE_FILE) \ |
| 113 | + -DNATIVE_BUILD_DIR=$(SLEEF_NATIVE_BUILD_DIR) \ |
| 114 | + -DSLEEF_BUILD_INLINE_HEADERS=TRUE \ |
| 115 | + $(EXTRA_CROSS_OPTIONS), \ |
| 116 | +)) |
| 117 | + |
| 118 | +TARGETS := $(sleef_cross_config) |
| 119 | + |
| 120 | +$(eval $(call SetupExecute, sleef_cross_build, \ |
| 121 | + INFO := Building cross-compiling sleef, \ |
| 122 | + DEPS := $(sleef_cross_config), \ |
| 123 | + OUTPUT_DIR := $(SLEEF_NATIVE_BUILD_DIR), \ |
| 124 | + COMMAND := cd $(SLEEF_SOURCE_DIR) && $(CMAKE) --build \ |
| 125 | + $(SLEEF_CROSS_BUILD_DIR) -j, \ |
| 126 | +)) |
| 127 | + |
| 128 | +TARGETS := $(sleef_cross_build) |
| 129 | + |
| 130 | +$(CROSS_COMPILATION_SRC_FILES): $(sleef_cross_build) |
| 131 | + |
| 132 | +# Finally, copy the generated files (and one needed static file) into our |
| 133 | +# target directory. |
| 134 | + |
| 135 | +$(eval $(call SetupCopyFiles, copy_static_sleef_source, \ |
| 136 | + FILES := $(SLEEF_SOURCE_DIR)/src/common/misc.h, \ |
| 137 | + DEST := $(SLEEF_TARGET_DIR), \ |
| 138 | +)) |
| 139 | + |
| 140 | +TARGETS := $(copy_static_sleef_source) |
| 141 | + |
| 142 | +$(eval $(call SetupCopyFiles, copy_generated_sleef_source, \ |
| 143 | + FILES := $(CROSS_COMPILATION_SRC_FILES), \ |
| 144 | + DEST := $(SLEEF_TARGET_DIR), \ |
| 145 | +)) |
| 146 | + |
| 147 | +TARGETS := $(copy_generated_sleef_source) |
| 148 | + |
| 149 | +################################################################################ |
| 150 | + |
| 151 | +all: $(TARGETS) |
| 152 | + |
| 153 | +.PHONY: all default |
0 commit comments