Main.gmk 27.5 KB
Newer Older
O
ohair 已提交
1
#
2
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
O
ohair 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
# 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.
#

C
chegar 已提交
26 27 28
################################################################################
# This is the main makefile containing most actual top level targets. It needs
# to be called with a SPEC file defined.
I
ihse 已提交
29
################################################################################
C
chegar 已提交
30 31 32

# Declare default target
default:
O
ohair 已提交
33

I
ihse 已提交
34 35 36 37
ifeq ($(wildcard $(SPEC)),)
  $(error Main.gmk needs SPEC set to a proper spec.gmk)
endif

O
ohair 已提交
38 39 40
# Now load the spec
include $(SPEC)

I
ihse 已提交
41
include $(SRC_ROOT)/make/MainSupport.gmk
C
chegar 已提交
42

43
# Load the vital tools for all the makefiles.
I
ihse 已提交
44
include $(SRC_ROOT)/make/common/MakeBase.gmk
45
include $(SRC_ROOT)/make/common/Modules.gmk
O
ohair 已提交
46

C
chegar 已提交
47
# Declare ALL_TARGETS as an immediate variable. This variable is a list of all
48
# valid top level targets. It's used to declare them all as PHONY and to
C
chegar 已提交
49 50 51
# generate the -only targets.
ALL_TARGETS :=

52 53
# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, , Main.gmk))
O
ohair 已提交
54

C
chegar 已提交
55
# All modules for the current target platform.
56
ALL_MODULES := $(call FindAllModules)
O
ohair 已提交
57

C
chegar 已提交
58 59 60 61 62 63
################################################################################
################################################################################
#
# Recipes for all targets. Only recipes, dependencies are declared later.
#
################################################################################
O
ohair 已提交
64

C
chegar 已提交
65 66
################################################################################
# Interim/build tools targets, compiling tools used during the build
O
ohair 已提交
67

C
chegar 已提交
68 69 70
buildtools-langtools:
	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Tools.gmk)

C
chegar 已提交
71 72
interim-langtools:
	+($(CD) $(LANGTOOLS_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterim.gmk)
O
ohair 已提交
73

C
chegar 已提交
74 75
interim-rmic:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileInterimRmic.gmk)
76

N
naoto 已提交
77 78 79
interim-cldrconverter:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopyInterimCLDRConverter.gmk)

C
chegar 已提交
80
buildtools-jdk:
E
erikj 已提交
81
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileTools.gmk)
O
ohair 已提交
82

83
ALL_TARGETS += buildtools-langtools interim-langtools \
N
naoto 已提交
84
    interim-rmic interim-cldrconverter buildtools-jdk
C
chegar 已提交
85 86 87 88 89 90 91 92 93 94

################################################################################
# Special targets for certain modules

import-hotspot:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Import.gmk)

unpack-sec:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f UnpackSecurity.gmk)

95 96 97 98
generate-exported-symbols:
	+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildStatic.gmk)

ALL_TARGETS += import-hotspot unpack-sec generate-exported-symbols
C
chegar 已提交
99 100 101

################################################################################
# Gensrc targets, generating source before java compilation can be done
C
chegar 已提交
102 103 104 105 106 107 108 109 110 111
$(eval $(call DeclareRecipesForPhase, GENSRC, \
    TARGET_SUFFIX := gensrc, \
    FILE_PREFIX := Gensrc, \
    MAKE_SUBDIR := gensrc, \
    CHECK_MODULES := $(ALL_MODULES), \
    MULTIPLE_MAKEFILES := true))

JDK_GENSRC_TARGETS := $(filter %-gensrc-jdk, $(GENSRC_TARGETS))
LANGTOOLS_GENSRC_TARGETS := $(filter %-gensrc-langtools, $(GENSRC_TARGETS))
CORBA_GENSRC_TARGETS := $(filter %-gensrc-corba, $(GENSRC_TARGETS))
112
HOTSPOT_GENSRC_TARGETS := $(filter %-gensrc-hotspot, $(GENSRC_TARGETS))
C
chegar 已提交
113

A
alanb 已提交
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
GENSRC_MODULEINFO_MODULES := $(ALL_MODULES)
GENSRC_MODULEINFO_TARGETS := $(addsuffix -gensrc-moduleinfo, \
    $(GENSRC_MODULEINFO_MODULES))

GENSRC_MODULES := $(GENSRC_MODULEINFO_MODULES)
GENSRC_TARGETS += $(sort $(GENSRC_MODULEINFO_TARGETS) \
    $(addsuffix -gensrc, $(GENSRC_MODULES)))

