1 # 2 # Copyright (c) 2014, 2025, 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 include MakeFileStart.gmk 27 28 ################################################################################ 29 30 include JavaCompilation.gmk 31 include Modules.gmk 32 33 ################################################################################ 34 # If this is an imported module that has prebuilt classes, only compile 35 # module-info.java. 36 ifneq ($(IMPORT_MODULES_CLASSES), ) 37 IMPORT_MODULE_DIR := $(IMPORT_MODULES_CLASSES)/$(MODULE) 38 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), ) 39 $(MODULE)_INCLUDE_FILES := module-info.java 40 endif 41 else 42 IMPORT_MODULE_DIR := 43 endif 44 45 ################################################################################ 46 # Setup the compilation for the module 47 # 48 MODULE_SRC_DIRS := $(call FindModuleSrcDirs, $(MODULE)) 49 50 # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying 51 # JDK_FILTER at the make command line, only a subset of the JDK java files will 52 # be recompiled. If multiple paths are separated by comma, convert that into a 53 # space separated list. 54 JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER))) 55 ifeq ($(JDK_FILTER), ) 56 FAIL_NO_SRC := true 57 else 58 # When using JDK_FILTER, most module java compilations will end up finding 59 # no source files. Don't let that fail the build. 60 FAIL_NO_SRC := false 61 endif 62 63 # Get the complete module source path. 64 MODULESOURCEPATH := $(call GetModuleSrcPath) 65 66 # Add imported modules to the modulepath 67 MODULEPATH := $(call PathList, $(IMPORT_MODULES_CLASSES)) 68 69 ################################################################################ 70 # Copy zh_HK properties files from zh_TW (needed by some modules) 71 72 $(JDK_OUTPUTDIR)/modules/%_zh_HK.properties: $(JDK_OUTPUTDIR)/modules/%_zh_TW.properties 73 $(install-file) 74 75 CreateHkTargets = \ 76 $(call FilterExcludedTranslations, \ 77 $(patsubst $(TOPDIR)/src/%, $(JDK_OUTPUTDIR)/modules/%, \ 78 $(subst /share/classes,, \ 79 $(subst _zh_TW,_zh_HK, $(filter %_zh_TW.properties, $1)) \ 80 ) \ 81 ), \ 82 .properties \ 83 ) 84 85 ################################################################################ 86 # Include module specific build settings 87 88 THIS_SNIPPET := modules/$(MODULE)/Java.gmk 89 90 ifneq ($(wildcard $(THIS_SNIPPET)), ) 91 include MakeSnippetStart.gmk 92 93 include $(THIS_SNIPPET) 94 95 include MakeSnippetEnd.gmk 96 endif 97 98 ################################################################################ 99 # Setup the main compilation 100 101 $(eval $(call SetupJavaCompilation, $(MODULE), \ 102 SMALL_JAVA := false, \ 103 MODULE := $(MODULE), \ 104 SRC := $(wildcard $(MODULE_SRC_DIRS)), \ 105 INCLUDES := $(JDK_USER_DEFINED_FILTER), \ 106 FAIL_NO_SRC := $(FAIL_NO_SRC), \ 107 BIN := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules), \ 108 HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \ 109 CREATE_API_DIGEST := true, \ 110 CLEAN := $(CLEAN), \ 111 CLEAN_FILES := $(CLEAN_FILES), \ 112 COPY := $(COPY), \ 113 DISABLED_WARNINGS := $(DISABLED_WARNINGS_java), \ 114 EXCLUDES := $(EXCLUDES), \ 115 EXCLUDE_FILES := $(EXCLUDE_FILES), \ 116 KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \ 117 JAVAC_FLAGS := \ 118 $(DOCLINT) \ 119 $(JAVAC_FLAGS) \ 120 --module-source-path $(MODULESOURCEPATH) \ 121 --module-path $(MODULEPATH) \ 122 --system none, \ 123 )) 124 125 TARGETS += $($(MODULE)) 126 127 # Declare dependencies between java compilations of different modules. 128 # Since the other modules are declared in different invocations of this file, 129 # use the macro to find the correct target file to depend on. 130 # Only the javac compilation actually depends on other modules so limit 131 # dependency declaration to that by using the *_MODFILELIST variable. 132 $($(MODULE)_MODFILELIST): $(foreach d, $(call FindDepsForModule, $(MODULE)), \ 133 $(call SetupJavaCompilationApiTarget, $d, \ 134 $(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d))) 135 136 ################################################################################ 137 # If this is an imported module, copy the pre built classes and resources into 138 # the modules output dir 139 140 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), ) 141 $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \ 142 $(call FindFiles, $(IMPORT_MODULE_DIR)) 143 $(call MakeDir, $(@D)) 144 # Do not delete marker and build meta data files 145 $(RM) -r $(filter-out $(@D)/_%, $(wildcard $(@D)/*)) 146 $(CP) -R $(IMPORT_MODULE_DIR)/* $(@D)/ 147 $(TOUCH) $@ 148 149 TARGETS += $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker 150 151 # Add this dependency to avoid a race between compiling module-info.java and 152 # importing the classes. 153 $($(MODULE)_COMPILE_TARGET): $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker 154 endif 155 156 ################################################################################ 157 158 include MakeFileEnd.gmk