1 #
   2 # Copyright (c) 2014, 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 ifndef _MODULES_GMK
  27 _MODULES_GMK := 1
  28 
  29 ################################################################################
  30 #
  31 # BOOT_MODULES are modules defined by the boot loader
  32 # PLATFORM_MODULES are modules defined by the platform loader
  33 # JRE_TOOL_MODULES are tools included in JRE and defined by the application loader
  34 #
  35 # All other modules not declared below are defined by the application loader
  36 # and are not included in JRE.
  37 
  38 BOOT_MODULES :=
  39 PLATFORM_MODULES :=
  40 JRE_TOOL_MODULES :=
  41 
  42 # Hook to include the corresponding custom file, if present.
  43 $(eval $(call IncludeCustomExtension, , common/Modules.gmk))
  44 
  45 UPGRADEABLE_MDOULES :=
  46 AGGREGATOR_MDOULES :=
  47 
  48 BOOT_MODULES += \
  49     java.base \
  50     java.datatransfer \
  51     java.desktop \
  52     java.httpclient \
  53     java.instrument \
  54     java.logging \
  55     java.management \
  56     java.naming \
  57     java.prefs \
  58     java.rmi \
  59     java.security.jgss \
  60     java.security.sasl \
  61     java.sql \
  62     java.xml \
  63     java.xml.crypto \
  64     jdk.httpserver \
  65     jdk.management \
  66     jdk.sctp \
  67     jdk.security.auth \
  68     jdk.security.jgss \
  69     jdk.vm.ci \
  70     #
  71 
  72 # to be deprivileged
  73 BOOT_MODULES += \
  74     java.compiler \
  75     java.scripting \
  76     java.sql.rowset \
  77     java.smartcardio \
  78     jdk.charsets \
  79     jdk.naming.rmi \
  80     #
  81 
  82 UPGRADEABLE_MODULES += \
  83     java.activation \
  84     java.annotations.common \
  85     java.corba \
  86     java.transaction \
  87     java.xml.bind \
  88     java.xml.ws \
  89     #
  90 
  91 AGGREGATOR_MODULES += \
  92     java.compact1 \
  93     java.compact2 \
  94     java.compact3 \
  95     java.se \
  96     java.se.ee \
  97     #
  98 
  99 PLATFORM_MODULES += \
 100     $(UPGRADEABLE_MODULES) \
 101     $(AGGREGATOR_MODULES)
 102     #
 103 
 104 PLATFORM_MODULES += \
 105     jdk.accessibility \
 106     jdk.crypto.ec \
 107     jdk.crypto.pkcs11 \
 108     jdk.dynalink \
 109     jdk.jsobject \
 110     jdk.xml.dom \
 111     jdk.localedata \
 112     jdk.naming.dns \
 113     jdk.scripting.nashorn \
 114     jdk.zipfs \
 115     #
 116 
 117 JRE_TOOL_MODULES += \
 118     jdk.jdwp.agent \
 119     jdk.pack200 \
 120     jdk.scripting.nashorn.shell \
 121     #
 122 
 123 ifeq ($(OPENJDK_TARGET_OS), windows)
 124   PLATFORM_MODULES += jdk.crypto.mscapi
 125 endif
 126 ifeq ($(OPENJDK_TARGET_OS), solaris)
 127   PLATFORM_MODULES += jdk.crypto.ucrypto
 128 endif
 129 
 130 ################################################################################
 131 # Some platforms don't have the serviceability agent
 132 
 133 ifeq ($(INCLUDE_SA), false)
 134   MODULES_FILTER += jdk.hotspot.agent
 135 endif
 136 
 137 ################################################################################
 138 # Module list macros
 139 
 140 # Use append so that the custom extension may add to this variable
 141 
 142 ALL_TOP_SRC_DIRS += \
 143     $(HOTSPOT_TOPDIR)/src \
 144     $(JDK_TOPDIR)/src \
 145     $(LANGTOOLS_TOPDIR)/src \
 146     $(CORBA_TOPDIR)/src \
 147     $(JAXP_TOPDIR)/src \
 148     $(JAXWS_TOPDIR)/src \
 149     $(NASHORN_TOPDIR)/src \
 150     #
 151 
 152 # Find all module-info.java files for the current build target platform and
 153 # configuration.
 154 # Param 1 - Module to find for, set to * for finding all
 155 FindAllModuleInfos = \
 156     $(wildcard \
 157         $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
 158         $(patsubst %,%/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
 159         $(patsubst %,%/$(strip $1)/share/classes/module-info.java, $(ALL_TOP_SRC_DIRS)) \
 160         $(patsubst %,%/$(strip $1)/module-info.java, $(IMPORT_MODULES_SRC)))
 161 
 162 # Extract the module names from the paths of module-info.java files. The
 163 # position of the module directory differs depending on if this is an imported
 164 # src dir or not.
 165 GetModuleNameFromModuleInfo = \
 166     $(strip $(foreach mi, $1, \
 167       $(if $(filter $(addsuffix %, $(IMPORT_MODULES_SRC)), $(mi)), \
 168         $(notdir $(patsubst %/,%, $(dir $(mi)))), \
 169         $(notdir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(patsubst %/,%, $(dir $(mi)))))))))))
 170 
 171 # Find all modules by looking for module-info.java files and looking at parent
 172 # directories.
 173 FindAllModules = \
 174     $(sort $(filter-out $(MODULES_FILTER), \
 175     $(call GetModuleNameFromModuleInfo, $(MODULE_INFOS))))
 176 
 177 FindImportedModules = \
 178     $(if $(IMPORT_MODULES_CLASSES), $(notdir $(wildcard $(IMPORT_MODULES_CLASSES)/*)))
 179 
 180 ################################################################################
 181 # Extract module dependencies from module-info.java files.
 182 
 183 MODULE_DEPS_MAKEFILE := $(MAKESUPPORT_OUTPUTDIR)/module-deps.gmk
 184 
 185 MODULE_INFOS := $(call FindAllModuleInfos, *)
 186 
 187 $(MODULE_DEPS_MAKEFILE): $(MODULE_INFOS) \
 188     $(call DependOnVariable, MODULE_INFOS, $(MAKESUPPORT_OUTPUTDIR)/MODULE_INFOS.vardeps)
 189         $(MKDIR) -p $(@D)
 190         $(RM) $@
 191         $(foreach m, $(MODULE_INFOS), \
 192             ( $(PRINTF) "DEPS_$(call GetModuleNameFromModuleInfo, $m) :=" && \
 193               $(NAWK) -v MODULE=$(call GetModuleNameFromModuleInfo, $m) '\
 194                   BEGIN      { if (MODULE != "java.base") printf(" java.base"); } \
 195                   /requires/ { sub(/;/, ""); \
 196                                sub(/requires/, ""); \
 197                                sub(/public/, ""); \
 198                                sub(/\/\/.*/, ""); \
 199                                sub(/\/\*.*\*\//, ""); \
 200                                gsub(/ /, ""); \
 201                                printf(" %s", $$0) } \
 202                   END        { printf("\n") }' $m \
 203             ) >> $@ $(NEWLINE))
 204 
 205 -include $(MODULE_DEPS_MAKEFILE)
 206 
 207 # Param 1: Module to find deps for
 208 FindDepsForModule = \
 209   $(DEPS_$(strip $1))
 210 
 211 # Finds transitive dependencies in 3 levels.
 212 # Param 1: Module to find transitive deps for
 213 FindTransitiveDepsForModule = \
 214     $(sort $(call FindDepsForModule, $1) \
 215         $(foreach m, $(call FindDepsForModule, $1), \
 216             $(call FindDepsForModule, $m) \
 217             $(foreach n, $(call FindDepsForModule, $m), \
 218                  $(call FindDepsForModule, $n))))
 219 
 220 ################################################################################
 221 
 222 # Param 1 - Name of module
 223 define ReadSingleImportMetaData
 224     ifneq ($$(wildcard $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties), )
 225       classloader :=
 226       include_in_jre :=
 227       include_in_jdk :=
 228       include $(IMPORT_MODULES_MAKE)/$$(strip $1)/build.properties
 229       ifeq ($$(include_in_jre), true)
 230         JRE_MODULES += $1
 231       endif
 232       ifeq ($$(include_in_jdk), true)
 233         JDK_MODULES += $1
 234       endif
 235       ifeq ($$(classloader), boot)
 236         BOOT_MODULES += $1
 237       else ifeq ($$(classloader), ext)
 238         PLATFORM_MODULES += $1
 239       endif
 240     else
 241       # Default to include in all
 242       JRE_MODULES += $1
 243       JDK_MODULES += $1
 244     endif
 245 endef
 246 
 247 # Reading the imported modules metadata has a cost, so to make it available,
 248 # a makefile needs to eval-call this macro first. After calling this, the
 249 # following variables are populated with data from the imported modules:
 250 # * JRE_MODULES
 251 # * JDK_MODULES
 252 # * BOOT_MODULES
 253 # * PLATFORM_MODULES
 254 # * JRE_TOOL_MODULES
 255 define ReadImportMetaData
 256     IMPORTED_MODULES := $$(call FindImportedModules)
 257     $$(foreach m, $$(IMPORTED_MODULES), \
 258       $$(eval $$(call ReadSingleImportMetaData, $$m)))
 259 endef
 260 
 261 ################################################################################
 262 
 263 endif # _MODULES_GMK