define DeclareModuleInfoRecipe
  $1-gensrc-moduleinfo:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
	    -f GensrcModuleInfo.gmk MODULE=$1)

  $1-gensrc: $1-gensrc-moduleinfo
endef

$(foreach m, $(GENSRC_MODULEINFO_MODULES), $(eval $(call DeclareModuleInfoRecipe,$m)))

C
chegar 已提交
132 133 134 135
ALL_TARGETS += $(GENSRC_TARGETS)

################################################################################
# Generate data targets
C
chegar 已提交
136 137 138 139 140 141
$(eval $(call DeclareRecipesForPhase, GENDATA, \
    TARGET_SUFFIX := gendata, \
    FILE_PREFIX := Gendata, \
    MAKE_SUBDIR := gendata, \
    CHECK_MODULES := $(ALL_MODULES), \
    USE_WRAPPER := true))
C
chegar 已提交
142 143 144 145 146

ALL_TARGETS += $(GENDATA_TARGETS)

################################################################################
# Copy files targets
C
chegar 已提交
147 148 149 150 151
$(eval $(call DeclareRecipesForPhase, COPY, \
    TARGET_SUFFIX := copy, \
    FILE_PREFIX := Copy, \
    MAKE_SUBDIR := copy, \
    CHECK_MODULES := $(ALL_MODULES), \
152 153
    USE_WRAPPER := true, \
    MULTIPLE_MAKEFILES := true))
C
chegar 已提交
154

A
alanb 已提交
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
ALL_COPY_MODULES += $(COPY_MODULES)
ALL_COPY_TARGETS += $(COPY_TARGETS)

IMPORT_COPY_MODULES := $(call FindImportedModules)
IMPORT_COPY_TARGETS := $(addsuffix -copy, $(IMPORT_COPY_MODULES))
ALL_COPY_MODULES += $(IMPORT_COPY_MODULES)
ALL_COPY_TARGETS += $(IMPORT_COPY_TARGETS)

define DeclareImportCopyRecipe
  $1-copy:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
	    -f CopyImportModules.gmk MODULE=$1)
endef

$(foreach m, $(IMPORT_COPY_MODULES), $(eval $(call DeclareImportCopyRecipe,$m)))

ALL_TARGETS += $(ALL_COPY_TARGETS)
C
chegar 已提交
172 173 174

################################################################################
# Targets for compiling all java modules. Nashorn is treated separately.
A
alanb 已提交
175
JAVA_MODULES := $(ALL_MODULES)
C
chegar 已提交
176 177 178 179
JAVA_TARGETS := $(addsuffix -java, $(JAVA_MODULES))

define DeclareCompileJavaRecipe
  $1-java:
180 181
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) \
	    -f CompileJavaModules.gmk MODULE=$1)
C
chegar 已提交
182 183 184 185 186 187 188 189
endef

$(foreach m, $(filter-out jdk.scripting.nashorn, $(JAVA_MODULES)), \
    $(eval $(call DeclareCompileJavaRecipe,$m)))

# Build nashorn. Needs to be compiled separately from the rest of the modules
# due to nasgen.
jdk.scripting.nashorn-java:
190 191
	+($(CD) $(NASHORN_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) \
	    -f BuildNashorn.gmk compile)
C
chegar 已提交
192 193 194 195 196

ALL_TARGETS += $(JAVA_TARGETS)

################################################################################
# Targets for running rmic.
C
chegar 已提交
197 198 199 200 201
$(eval $(call DeclareRecipesForPhase, RMIC, \
    TARGET_SUFFIX := rmic, \
    FILE_PREFIX := Rmic, \
    MAKE_SUBDIR := rmic, \
    CHECK_MODULES := $(ALL_MODULES)))
C
chegar 已提交
202 203 204 205 206

ALL_TARGETS += $(RMIC_TARGETS)

################################################################################
# Targets for compiling native libraries
C
chegar 已提交
207 208 209 210 211 212
$(eval $(call DeclareRecipesForPhase, LIBS, \
    TARGET_SUFFIX := libs, \
    FILE_PREFIX := Lib, \
    MAKE_SUBDIR := lib, \
    CHECK_MODULES := $(ALL_MODULES), \
    USE_WRAPPER := true))
C
chegar 已提交
213

C
chegar 已提交
214
ALL_TARGETS += $(LIBS_TARGETS)
215

C
chegar 已提交
216 217
################################################################################
# Targets for compiling native executables
C
chegar 已提交
218 219 220 221 222 223
$(eval $(call DeclareRecipesForPhase, LAUNCHER, \
    TARGET_SUFFIX := launchers, \
    FILE_PREFIX := Launcher, \
    MAKE_SUBDIR := launcher, \
    CHECK_MODULES := $(ALL_MODULES), \
    USE_WRAPPER := true))
