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 include CopyFiles.gmk 34 35 ################################################################################ 36 # If this is an imported module that has prebuilt classes, only compile 37 # module-info.java. 38 ifneq ($(IMPORT_MODULES_CLASSES), ) 39 IMPORT_MODULE_DIR := $(IMPORT_MODULES_CLASSES)/$(MODULE) 40 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), ) 41 $(MODULE)_INCLUDE_FILES := module-info.java 42 endif 43 else 44 IMPORT_MODULE_DIR := 45 endif 46 47 ################################################################################ 48 # Setup the compilation for the module 49 # 50 MODULE_SRC_DIRS := $(call FindModuleSrcDirs, $(MODULE)) 51 52 # The JDK_USER_DEFINED_FILTER is a poor man's incremental build: by specifying 53 # JDK_FILTER at the make command line, only a subset of the JDK java files will 54 # be recompiled. If multiple paths are separated by comma, convert that into a 55 # space separated list. 56 JDK_USER_DEFINED_FILTER := $(strip $(subst $(COMMA),$(SPACE), $(JDK_FILTER))) 57 ifeq ($(JDK_FILTER), ) 58 FAIL_NO_SRC := true 59 else 60 # When using JDK_FILTER, most module java compilations will end up finding 61 # no source files. Don't let that fail the build. 62 FAIL_NO_SRC := false 63 endif 64 65 # Get the complete module source path. 66 MODULESOURCEPATH := $(call GetModuleSrcPath) 67 68 # Add imported modules to the modulepath 69 MODULEPATH := $(call PathList, $(IMPORT_MODULES_CLASSES)) 70 71 ################################################################################ 72 # Copy zh_HK properties files from zh_TW (needed by some modules) 73 74 $(JDK_OUTPUTDIR)/modules/%_zh_HK.properties: $(JDK_OUTPUTDIR)/modules/%_zh_TW.properties 75 $(install-file) 76 77 CreateHkTargets = \ 78 $(call FilterExcludedTranslations, \ 79 $(patsubst $(TOPDIR)/src/%, $(JDK_OUTPUTDIR)/modules/%, \ 80 $(subst /share/classes,, \ 81 $(subst _zh_TW,_zh_HK, $(filter %_zh_TW.properties, $1)) \ 82 ) \ 83 ), \ 84 .properties \ 85 ) 86 87 ################################################################################ 88 # Include module specific build settings 89 90 THIS_SNIPPET := $(call GetModuleSnippetName, Java) 91 92 ifneq ($(wildcard $(THIS_SNIPPET)), ) 93 include MakeSnippetStart.gmk 94 95 include $(THIS_SNIPPET) 96 97 include MakeSnippetEnd.gmk 98 endif 99 100 ################################################################################ 101 # Setup the main compilation 102 $(eval $(call SetupJavaCompilation, $(MODULE), \ 103 SMALL_JAVA := false, \ 104 MODULE := $(MODULE), \ 105 SRC := $(wildcard $(MODULE_SRC_DIRS)), \ 106 INCLUDES := $(JDK_USER_DEFINED_FILTER), \ 107 FAIL_NO_SRC := $(FAIL_NO_SRC), \ 108 BIN := $(if $($(MODULE)_BIN), $($(MODULE)_BIN), $(JDK_OUTPUTDIR)/modules), \ 109 HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \ 110 CREATE_API_DIGEST := true, \ 111 CLEAN := $(CLEAN), \ 112 CLEAN_FILES := $(CLEAN_FILES), \ 113 COPY := $(COPY), \ 114 DISABLED_WARNINGS := $(DISABLED_WARNINGS_java), \ 115 EXCLUDES := $(EXCLUDES), \ 116 EXCLUDE_FILES := $(EXCLUDE_FILES), \ 117 EXCLUDE_PATTERNS := -files, \ 118 KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \ 119 TARGET_RELEASE := $(TARGET_RELEASE), \ 120 JAVAC_FLAGS := \ 121 $(DOCLINT) \ 122 $(JAVAC_FLAGS) \ 123 --module-source-path $(MODULESOURCEPATH) \ 124 --module-path $(MODULEPATH) \ 125 --system none, \ 126 )) 127 128 TARGETS += $($(MODULE)) 129 130 ################################################################################ 131 # Setup compilation for value classes in the module 132 # TBD: When $(DOCLINT) was included there was an NPE in JavacTypes.getOverriddenMethods 133 134 # Directory and file name suffix for jar file containing value classes 135 VALUECLASSES_STR := valueclasses 136 137 ifneq ($(COMPILER), bootjdk) 138 MODULE_VALUECLASS_SRC_DIRS := $(call FindModuleValueClassSrcDirs, $(MODULE)) 139 MODULE_VALUECLASS_SOURCEPATH := $(call GetModuleValueClassSrcPath) 140 141 ifneq ($(MODULE_VALUECLASS_SRC_DIRS),) 142 $(eval $(call SetupJavaCompilation, $(MODULE)-$(VALUECLASSES_STR), \ 143 SMALL_JAVA := false, \ 144 MODULE := $(MODULE), \ 145 SRC := $(wildcard $(MODULE_VALUECLASS_SRC_DIRS)), \ 146 INCLUDES := $(JDK_USER_DEFINED_FILTER), \ 147 FAIL_NO_SRC := $(FAIL_NO_SRC), \ 148 BIN := $(SUPPORT_OUTPUTDIR)/$(VALUECLASSES_STR)/, \ 149 JAR := $(JDK_OUTPUTDIR)/lib/$(VALUECLASSES_STR)/$(MODULE)-$(VALUECLASSES_STR).jar, \ 150 HEADERS := $(SUPPORT_OUTPUTDIR)/headers, \ 151 DISABLED_WARNINGS := $(DISABLED_WARNINGS_java) preview, \ 152 EXCLUDES := $(EXCLUDES), \ 153 EXCLUDE_FILES := $(EXCLUDE_FILES) \ 154 KEEP_ALL_TRANSLATIONS := $(KEEP_ALL_TRANSLATIONS), \ 155 DEPENDS := $($(MODULE)), \ 156 JAVAC_FLAGS := \ 157 $(JAVAC_FLAGS) \ 158 --module-source-path $(MODULE_VALUECLASS_SOURCEPATH) \ 159 --module-path $(JDK_OUTPUTDIR)/modules \ 160 --system none \ 161 --enable-preview -source $(JDK_SOURCE_TARGET_VERSION), \ 162 )) 163 164 TARGETS += $($(MODULE)-$(VALUECLASSES_STR)) 165 166 $(eval $(call SetupCopyFiles, $(MODULE)-copy-valueclass-jar, \ 167 FILES := $(JDK_OUTPUTDIR)/lib/$(VALUECLASSES_STR)/$(MODULE)-$(VALUECLASSES_STR).jar, \ 168 DEST := $(SUPPORT_OUTPUTDIR)/modules_libs/$(MODULE)/$(VALUECLASSES_STR), \ 169 )) 170 171 TARGETS += $($(MODULE)-copy-valueclass-jar) 172 endif 173 endif 174 175 # Declare dependencies between java compilations of different modules. 176 # Since the other modules are declared in different invocations of this file, 177 # use the macro to find the correct target file to depend on. 178 # Only the javac compilation actually depends on other modules so limit 179 # dependency declaration to that by using the *_MODFILELIST variable. 180 $($(MODULE)_MODFILELIST): $(foreach d, $(call FindDepsForModule, $(MODULE)), \ 181 $(call SetupJavaCompilationApiTarget, $d, \ 182 $(if $($d_BIN), $($d_BIN), $(JDK_OUTPUTDIR)/modules/$d))) 183 184 ################################################################################ 185 # If this is an imported module, copy the pre built classes and resources into 186 # the modules output dir 187 188 ifneq ($(wildcard $(IMPORT_MODULE_DIR)), ) 189 $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker: \ 190 $(call FindFiles, $(IMPORT_MODULE_DIR)) 191 $(call MakeDir, $(@D)) 192 # Do not delete marker and build meta data files 193 $(RM) -r $(filter-out $(@D)/_%, $(wildcard $(@D)/*)) 194 $(CP) -R $(IMPORT_MODULE_DIR)/* $(@D)/ 195 $(TOUCH) $@ 196 197 TARGETS += $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker 198 199 # Add this dependency to avoid a race between compiling module-info.java and 200 # importing the classes. 201 $($(MODULE)_COMPILE_TARGET): $(JDK_OUTPUTDIR)/modules/$(MODULE)/_imported.marker 202 endif 203 204 ################################################################################ 205 206 include MakeFileEnd.gmk