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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
#
# Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
ifndef _JDK_NATIVE_COMPILATION_GMK
_JDK_NATIVE_COMPILATION_GMK := 1
ifeq ($(_MAKEBASE_GMK), )
$(error You must include MakeBase.gmk prior to including JdkNativeCompilation.gmk)
endif
include NativeCompilation.gmk
# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, common/JdkNativeCompilation.gmk))
FindSrcDirsForLib += \
$(call uniq, $(wildcard \
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/lib$(strip $2) \
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/lib$(strip $2) \
$(TOPDIR)/src/$(strip $1)/share/native/lib$(strip $2)))
FindSrcDirsForComponent += \
$(call uniq, $(wildcard \
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/$(strip $2) \
$(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/$(strip $2) \
$(TOPDIR)/src/$(strip $1)/share/native/$(strip $2)))
# Find a library. Used for declaring dependencies on libraries in different
# modules.
# Param 1 - module name
# Param 2 - library name
# Param 3 - optional subdir for library
FindLib = \
$(call FindLibDirForModule, \
$(strip $1))$(strip $3)/$(LIBRARY_PREFIX)$(strip $2)$(SHARED_LIBRARY_SUFFIX)
# Find a static library
# Param 1 - module name
# Param 2 - library name
# Param 3 - optional subdir for library
FindStaticLib = \
$(addprefix $(SUPPORT_OUTPUTDIR)/native/, \
$(strip $1)$(strip $3)/$(LIBRARY_PREFIX)$(strip $2)$(STATIC_LIBRARY_SUFFIX))
# If only generating compile_commands.json, make these return empty to avoid
# declaring dependencies.
ifeq ($(GENERATE_COMPILE_COMMANDS_ONLY), true)
FindLib =
FindStaticLib =
endif
# If building static versions of libraries, make these return empty to avoid
# declaring dependencies.
ifeq ($(STATIC_LIBS), true)
FindLib =
FindStaticLib =
endif
GetJavaHeaderDir = \
$(wildcard $(SUPPORT_OUTPUTDIR)/headers/$(strip $1))
# Process a dir description such as "java.base:headers" into a set of proper absolute paths.
ProcessDir = \
$(if $(findstring :, $1), \
$(call FindSrcDirsForComponent, $(firstword $(subst :, , $1)), $(lastword $(subst :, , $1))) \
, \
$(if $(filter /%, $1), \
$1 \
, \
$(call FindSrcDirsForComponent, $(MODULE), $1) \
) \
)
# Setup make rules for creating a native shared library with suitable defaults
# for the OpenJDK project.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameters are named arguments. These are all passed on to
# SetupNativeCompilation, except for
# EXTRA_RC_FLAGS -- additional RC_FLAGS to append.
# EXTRA_HEADER_DIRS -- additional directories to look for headers in
# EXTRA_SRC -- additional directories to look for source in
# EXCLUDE_SRC_PATTERNS -- exclude source dirs matching these patterns from
# appearing in SRC.
# HEADERS_FROM_SRC -- if false, does not add source dirs automatically as
# header include dirs. (Defaults to true.)
# SRC -- this is passed on, but preprocessed to accept source dir designations
# such as "java.base:headers".
SetupJdkLibrary = $(NamedParamsMacroTemplate)
define SetupJdkLibraryBody
ifeq ($$($1_OUTPUT_DIR), )
$1_OUTPUT_DIR := $$(call FindLibDirForModule, $$(MODULE))
endif
ifeq ($$($1_OBJECT_DIR), )
$1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/lib$$($1_NAME)
endif
ifeq ($$($1_SRC), )
$1_SRC := $$(call FindSrcDirsForLib, $$(MODULE), $$($1_NAME))
else
$1_SRC := $$(foreach dir, $$($1_SRC), $$(call ProcessDir, $$(dir)))
endif
ifneq ($$($1_EXTRA_SRC), )
$1_SRC += $$(foreach dir, $$($1_EXTRA_SRC), $$(call ProcessDir, $$(dir)))
endif
ifneq ($$($1_EXCLUDE_SRC_PATTERNS), )
$1_EXCLUDE_SRC := $$(call containing, $$($1_EXCLUDE_SRC_PATTERNS), $$($1_SRC))
$1_SRC := $$(filter-out $$($1_EXCLUDE_SRC), $$($1_SRC))
endif
ifeq ($$($1_VERSIONINFO_RESOURCE), )
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE)
$1_VERSIONINFO_RESOURCE :=
endif
ifeq ($$($1_RC_FLAGS), )
$1_RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=$$($1_NAME).dll" \
-D "JDK_INTERNAL_NAME=$$($1_NAME)" \
-D "JDK_FTYPE=0x2L"
else ifeq ($$($1_RC_FLAGS), DISABLE)
$1_RC_FLAGS :=
endif
ifneq ($$($1_HEADERS_FROM_SRC), false)
$1_SRC_HEADER_FLAGS := $$(addprefix -I, $$(wildcard $$($1_SRC)))
endif
# Always add the java header dir
$1_SRC_HEADER_FLAGS += $$(addprefix -I, $$(call GetJavaHeaderDir, $$(MODULE)))
ifneq ($$($1_EXTRA_HEADER_DIRS), )
$1_PROCESSED_EXTRA_HEADER_DIRS := $$(foreach dir, $$($1_EXTRA_HEADER_DIRS), \
$$(call ProcessDir, $$(dir)))
$1_EXTRA_HEADER_FLAGS := $$(addprefix -I, $$($1_PROCESSED_EXTRA_HEADER_DIRS))
endif
ifneq ($$($1_CFLAGS), )
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
endif
ifneq ($$($1_CXXFLAGS), )
$1_CXXFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
endif
ifeq ($$($1_CFLAGS)$$($1_CXXFLAGS), )
$1_CFLAGS += $$($1_SRC_HEADER_FLAGS) $$($1_EXTRA_HEADER_FLAGS)
endif
$1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS)
# Since we reuse the rule name ($1), all our arguments will pass through.
# We lose in transparency, but gain in brevity in this call...
$$(eval $$(call SetupNativeCompilation, $1, ))
endef
# Setup make rules for creating a native executable with suitable defaults for
# the OpenJDK project.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameters are named arguments. These are all passed on to
# SetupNativeCompilation, except for
# EXTRA_RC_FLAGS -- additional RC_FLAGS to append.
SetupJdkExecutable = $(NamedParamsMacroTemplate)
define SetupJdkExecutableBody
$1_TYPE := EXECUTABLE
ifeq ($$($1_OUTPUT_DIR), )
$1_OUTPUT_DIR := $$(call FindExecutableDirForModule, $$(MODULE))
endif
ifeq ($$($1_OBJECT_DIR), )
$1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$$($1_NAME)
endif
ifeq ($$($1_VERSIONINFO_RESOURCE), )
$1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
else ifeq ($$($1_VERSIONINFO_RESOURCE), DISABLE)
$1_VERSIONINFO_RESOURCE :=
endif
ifeq ($$($1_RC_FLAGS), )
$1_RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=$$($1_NAME).exe" \
-D "JDK_INTERNAL_NAME=$$($1_NAME)" \
-D "JDK_FTYPE=0x01L"
else ifeq ($$($1_RC_FLAGS), DISABLE)
$1_RC_FLAGS :=
endif
$1_RC_FLAGS += $$($1_EXTRA_RC_FLAGS)
# Since we reuse the rule name ($1), all our arguments will pass through.
# We lose in transparency, but gain in brevity in this call...
$$(eval $$(call SetupNativeCompilation, $1))
endef
endif # _JDK_NATIVE_COMPILATION_GMK
|