C
chegar 已提交
224 225 226 227 228

ALL_TARGETS += $(LAUNCHER_TARGETS)

################################################################################
# Build hotspot target
O
ohair 已提交
229

230
ifeq ($(BUILD_HOTSPOT),true)
C
chegar 已提交
231
  hotspot:
E
erikj 已提交
232 233 234 235 236
        ifeq ($(USE_NEW_HOTSPOT_BUILD), true)
	  +($(CD) $(HOTSPOT_TOPDIR)/makefiles && $(MAKE) $(MAKE_ARGS) -f BuildHotspot.gmk)
        else
	  +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk)
        endif
237
endif
O
ohair 已提交
238

E
erikj 已提交
239 240 241 242
hotspot-ide-project:
	+($(CD) $(HOTSPOT_TOPDIR)/makefiles && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk)

ALL_TARGETS += hotspot hotspot-ide-project
243

C
chegar 已提交
244 245
################################################################################
# Build demos and samples targets
246

E
erikj 已提交
247
demos-jdk:
C
chegar 已提交
248 249
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CompileDemos.gmk)

E
erikj 已提交
250
samples-jdk:
C
chegar 已提交
251 252
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f CopySamples.gmk)

E
erikj 已提交
253
ALL_TARGETS += demos-jdk samples-jdk
O
ohair 已提交
254

C
chegar 已提交
255
################################################################################
A
alanb 已提交
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
# Jigsaw specific data and analysis targets.

generate-summary:
	+($(CD) $(JDK_TOPDIR)/make && $(MAKE) -f GenerateModuleSummary.gmk)

ALL_TARGETS += generate-summary

################################################################################
# Strip binaries targets

STRIP_MODULES := $(sort $(LIBS_MODULES) $(LAUNCHER_MODULES) $(COPY_MODULES) \
    $(GENDATA_MODULES))
STRIP_TARGETS := $(addsuffix -strip, $(STRIP_MODULES))

define DeclareStripRecipe
  $1-strip:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f StripBinaries.gmk \
	    MODULE=$1)
endef

$(foreach m, $(STRIP_MODULES), $(eval $(call DeclareStripRecipe,$m)))

ALL_TARGETS += $(STRIP_TARGETS)

################################################################################
# Jmod targets

JMOD_MODULES := $(ALL_MODULES)
JMOD_TARGETS := $(addsuffix -jmod, $(JMOD_MODULES))

define DeclareJmodRecipe
  $1-jmod:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateJmods.gmk \
	    MODULE=$1)
endef

$(foreach m, $(JMOD_MODULES), $(eval $(call DeclareJmodRecipe,$m)))

ALL_TARGETS += $(JMOD_TARGETS)

################################################################################
# Images targets
O
ohair 已提交
298 299 300

# Stores the tips for each repository. This file is be used when constructing the jdk image and can be
# used to track the exact sources used to build that image.
C
chegar 已提交
301 302
source-tips: $(SUPPORT_OUTPUTDIR)/source_tips
$(SUPPORT_OUTPUTDIR)/source_tips: FRC
E
erikj 已提交
303
	$(call MakeDir, $(@D))
O
ohair 已提交
304
	@$(RM) $@
305
	@$(call GetSourceTips)
O
ohair 已提交
306

307
BOOTCYCLE_TARGET := product-images
C
chegar 已提交
308 309
bootcycle-images:
	@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
310 311
	+$(MAKE) -f $(SRC_ROOT)/make/Init.gmk PARALLEL_TARGETS=$(BOOTCYCLE_TARGET) \
	    JOBS= SPEC=$(dir $(SPEC))bootcycle-spec.gmk main
C
chegar 已提交
312

C
chegar 已提交
313 314
zip-security:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSecurity.gmk)
C
chegar 已提交
315

C
chegar 已提交
316 317
zip-source:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f ZipSource.gmk)
C
chegar 已提交
318

C
chegar 已提交
319 320
jrtfs-jar:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f JrtfsJar.gmk)
C
chegar 已提交
321

C
chegar 已提交
322 323 324 325 326 327
jimages:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk jimages)

profiles:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Images.gmk profiles)

E
erikj 已提交
328
mac-bundles-jdk:
C
chegar 已提交
329
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f MacBundles.gmk)
C
chegar 已提交
330

A
alanb 已提交
331
ALL_TARGETS += source-tips bootcycle-images zip-security zip-source \
E
erikj 已提交
332
    jrtfs-jar jimages profiles mac-bundles-jdk
