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