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