C
chegar 已提交
333 334 335 336 337 338 339 340 341 342

################################################################################
# Docs targets

docs-javadoc:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk docs)

docs-jvmtidoc:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk jvmtidocs)

343 344 345
zip-docs: docs-javadoc docs-jvmtidoc
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk zip-docs)

C
chegar 已提交
346 347
ALL_TARGETS += docs-javadoc docs-jvmtidoc

A
alanb 已提交
348 349 350 351 352 353
################################################################################
# Cross compilation support

ifeq ($(CREATE_BUILDJDK), true)
  # This target is only called by the recursive call below.
  create-buildjdk-compile-hotspot-helper: hotspot
354 355
  create-buildjdk-compile-modules-helper: jdk.jlink-launchers java.base-copy \
      jdk.jdeps-launchers
A
alanb 已提交
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370
endif

create-buildjdk-copy:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f CreateBuildJdkCopy.gmk)

create-buildjdk-compile-hotspot create-buildjdk-compile-modules:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Main.gmk \
	    $@-helper \
	    SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
	    HOTSPOT_SPEC=$(dir $(SPEC))buildjdk-spec.gmk \
	    CREATING_BUILDJDK=true)

ALL_TARGETS += create-buildjdk-copy create-buildjdk-compile-hotspot \
    create-buildjdk-compile-modules

C
chegar 已提交
371
################################################################################
372 373 374 375 376 377 378 379 380 381 382 383 384 385
# Build tests
#

prepare-test-image:
	$(MKDIR) -p $(TEST_IMAGE_DIR)
	$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'

build-test-hotspot-jtreg-native:
	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    build-test-hotspot-jtreg-native)

test-image-hotspot-jtreg-native:
	+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    test-image-hotspot-jtreg-native)
C
chegar 已提交
386

387 388 389 390 391 392 393 394
build-test-jdk-jtreg-native:
	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    build-test-jdk-jtreg-native)

test-image-jdk-jtreg-native:
	+($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \
	    test-image-jdk-jtreg-native)

395 396 397
build-test-lib:
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk)

398 399 400
ifeq ($(BUILD_FAILURE_HANDLER), true)
  # Builds the failure handler jtreg extension
  build-test-failure-handler:
401 402 403
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
	    -f BuildFailureHandler.gmk build)

404 405
  # Runs the tests for the failure handler jtreg extension
  test-failure-handler:
406 407 408
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
	    -f BuildFailureHandler.gmk test)

409 410
  # Copies the failure handler jtreg extension into the test image
  test-image-failure-handler:
411 412
	+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) \
	     -f BuildFailureHandler.gmk images)
413
endif
414

415 416
ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
    test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
417 418
    test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
    test-failure-handler test-image-failure-handler
419 420 421 422 423

################################################################################
# Run tests

# Run tests specified by $(TEST), or the default test set.
C
chegar 已提交
424
test:
425 426
	$(call RunTests, $(TEST))

427 428 429
test-hotspot-jtreg:
	$(call RunTests, "hotspot_all")

430 431 432
test-hotspot-jtreg-native:
	$(call RunTests, "hotspot_native_sanity")

433 434 435
test-hotspot-internal:
	$(call RunTests, "hotspot_internal")

436 437
test-jdk-jtreg-native:
	$(call RunTests, "jdk_native_sanity")
C
chegar 已提交
438 439 440 441

test-make:
	($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET))

442 443
ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \
    test-hotspot-internal test-jdk-jtreg-native test-make
C
chegar 已提交
444 445 446 447 448 449 450 451 452 453 454

################################################################################
# Install targets

install:
	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Install.gmk)

ALL_TARGETS += install

################################################################################
#
455
# Dependency declarations between targets.
C
chegar 已提交
456
#
457
# These are declared in two groups. First all dependencies between targets that
C
chegar 已提交
458 459 460 461 462 463 464
# have recipes above as these dependencies may be disabled. Then the aggregator
# targets that do not have recipes of their own, which will never have their
# dependencies disabled.
#
################################################################################
# Targets with recipes above

465 466
# If running an *-only target, parallel execution and dependencies between
# recipe targets are disabled. This makes it possible to run a select set of
C
chegar 已提交
467
# recipe targets in order. It's the responsibility of the user to make sure
468
# all prerequisites are fulfilled.
C
chegar 已提交
469 470 471
ifneq ($(findstring -only, $(MAKECMDGOALS)), )
  .NOTPARALLEL:
else
C
chegar 已提交
472 473
  $(LANGTOOLS_GENSRC_TARGETS): buildtools-langtools

