File: JdkNativeCompilation.gmk

package info (click to toggle)
openjdk-26 26~32ea-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 841,336 kB
  • sloc: java: 5,732,058; xml: 1,398,183; cpp: 1,348,173; ansic: 488,951; asm: 404,027; objc: 21,152; sh: 14,618; javascript: 12,730; python: 8,352; makefile: 2,524; perl: 357; awk: 351; pascal: 103; exp: 83; sed: 72; jsp: 24
file content (543 lines) | stat: -rw-r--r-- 20,905 bytes parent folder | download
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
#
# Copyright (c) 2018, 2025, 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.
#

include MakeIncludeStart.gmk
ifeq ($(INCLUDE), true)

################################################################################

include NativeCompilation.gmk

ifeq ($(call isCompiler, gcc), true)
  # --disable-new-dtags forces use of RPATH instead of RUNPATH for rpaths.
  # This protects internal library dependencies within the JDK from being
  # overridden using LD_LIBRARY_PATH. See JDK-8326891 for more information.
  SetExecutableOrigin = \
      -Wl,-rpath,\$(DOLLAR)ORIGIN$1 -Wl,--disable-new-dtags
  SetSharedLibraryOrigin = \
      -Wl,-z,origin -Wl,-rpath,\$(DOLLAR)ORIGIN$1 -Wl,--disable-new-dtags
else ifeq ($(call isCompiler, clang), true)
  ifeq ($(call isTargetOs, macosx), true)
    SetExecutableOrigin = \
        -Wl,-rpath,@loader_path$(or $1,/.)
    SetSharedLibraryOrigin = \
        -Wl,-rpath,@loader_path$(or $1,/.)
  else ifeq ($(call isTargetOs, aix), true)
    SetExecutableOrigin =
    SetSharedLibraryOrigin =
  else
    ifeq ($(call isTargetOs, linux), true)
      SetExecutableOrigin = \
          -Wl,-rpath,\$(DOLLAR)ORIGIN$1 -Wl,--disable-new-dtags
    else
      SetExecutableOrigin = \
          -Wl,-rpath,\$(DOLLAR)ORIGIN$1
    endif

    ifeq ($(call isTargetOs, arm), true)
      SetSharedLibraryOrigin = \
          -Wl,-rpath,\$(DOLLAR)ORIGIN$1
    else
      SetSharedLibraryOrigin = \
          -Wl,-z,origin -Wl,-rpath,\$(DOLLAR)ORIGIN$1
    endif
  endif
else ifeq ($(call isCompiler, microsoft), true)
  SetExecutableOrigin =
  SetSharedLibraryOrigin =
else
  $(error Unknown toolchain)
endif

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

# Returns the module specific java header dir if it exists.
# Param 1 - module name
GetJavaHeaderDir = \
  $(if $(strip $1),$(wildcard $(SUPPORT_OUTPUTDIR)/headers/$(strip $1)))