C
chegar 已提交
474 475
  interim-langtools: $(LANGTOOLS_GENSRC_TARGETS)

N
naoto 已提交
476
  buildtools-jdk: interim-langtools interim-cldrconverter
C
chegar 已提交
477 478 479

  $(CORBA_GENSRC_TARGETS): interim-langtools

480 481
  $(HOTSPOT_GENSRC_TARGETS): interim-langtools

C
chegar 已提交
482
  $(JDK_GENSRC_TARGETS): interim-langtools buildtools-jdk
C
chegar 已提交
483

A
alanb 已提交
484 485
  $(GENSRC_MODULEINFO_TARGETS): buildtools-jdk

C
chegar 已提交
486
  $(GENDATA_TARGETS): interim-langtools buildtools-jdk
C
chegar 已提交
487 488 489

  interim-rmic: interim-langtools

490
  $(RMIC_TARGETS): interim-langtools interim-rmic
C
chegar 已提交
491

E
erikj 已提交
492 493
  $(JAVA_TARGETS): interim-langtools

E
erikj 已提交
494 495
  hotspot-ide-project: hotspot exploded-image

C
chegar 已提交
496 497
  import-hotspot: hotspot

498 499
  generate-exported-symbols: java.base-libs jdk.jdwp.agent-libs

C
chegar 已提交
500
  $(LIBS_TARGETS): import-hotspot
C
chegar 已提交
501 502 503

  $(LAUNCHER_TARGETS): java.base-libs

504 505 506 507
  ifeq ($(STATIC_BUILD), true)
    $(LAUNCHER_TARGETS): generate-exported-symbols
  endif

508 509 510
  # The demos are currently linking to libjvm and libjava, just like all other
  # jdk libs, even though they don't need to. To avoid warnings, make sure they
  # aren't built until after libjava and libjvm are available to link to.
E
erikj 已提交
511
  demos-jdk: $(JAVA_TARGETS)
C
chegar 已提交
512 513 514 515 516 517 518 519 520 521 522 523 524

  # Declare dependency from <module>-java to <module>-gensrc
  $(foreach m, $(GENSRC_MODULES), $(eval $m-java: $m-gensrc))

  # Declare dependencies between java modules
  $(foreach m, $(JAVA_MODULES), \
      $(eval $m-java: $(addsuffix -java, $(filter $(JAVA_MODULES), \
      $(call FindDepsForModule,$m)))))

  # Declare dependencies between <module>-rmic to <module>-java
  $(foreach m, $(RMIC_MODULES), $(eval $m-rmic: $m-java))

  # Declare dependencies from <module>-lib to <module>-java
A
alanb 已提交
525 526 527
  # Skip modules that do not have java source. When creating a BUILD_JDK, the
  # java compilation has already been done by the normal build and copied in.
  ifneq ($(CREATING_BUILDJDK), true)
528
  $(foreach m, $(filter $(JAVA_MODULES), $(LIBS_MODULES)), $(eval $m-libs: $m-java))
A
alanb 已提交
529
  endif
C
chegar 已提交
530 531

  # Declare dependencies from all other <module>-lib to java.base-lib
C
chegar 已提交
532
  $(foreach t, $(filter-out java.base-libs, $(LIBS_TARGETS)), \
C
chegar 已提交
533 534
      $(eval $t: java.base-libs))

535 536 537
  # jdk.accessibility depends on java.desktop
  jdk.accessibility-libs: java.desktop-libs

538
  # This dependency needs to be explicitly declared. jdk.jdi-gensrc generates a
C
chegar 已提交
539 540 541 542
  # header file used by jdk.jdwp.agent-libs. The jdk.jdwp.agent-gensrc is a
  # virtual target.
  jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc

543 544
  # The swing beans need to have java base properly generated to avoid errors
  # in javadoc.
C
chegar 已提交
545
  java.desktop-gensrc-jdk: java.base-gensrc
546

547 548
  # The annotation processing for jdk.vm.ci needs java.base classes from the
  # current JDK.
549
  jdk.vm.ci-gensrc-hotspot: java.base-java
550

C
chegar 已提交
551 552 553
  # Explicitly add dependencies for special targets
  java.base-java: unpack-sec

554 555 556
  # The copy target copies files generated by gensrc
  java.base-copy-hotspot: java.base-gensrc-hotspot

557
  jdk.jdeps-gendata: java rmic
558

A
alanb 已提交
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
  # Declare dependencies from <module>-strip to libs, launchers, gendata and copy
  $(foreach m, $(LIBS_MODULES), $(eval $m-strip: $m-libs))
  $(foreach m, $(LAUNCHER_MODULES), $(eval $m-strip: $m-launchers))
  $(foreach m, $(GENDATA_MODULES), $(eval $m-strip: $m-gendata))
  $(foreach m, $(COPY_MODULES), $(eval $m-strip: $m-copy))

  # Declare dependencies between jmod targets
  $(foreach m, $(JMOD_MODULES), \
      $(eval $m-jmod: $(addsuffix -jmod, $(call FindDepsForModule,$m))))

  # Declare dependencies from <module>-jmod to all other module targets
  $(foreach m, $(STRIP_MODULES), $(eval $m-jmod: $m-strip))
  $(foreach m, $(JAVA_MODULES), $(eval $m-jmod: $m-java))
  $(foreach m, $(GENDATA_MODULES), $(eval $m-jmod: $m-gendata))
  $(foreach m, $(RMIC_MODULES), $(eval $m-jmod: $m-rmic))
  $(foreach m, $(LIBS_MODULES), $(eval $m-jmod: $m-libs))
  $(foreach m, $(LAUNCHER_MODULES), $(eval $m-jmod: $m-launchers))
  $(foreach m, $(COPY_MODULES), $(eval $m-jmod: $m-copy))

  # Jmods cannot be created until we have the jlink tool ready to run, which requires
  # all java modules to be compiled and jdk.jlink-launchers.
  $(JMOD_TARGETS): java java.base-libs jdk.jlink-launchers

  ifeq ($(CREATE_BUILDJDK), true)
    $(JMOD_TARGETS): create-buildjdk
  endif

C
chegar 已提交
586 587
  zip-security: java.base-java java.security.jgss-java java.security.jgss-libs \
      $(filter jdk.crypto%, $(JAVA_TARGETS))
C
chegar 已提交
588

C
chegar 已提交
589
  zip-source: gensrc rmic
C
chegar 已提交
590

A
alanb 已提交
591
  jrtfs-jar: interim-langtools
C
chegar 已提交
592

A
alanb 已提交
593
  jimages: jmods zip-source source-tips demos samples jrtfs-jar
C
chegar 已提交
594

A
alanb 已提交
595
  profiles: jmods zip-source source-tips jrtfs-jar
C
chegar 已提交
596

E
erikj 已提交
597
  mac-bundles-jdk: jimages
C
chegar 已提交
598

C
chegar 已提交
599
  bootcycle-images: jimages
C
chegar 已提交
600

A
alanb 已提交
601
  docs-javadoc: $(GENSRC_TARGETS) rmic
C
chegar 已提交
602 603 604

  docs-jvmtidoc: hotspot

605
  test: jimages test-image
C
chegar 已提交
606

A
alanb 已提交
607 608 609
  create-buildjdk-copy: jdk.jlink-java java.base-gendata

  create-buildjdk-compile-modules: create-buildjdk-copy create-buildjdk-compile-hotspot
C
chegar 已提交
610

611 612
  test-make: clean-test-make

E
erikj 已提交
613 614
  build-test-lib: java

615 616 617 618 619 620
  build-test-failure-handler: interim-langtools

  test-failure-handler: build-test-failure-handler

  test-image-failure-handler: build-test-failure-handler

621 622 623 624
  build-test-hotspot-jtreg-native: buildtools-jdk

  build-test-jdk-jtreg-native: buildtools-jdk

625 626 627 628
  test-image-hotspot-jtreg-native: build-test-hotspot-jtreg-native

  test-image-jdk-jtreg-native: build-test-jdk-jtreg-native

629 630
  test-hotspot-internal: exploded-image

631 632
  test-hotspot-jtreg: jimages test-image

633 634
  install: product-images

A
alanb 已提交
635 636
  generate-summary: jmods

C
chegar 已提交
637 638 639 640 641
endif

################################################################################
# Virtual targets without recipes

642
buildtools: buildtools-langtools interim-langtools interim-rmic \
C
chegar 已提交
643 644
    buildtools-jdk

C
chegar 已提交
645 646 647 648
gensrc: $(GENSRC_TARGETS)

gendata: $(GENDATA_TARGETS)

A
alanb 已提交
649
copy: $(ALL_COPY_TARGETS)
C
chegar 已提交
650 651 652 653 654

java: $(JAVA_TARGETS)

rmic: $(RMIC_TARGETS)

C
chegar 已提交
655
libs: $(LIBS_TARGETS)
C
chegar 已提交
656 657 658

launchers: $(LAUNCHER_TARGETS)

A
alanb 已提交
659 660 661 662
jmods: $(JMOD_TARGETS)