HOTSPOT_INCLUDE_DIR := $(TOPDIR)/src/hotspot/share/include \
    $(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include

# Preprocess a source dir destination. Pass on absolute paths unchanged. Expand
# description such as "java.base:headers" into a set of proper absolute paths,
# by looking in $MODULE/[shared|$OS|$OSTYPE]/native.
# Treat *:libjvm as a special case, and replace it with the proper hotspot
# include directories.
ProcessSrcDir = \
  $(if $(findstring :, $1), \
    $(if $(filter %:libjvm, $1), \
      $(HOTSPOT_INCLUDE_DIR) \
    , \
      $(call FindSrcDirsForComponent, $(firstword $(subst :, , $1)), \
          $(lastword $(subst :, , $1))) \
    ) \
  , \
    $(if $(filter /%, $1), \
      $1 \
    , \
      $(if $(filter libjvm, $1), \
        $(HOTSPOT_INCLUDE_DIR) \
      , \
        $(call FindSrcDirsForComponent, $(MODULE), $1) \
      ) \
    ) \
  )

# Create a proper LIBPATH for the given library. Sets result in $1_$2_LIBPATH.
# $1: The name of the rule (namespace)
# $2: The safe namespace of the library
define ResolveLibPath
  # Determine proper LIBPATH. This is quite messy due to historical reasons,
  # and because we need to have special treatment for "gtest:" and ":jvm".
  ifneq ($$($1_$2_MODULE), gtest)
    ifneq ($$($1_$2_NAME), jvm)
      # This is the common case
      ifeq ($$(call isTargetOs, windows), true)
        $1_$2_LIBPATH := $$(SUPPORT_OUTPUTDIR)/native/$$($1_$2_MODULE)/lib$$($1_$2_NAME)
      else
        ifeq ($(STATIC_LIBS), true)
          $1_$2_LIBPATH := $$(SUPPORT_OUTPUTDIR)/native/$$($1_$2_MODULE)/lib$$($1_$2_NAME)/static
        else ifeq ($$($1_$2_STATIC_LIBRARY), true)
          $1_$2_LIBPATH := $$(SUPPORT_OUTPUTDIR)/native/$$($1_$2_MODULE)
        else
          $1_$2_LIBPATH := $$(SUPPORT_OUTPUTDIR)/modules_libs/$$($1_$2_MODULE)
        endif
      endif
    else
      # Special treatment for hotspot
      ifeq ($(CREATING_BUILDJDK), true)
        # When building a buildjdk, it's always only the server variant
        $1_$2_JVM_VARIANT_PATH := server
      else
        $1_$2_JVM_VARIANT_PATH := $(JVM_VARIANT_MAIN)
      endif
      ifeq ($$(call isTargetOs, windows), true)
        ifeq ($(STATIC_LIBS), true)
          $1_$2_LIBPATH := $$(HOTSPOT_OUTPUTDIR)/variant-$$($1_$2_JVM_VARIANT_PATH)/libjvm/objs/static
        else
          $1_$2_LIBPATH := $$(SUPPORT_OUTPUTDIR)/modules_libs/$$($1_$2_MODULE)
        endif
      else
        ifeq ($(STATIC_LIBS), true)
          $1_$2_LIBPATH := $$(HOTSPOT_OUTPUTDIR)/variant-$$($1_$2_JVM_VARIANT_PATH)/libjvm/objs/static
        else
          $1_$2_LIBPATH := $$(SUPPORT_OUTPUTDIR)/modules_libs/$$($1_$2_MODULE)/$$($1_$2_JVM_VARIANT_PATH)
        endif
      endif
    endif
  else
    # Special treatment for virtual module "gtest"
    ifeq ($$($1_$2_NAME), jvm)
      ifeq ($$(call isTargetOs, windows), true)
        ifeq ($(STATIC_LIBS), true)
          $1_$2_LIBPATH := $$(JVM_OUTPUTDIR)/gtest/objs/static
        else
          $1_$2_LIBPATH := $$(JVM_OUTPUTDIR)/gtest/objs
        endif
      else
        ifeq ($(STATIC_LIBS), true)
          $1_$2_LIBPATH := $$(JVM_OUTPUTDIR)/gtest/objs/static
        else
          $1_$2_LIBPATH := $$(JVM_OUTPUTDIR)/gtest
        endif
      endif
    else ifeq ($$($1_$2_NAME), gtest)
      $1_$2_LIBPATH := $$(JVM_OUTPUTDIR)/libgtest
      ifeq ($(STATIC_LIBS), true)
        $1_$2_LIBPATH := $$(JVM_OUTPUTDIR)/libgtest/objs/static
      else
        $1_$2_LIBPATH := $$(JVM_OUTPUTDIR)/libgtest
      endif
    endif
  endif
endef

# Process a JDK library designation such as "java.desktop:jawt" into the needed
# additions to EXTRA_LINK_DEPS, LDFLAGS, LIBS and EXTRA_HEADER_DIRS.
# $1: The name of the rule (namespace)
# $2: The safe namespace of the library
# $3: The actual string given to represent the library
define AddJdkLibrary
  $1_$2_NAME := $$(strip $$(lastword $$(subst :, , $3)))
  $1_$2_MODULE := $$(strip $$(patsubst %$$($1_$2_NAME), %, $3))

  ifeq ($$(filter lib%, $$($1_$2_NAME)), )
    $$(error Library name $$($1_$2_NAME) missing lib prefix in $1)
  endif
  $1_$2_NAME := $$(strip $$(patsubst lib%, %, $$($1_$2_NAME)))

  ifeq ($$($1_$2_MODULE), )
    $1_$2_MODULE := $$(MODULE)
  else
    $1_$2_MODULE := $$(strip $$(patsubst %:, %, $$($1_$2_MODULE)))
  endif

  # Determine if the library in question is static.
  # Ideally, we should not hardcode these
  ifeq ($(call isTargetOs, aix)+$$($1_$2_MODULE):$$($1_$2_NAME), true+java.base:jli)
    $1_$2_STATIC_LIBRARY := true
  endif
  ifeq ($$($1_$2_MODULE):$$($1_$2_NAME), gtest:gtest)
    $1_$2_STATIC_LIBRARY := true
  endif

  # Setup $1_$2_LIBPATH.
  $$(eval $$(call ResolveLibPath,$1,$2))

  $1_EXTRA_HEADER_DIRS += $$($1_$2_MODULE):lib$$($1_$2_NAME)

  ifneq ($(STATIC_LIBS), true)
    ifeq ($$(call isTargetOs, windows), true)
      ifeq ($$(filter -libpath:$$($1_$2_LIBPATH), $$($1_LDFLAGS)), )
        $1_LDFLAGS += -libpath:$$($1_$2_LIBPATH)
      endif
      $1_LIBS += $$($1_$2_NAME)$(STATIC_LIBRARY_SUFFIX)
      $1_$2_LIBFILE := $(LIBRARY_PREFIX)$$($1_$2_NAME)$(STATIC_LIBRARY_SUFFIX)
    else
      ifeq ($$(filter -L$$($1_$2_LIBPATH), $$($1_LDFLAGS)), )
        $1_LDFLAGS += -L$$($1_$2_LIBPATH)
      endif
      $1_LIBS += -l$$($1_$2_NAME)
      ifeq ($$($1_$2_STATIC_LIBRARY), true)
        $1_$2_LIBFILE := $(LIBRARY_PREFIX)$$($1_$2_NAME)$(STATIC_LIBRARY_SUFFIX)
      else
        $1_$2_LIBFILE := $(LIBRARY_PREFIX)$$($1_$2_NAME)$(SHARED_LIBRARY_SUFFIX)
      endif
    endif

    $1_EXTRA_LINK_DEPS += $$($1_$2_LIBPATH)/$$($1_$2_LIBFILE)
  endif
endef

GLOBAL_VERSION_INFO_RESOURCE := $(TOPDIR)/src/java.base/windows/native/common/version.rc

# \xA9 is the copyright symbol in ANSI encoding (Windows-1252), which rc.exe
# assumes the resource file is in.
JDK_RCFLAGS=$(RCFLAGS) \
    -D"JDK_VERSION_STRING=$(VERSION_STRING)" \
    -D"JDK_COMPANY=$(JDK_RC_COMPANY_NAME)" \
    -D"JDK_VER=$(VERSION_NUMBER_FOUR_POSITIONS)" \
    -D"JDK_COPYRIGHT=Copyright \xA9 $(COPYRIGHT_YEAR)" \
    -D"JDK_NAME=$(JDK_RC_NAME) $(VERSION_SHORT)" \
    -D"JDK_FVER=$(subst .,$(COMMA),$(VERSION_NUMBER_FOUR_POSITIONS))"

# Setup make rules for creating a native binary with suitable defaults
# for the OpenJDK project. This macro is mostly considered to be an internal
# support version. Please use SetupJdkLibrary or SetupJdkExecutable instead.
#
# 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. This macro also adds the following additional
# arguments:
#
#   SRC -- this is passed on after preprocessing. The preprocessing will pass on
#     absolute paths unchanged, but relative paths will be expanded to include
#     all directories with this name in $MODULE/[shared|$OS|$OSTYPE]/native.
#   EXTRA_SRC -- additional directories to look for source in. This is processed
#     like SRC.
#   EXCLUDE_SRC_PATTERNS -- exclude source dirs matching these patterns from
#     appearing in SRC.
#   EXTRA_HEADER_DIRS -- additional directories to look for headers in. This can
#     be specified either as an absolute path, or relative directory names which
#     are preprocessed like SRC, or in the format <module>:<directory>, which
#     will be processed like SRC but for the given module. The names
#     "java.base:libjvm" and "gtest:libjvm" symbolise virtual libraries that
#     will be replaced with proper values for hotspot.
#   HEADERS_FROM_SRC -- if false, does not add source dirs automatically as
#     header include dirs. (Defaults to true.)
#   JAVA_HEADERS -- if false, does not add the directory with the generated
#     headers from the Java compilation of the current module to the search
#     path for include files. (Defaults to true.)
#   JDK_LIBS -- libraries generated by the JDK build system to link against.
#     These take the form <module>:<basename>. For the current module, the
#     module name and colon can be omitted. The basename should be specified
#     as the source directory, e.g. "libjava". The gtest module is a virtual
#     module that will be replaced with correct values for gtest. When
#     specifying JDK_LIBS, suitable values for EXTRA_LINK_DEPS, LDFLAGS, LIBS
#     and EXTRA_HEADER_DIRS will be added.
#   JDK_LIBS_<os> or JDK_LIBS_<osType> -- additional JDK_LIBS for the given OS
#     or OS type only
#   ONLY_EXPORTED -- if true, this library will be flagged as not
#     to be included for this module when building static libs
#   EXTRA_RCFLAGS -- additional RCFLAGS to append.
#   RC_FILEDESC -- override the default FILEDESC for Windows version.rc
#   DEFAULT_LIBCXX -- if false, do not add LIBCXX to LIBS for C++ compilations
#   DEFAULT_CFLAGS -- if false, do not add default CFLAGS and CXXFLAGS
#   DEFAULT_LDFLAGS -- if false, do not add default LDFLAGS
#   CFLAGS_FILTER_OUT -- flags to filter out from default CFLAGS
#   CXXFLAGS_FILTER_OUT -- flags to filter out from default CXXFLAGS
#   LDFLAGS_FILTER_OUT -- flags to filter out from default LDFLAGS
#   LD_SET_ORIGIN -- if false, do not add SET_*_ORIGIN flags to LDFLAGS
#   APPEND_LDFLAGS -- a quirk to have additional LDFLAGS that will be set after
#     the origin flags
#   DEFAULT_VERSIONINFO_RESOURCE -- if false, do not set the default
#     VERSIONINFO_RESOURCE
#
SetupJdkNativeCompilation = $(NamedParamsMacroTemplate)
define SetupJdkNativeCompilationBody
  ifeq ($$($1_TYPE), EXECUTABLE)
    $1_NATIVE_DIR_PREFIX :=
    $1_MODULES_PATH := modules_cmds
    $1_RC_EXT := exe
    $1_RC_FTYPE := 0x1L
  else
    $1_NATIVE_DIR_PREFIX := lib
    $1_MODULES_PATH := modules_libs
    $1_RC_EXT := dll
    $1_RC_FTYPE := 0x2L
  endif

  ifneq ($$(MODULE), )
    # Record the fact that this native library is part of the current module
    # (unless told otherwise). This variable stores information about all
    # created libraries, and is read by ModuleWrapper.
    ifneq ($$($1_ONLY_EXPORTED), true)
      $$(MODULE)_INCLUDED_LIBS += $$($1_NAME)
    endif
  endif

  ifeq ($$($1_OUTPUT_DIR), )
    ifneq ($$(MODULE), )
      ifeq ($$($1_TYPE), STATIC_LIBRARY)
        $1_OUTPUT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)
      else
        $1_OUTPUT_DIR := $$(SUPPORT_OUTPUTDIR)/$$($1_MODULES_PATH)/$$(strip $$(MODULE))
      endif
    else
      $$(error Must specify OUTPUT_DIR in a MODULE free context)
    endif
  endif

  ifeq ($$($1_OBJECT_DIR), )
    ifneq ($$(MODULE), )
      $1_OBJECT_DIR := $$(SUPPORT_OUTPUTDIR)/native/$$(MODULE)/$$($1_NATIVE_DIR_PREFIX)$$($1_NAME)
    else
      $$(error Must specify OBJECT_DIR in a MODULE free context)
    endif
  endif

  ifneq ($$($1_DEFAULT_LIBCXX), false)
    ifeq ($$($1_LINK_TYPE), C++)
      $1_LIBS += $(LIBCXX)
    endif
  endif

  ifeq ($$($1_SRC), )
    ifneq ($$(MODULE), )
      $1_SRC := $$(call FindSrcDirsForComponent, $$(MODULE), $$($1_NATIVE_DIR_PREFIX)$$($1_NAME))
    else
      ifeq ($$($1_EXTRA_FILES), )
        $$(error Must specify SRC or EXTRA_FILES in a MODULE free context)
      endif
    endif
  else
    $1_SRC := $$(foreach dir, $$($1_SRC), $$(call ProcessSrcDir, $$(dir)))
  endif
  ifneq ($$($1_EXTRA_SRC), )
    $1_SRC += $$(foreach dir, $$($1_EXTRA_SRC), $$(call ProcessSrcDir, $$(dir)))
  endif

  ifneq ($$($1_EXCLUDE_SRC_PATTERNS), )
    $1_SRC_WITHOUT_WORKSPACE_ROOT := $$(patsubst $$(WORKSPACE_ROOT)/%, %, $$($1_SRC))
    $1_EXCLUDE_SRC := $$(addprefix %, $$(call containing, $$($1_EXCLUDE_SRC_PATTERNS), \
        $$($1_SRC_WITHOUT_WORKSPACE_ROOT)))
    $1_SRC := $$(filter-out $$($1_EXCLUDE_SRC), $$($1_SRC))
  endif

  ifneq ($$($1_DEFAULT_VERSIONINFO_RESOURCE), false)
    ifeq ($$($1_VERSIONINFO_RESOURCE), )
      $1_VERSIONINFO_RESOURCE := $$(GLOBAL_VERSION_INFO_RESOURCE)
    endif
  endif

  ifeq ($$($1_RC_FILEDESC), )
    $1_RC_FILEDESC := $(JDK_RC_NAME) binary
  endif
  $1_RCFLAGS := $(JDK_RCFLAGS) \
      -D"JDK_FILEDESC=$$($1_RC_FILEDESC)" \
      -D"JDK_FNAME=$$($1_NAME).$$($1_RC_EXT)" \
      -D"JDK_INTERNAL_NAME=$$($1_NAME)" \
      -D"JDK_FTYPE=$$($1_RC_FTYPE)" \
      -I$(TOPDIR)/src/java.base/windows/native/common \
      $$($1_EXTRA_RCFLAGS)

  ifneq ($$($1_HEADERS_FROM_SRC), false)
    $1_SRC_HEADER_FLAGS := $$(addprefix -I, $$(wildcard $$($1_SRC)))
  endif

  # Add the module specific java header dir
  ifneq ($$(MODULE), )
    ifneq ($$($1_JAVA_HEADERS), false)
      $1_SRC_HEADER_FLAGS += $$(addprefix -I, $$(call GetJavaHeaderDir, $$(MODULE)))
    endif
  endif

  $1_JDK_LIBS += $$($1_JDK_LIBS_$$(OPENJDK_TARGET_OS))
  $1_JDK_LIBS += $$($1_JDK_LIBS_$$(OPENJDK_TARGET_OS_TYPE))
  $$(foreach lib, $$($1_JDK_LIBS), \
    $$(eval $$(call AddJdkLibrary,$1,$$(subst :,_,$$(lib)),$$(lib))) \
  )

  # Add the include path for jni.h to all native compilations
  $1_EXTRA_HEADER_DIRS += \
      $(SUPPORT_OUTPUTDIR)/modules_include/java.base \
      java.base:include \
      #

  $1_PROCESSED_EXTRA_HEADER_DIRS := $$(foreach dir, $$($1_EXTRA_HEADER_DIRS), \
      $$(call ProcessSrcDir, $$(dir)))
  $1_EXTRA_HEADER_FLAGS := $$(addprefix -I, $$($1_PROCESSED_EXTRA_HEADER_DIRS))

  ifneq ($$($1_DEFAULT_CFLAGS), false)
    ifeq ($$($1_TYPE), EXECUTABLE)
      # Set the default flags first to be able to override
      $1_CFLAGS := $$(filter-out $$($1_CFLAGS_FILTER_OUT), $$(CFLAGS_JDKEXE)) $$($1_CFLAGS)

      # Set the default flags first to be able to override
      $1_CXXFLAGS := $$(filter-out $$($1_CXXFLAGS_FILTER_OUT), $$(CXXFLAGS_JDKEXE)) $$($1_CXXFLAGS)
    else
      # Set the default flags first to be able to override
      $1_CFLAGS := $$(filter-out $$($1_CFLAGS_FILTER_OUT), $$(CFLAGS_JDKLIB)) $$($1_CFLAGS)

      # Set the default flags first to be able to override
      $1_CXXFLAGS := $$(filter-out $$($1_CXXFLAGS_FILTER_OUT), $$(CXXFLAGS_JDKLIB)) $$($1_CXXFLAGS)
    endif
  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

  ifneq ($$($1_DEFAULT_LDFLAGS), false)
    ifeq ($$($1_TYPE), EXECUTABLE)
      # Set the default flags first to be able to override
      $1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE) $$($1_LDFLAGS))
    else
      # Set the default flags first to be able to override
      $1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKLIB) $$($1_LDFLAGS))
    endif
  endif

  ifneq ($$($1_LD_SET_ORIGIN), false)
    ifeq ($$($1_TYPE), EXECUTABLE)
      $1_LDFLAGS += $$(call SetExecutableOrigin)
    else
      $1_LDFLAGS += $$(call SetSharedLibraryOrigin)
    endif
  endif
  # APPEND_LDFLAGS, if it exists, must be set after the origin flags
  # This is a workaround to keep existing behavior
  $1_LDFLAGS += $$($1_APPEND_LDFLAGS)

  # 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 library with suitable defaults
# for the OpenJDK project. The default is to create a shared library,
# but by passing TYPE := STATIC_LIBARY, a static library can be created.
#
# 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
# SetupJdkNativeCompilation. Please see that macro for details.
SetupJdkLibrary = $(NamedParamsMacroTemplate)
define SetupJdkLibraryBody
  # If type is unspecified, default to LIBRARY
  ifeq ($$($1_TYPE), )
    $1_TYPE := LIBRARY
  endif

  # 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 SetupJdkNativeCompilation, $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
# SetupJdkNativeCompilation. Please see that macro for details.
SetupJdkExecutable = $(NamedParamsMacroTemplate)
define SetupJdkExecutableBody
  $1_TYPE := EXECUTABLE

  # 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 SetupJdkNativeCompilation, $1))
endef

################################################################################

endif # include guard
include MakeIncludeEnd.gmk