strip-binaries: $(STRIP_TARGETS)

C
chegar 已提交
663 664 665
# Explicitly declare dependency for virtual target jdk.jdwp.agent-gensrc which
# is actually handled by jdk.jdi-gensrc
jdk.jdwp.agent-gensrc: jdk.jdi-gensrc
C
chegar 已提交
666 667

# Declare dependencies from <module> to all the individual targets specific
668
# to that module <module>-*, that are needed for the exploded image.
C
chegar 已提交
669 670 671 672
$(foreach m, $(GENSRC_MODULES), $(eval $m: $m-gensrc))
$(foreach m, $(JAVA_MODULES), $(eval $m: $m-java))
$(foreach m, $(GENDATA_MODULES), $(eval $m: $m-gendata))
$(foreach m, $(RMIC_MODULES), $(eval $m: $m-rmic))
C
chegar 已提交
673
$(foreach m, $(LIBS_MODULES), $(eval $m: $m-libs))
C
chegar 已提交
674
$(foreach m, $(LAUNCHER_MODULES), $(eval $m: $m-launchers))
A
alanb 已提交
675
$(foreach m, $(ALL_COPY_MODULES), $(eval $m: $m-copy))
E
erikj 已提交
676 677 678 679
demos: demos-jdk

samples: samples-jdk

680
# The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
681
exploded-image: $(ALL_MODULES)
C
chegar 已提交
682

A
alanb 已提交
683 684 685
create-buildjdk: create-buildjdk-compile-modules create-buildjdk-copy \
    create-buildjdk-compile-hotspot

E
erikj 已提交
686 687
mac-bundles: mac-bundles-jdk

688
# The $(BUILD_OUTPUT)/images directory contain the resulting deliverables,
689 690 691 692
# and in line with this, our targets for creating these are named *-image[s].

# This target builds the product images, e.g. the JRE and JDK image
# (and possibly other, more specific versions)
A
alanb 已提交
693 694 695 696 697 698 699
product-images: jimages demos samples zip-security exploded-image

# When cross compiling and building a partial BUILDJDK for the build host,
# the summary generation cannot be run.
ifneq ($(CREATE_BUILDJDK), true)
  product-images: generate-summary
endif
C
chegar 已提交
700

C
chegar 已提交
701
ifeq ($(OPENJDK_TARGET_OS), macosx)
702
  product-images: mac-bundles
C
chegar 已提交
703
endif
C
chegar 已提交
704

705
# This target builds the documentation image
706
docs-image: zip-docs
C
chegar 已提交
707

708
# This target builds the test image
709
test-image: prepare-test-image test-image-hotspot-jtreg-native \
710
    test-image-jdk-jtreg-native test-image-failure-handler
711

712 713 714
# all-images is the top-most target, it builds all our deliverables ("images").
all-images: product-images test-image docs-image

A
alanb 已提交
715
ALL_TARGETS += buildtools gensrc gendata copy java rmic libs launchers jmods \
716
    jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples exploded-image \
A
alanb 已提交
717
    create-buildjdk mac-bundles product-images docs-image test-image all-images
C
chegar 已提交
718 719 720

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

721 722 723
# Traditional targets typically run by users.
# These can be considered aliases for the targets now named by a more
# "modern" naming scheme.
724
default: $(DEFAULT_MAKE_TARGET)
725 726 727 728
jdk: exploded-image
images: product-images
docs: docs-image
all: all-images
C
chegar 已提交
729

730
ALL_TARGETS += default jdk images docs all zip-docs
C
chegar 已提交
731 732 733 734 735 736 737

################################################################################
################################################################################
#
# Clean targets
#
################################################################################
738
# Clean targets are automatically run serially by the Makefile calling this
739
# file.
C
chegar 已提交
740

C
chegar 已提交
741
CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
A
alanb 已提交
742
    images make-support test-make bundles buildjdk
C
chegar 已提交
743
CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
I
ihse 已提交
744 745
CLEAN_SUPPORT_DIRS += demos
CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
746
CLEAN_TESTS += hotspot-jtreg-native jdk-jtreg-native lib
747
CLEAN_TEST_TARGETS += $(addprefix clean-test-, $(CLEAN_TESTS))
E
erikj 已提交
748
CLEAN_PHASES := gensrc java native include docs
C
chegar 已提交
749 750 751 752 753
CLEAN_PHASE_TARGETS := $(addprefix clean-, $(CLEAN_PHASES))
CLEAN_MODULE_TARGETS := $(addprefix clean-, $(ALL_MODULES))
# Construct targets of the form clean-$module-$phase
CLEAN_MODULE_PHASE_TARGETS := $(addprefix clean-, $(foreach m, $(ALL_MODULES), \
    $(addprefix $m-, $(CLEAN_PHASES))))
O
ohair 已提交
754 755

# Remove everything, except the output from configure.
C
chegar 已提交
756
clean: $(CLEAN_DIR_TARGETS)
E
erikj 已提交
757
	($(CD) $(OUTPUT_ROOT) && $(RM) -r build*.log*)
C
chegar 已提交
758 759
	$(ECHO) Cleaned all build artifacts.

C
chegar 已提交
760 761 762
$(CLEAN_DIR_TARGETS):
	$(call CleanDir,$(patsubst clean-%, %, $@))

I
ihse 已提交
763 764 765
$(CLEAN_SUPPORT_DIR_TARGETS):
	$(call CleanSupportDir,$(patsubst clean-%, %, $@))

766 767 768
$(CLEAN_TEST_TARGETS):
	$(call CleanTest,$(patsubst clean-test-%, %, $@))

C
chegar 已提交
769 770 771 772 773 774 775 776 777 778 779 780 781 782
$(CLEAN_PHASE_TARGETS):
	$(call Clean-$(patsubst clean-%,%, $@))

$(CLEAN_MODULE_TARGETS):
	$(call CleanModule,$(patsubst clean-%, %, $@))

$(CLEAN_MODULE_PHASE_TARGETS):
	$(call Clean-$(word 3, $(subst -,$(SPACE),$@)), \
	    $(word 2, $(subst -,$(SPACE),$@)))

# When removing the support dir, we must also remove jdk. Building classes has
# the side effect of generating native headers. The headers end up in support
# while classes and touch files end up in jdk.
clean-support: clean-jdk
C
chegar 已提交
783

E
erikj 已提交
784 785
# Remove everything, including configure configuration. If the output
# directory was created by configure and now becomes empty, remove it as well.
O
ohair 已提交
786
dist-clean: clean
E
erikj 已提交
787 788
	($(CD) $(OUTPUT_ROOT) && \
	    $(RM) -r *spec.gmk $(CONFIGURESUPPORT_OUTPUTDIR) Makefile compare.sh ide)
C
chegar 已提交
789
	$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
790 791 792
	  if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
	    $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \
	  else \
C
chegar 已提交
793 794
	    ($(CD) $(SRC_ROOT) && $(ECHO) "Removing configuration directory for '$(CONF_NAME)'" \
	        && $(RM) -r $(OUTPUT_ROOT)) \
795 796
	  fi \
	)
C
chegar 已提交
797 798
	$(ECHO) Cleaned everything, you will have to re-run configure.

I
ihse 已提交
799 800 801
ALL_TARGETS += clean dist-clean $(CLEAN_DIR_TARGETS) $(CLEAN_SUPPORT_DIR_TARGETS) \
    $(CLEAN_TEST_TARGETS) $(CLEAN_PHASE_TARGETS) $(CLEAN_MODULE_TARGETS) \
    $(CLEAN_MODULE_PHASE_TARGETS)
C
chegar 已提交
802 803

################################################################################
I
ihse 已提交
804 805
# Declare *-only targets for each normal target
$(foreach t, $(ALL_TARGETS), $(eval $(t)-only: $(t)))
C
chegar 已提交
806

I
ihse 已提交
807
ALL_TARGETS += $(addsuffix -only, $(filter-out dist-clean clean%, $(ALL_TARGETS)))
808

I
ihse 已提交
809
################################################################################
O
ohair 已提交
810

I
ihse 已提交
811 812
# Include JPRT targets
include $(SRC_ROOT)/make/Jprt.gmk
C
chegar 已提交
813 814 815

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

I
ihse 已提交
816 817 818
# The following targets are intentionally not added to ALL_TARGETS since they
# are internal only, to support Init.gmk.

I
ihse 已提交
819 820 821 822 823 824
print-targets:
	  @$(ECHO) $(sort $(ALL_TARGETS))

print-modules:
	  @$(ECHO) $(sort $(ALL_MODULES))

I
ihse 已提交
825
create-main-targets-include:
E
erikj 已提交
826
	  $(call LogInfo, Generating main target list)
I
ihse 已提交
827 828
	  @$(ECHO) ALL_MAIN_TARGETS := $(sort $(ALL_TARGETS)) > \
	      $(MAKESUPPORT_OUTPUTDIR)/main-targets.gmk
C
chegar 已提交
829 830 831 832

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

.PHONY: $(ALL_TARGETS)
O
ohair 已提交
833 834

FRC: # Force target