1 # 2 # Copyright (c) 2009, 2010, 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 # 27 # images Target to build jigsaw modules images. 28 # 29 # This target will build the modules images taking the jdk modules 30 # under the $outputdir/modules directory. For incremental build, 31 # make sure that $outputdir/modules is up-to-date (i.e. build 32 # make/modules/Makefile before invoking the "modules" target). 33 # 34 # The following modules images are created: 35 # 36 # jre-base-image: Minimal Java runtime environment 37 # jre-module-image: Full Java runtime environment with all JRE modules 38 # installed 39 # jdk-module-image: jre-module-image with all JDK modules installed 40 # i.e. full Java development kit 41 # 42 # TODO: we may not need jdk-base-image to build. It is for 43 # convenience for the base image testing that at least 44 # needs javac in it. 45 # 46 # jdk-base-image: jre-base-image with the language tool modules 47 # installed. 48 # 49 # 50 MODULE_IMAGES_DIR = $(ABS_OUTPUTDIR) 51 JDK_MODULE_IMAGE_DIR = $(MODULE_IMAGES_DIR)/jdk-module-image 52 JRE_MODULE_IMAGE_DIR = $(MODULE_IMAGES_DIR)/jre-module-image 53 JDK_BASE_IMAGE_DIR = $(MODULE_IMAGES_DIR)/jdk-base-image 54 JRE_BASE_IMAGE_DIR = $(MODULE_IMAGES_DIR)/jre-base-image 55 56 # 57 # TODO: 58 # 1. Any other sanity check to perform? 59 # 2. Trim out any extra files not for the jre shipment. 60 # (Note the jdk WILL want the jre image before this trimming) 61 # 3. Post process the image (strips and mcs on Elf files we are shipping) 62 # (Note the jdk WILL want the jre image before this processing) 63 # 4. Sign security jars and export policy files 64 # 5. Java DB, demos/samples module not installed yet 65 # 6. man pages - should go in the module of the tool? 66 # 67 # Open issues that need further investigation: 68 # 1. Classes in jre/lib/ext/dnsns.jar are currently put in jre/lib/jndi-dns 69 # module. META-INF/services file is not installed. 70 # 2. Signed jars 71 # For JDK build, signed jars are copied to the build. 72 # All jars in the module image are unsigned. 73 # 3. sparcv9 image is installed on top of a sparc image 74 75 # 76 # Targets. 77 # 78 MODULE_TARGET_SUFFIX= 79 ifeq ($(PLATFORM), solaris) 80 ifeq ($(ARCH_DATA_MODEL), 64) 81 MODULE_TARGET_SUFFIX=-sol64 82 endif 83 endif 84 85 images modules modules-clobber:: 86 @$(ECHO) ">>>Making "$@" @ `$(DATE)` ..." 87 88 images:: modules 89 90 # 91 # jdk-xxx-image depends on jre-xxx-image 92 # 93 # Build jdk-xxx-image target before jre-xxx-image target 94 # so that jre-xxx-image will be made only once 95 # 96 modules:: sanity-images post-sanity-images \ 97 $(EXPORT_BINARY_PLUGS) \ 98 gen-pkgs \ 99 jdk-base-image$(MODULE_TARGET_SUFFIX) \ 100 jre-base-image$(MODULE_TARGET_SUFFIX) \ 101 jdk-module-image$(MODULE_TARGET_SUFFIX) \ 102 jre-module-image$(MODULE_TARGET_SUFFIX) \ 103 post-image-build 104 105 # JDK files 106 $(JDK_BASE_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/% 107 $(process-doc-file) 108 109 # JRE files 110 $(JRE_BASE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/% 111 $(process-doc-file) 112 113 # Add $(TEXT_SUFFIX) suffix 114 ifdef TEXT_SUFFIX 115 $(JRE_BASE_IMAGE_DIR)/%$(TEXT_SUFFIX): $(SHARE_JRE_DOC_SRC)/% 116 $(process-doc-file) 117 endif 118 119 # JDK files 120 $(JDK_MODULE_IMAGE_DIR)/%: $(SHARE_JDK_DOC_SRC)/% 121 $(process-doc-file) 122 123 124 # JRE files 125 $(JRE_MODULE_IMAGE_DIR)/%: $(SHARE_JRE_DOC_SRC)/% 126 $(process-doc-file) 127 128 ifeq ($(PLATFORM), windows) 129 $(JRE_BASE_IMAGE_DIR)/README.txt: $(SHARE_JRE_DOC_SRC)/README 130 $(process-doc-file) 131 $(JRE_MODULE_IMAGE_DIR)/README.txt: $(SHARE_JRE_DOC_SRC)/README 132 $(process-doc-file) 133 endif 134 135 # 136 # Create a module library for the specified image location 137 define create-module-library 138 image=$(strip $1); \ 139 mlib=$(MODULE_IMAGES_DIR)/$$image/lib/modules; \ 140 $(ECHO) "Creating module library $$mlib" ; \ 141 $(HOST_JMOD_CMD) create -N $(JMOD_CREATE_ARGS) -L $$mlib 142 endef 143 144 # Copy module content to the module image 145 # $1 - image location 146 # $2 - module name 147 # 148 define copy-module-content 149 image=$(strip $1); m=$(strip $2); \ 150 javahome=$(MODULE_IMAGES_DIR)/$$image; \ 151 for d in bin lib ; do \ 152 if [ -d $$m/$$d ] ; then \ 153 $(CP) -rf $(ABS_MODULEPATH_DIR)/$$m/$$d $$javahome; \ 154 fi ; \ 155 done 156 endef 157 158 # 159 # Copy JRE image to the dest 160 # $1 - jre image location 161 # $2 - dest location 162 # 163 # Shall investigate if we can eliminate the dependency on this special 164 # copy of the lib/dll files. 165 # Probably better to copy these files to part of the jdk.base.tools module 166 # Also, need to copy jawt.lib. 167 # 168 # Should *_SUFFIX variable either have "." or not dot? 169 # 170 define copy-jre-image 171 from=$(strip $1); dest=$(strip $2); \ 172 ($(CD) $(MODULE_IMAGES_DIR)/$$from && $(FIND) . -depth -print \ 173 | $(CPIO) -pdum $(MODULE_IMAGES_DIR)/$$dest) ; \ 174 if [ -d "$(ABS_MODULEPATH_DIR)/jdk.boot/include" ] ; then \ 175 $(CP) -rf $(ABS_MODULEPATH_DIR)/jdk.boot/include $(MODULE_IMAGES_DIR)/$$dest; \ 176 fi 177 endef 178 179 # 180 # Install jigsaw module 181 # $1 - image location 182 # $2 - module name 183 define install-jigsaw-module 184 image=$(strip $1); m=$(strip $2); \ 185 mlib=$(MODULE_IMAGES_DIR)/$$image/lib/modules; \ 186 mid=`$(HOST_JMOD_CMD) ls -L $$mlib $$m | $(GREP) -v '#'` ; \ 187 if [ "x$$mid" = "x" ] ; then \ 188 $(ECHO) "Installing module $$m in $$image" ; \ 189 $(CD) $(ABS_MODULEPATH_DIR) && \ 190 if [ -d $$m/resources ] ; then \ 191 $(HOST_JMOD_CMD) install $$m/classes -r $$m/resources -L $$mlib $(JMOD_INSTALL_ARGS) $$m || exit 1; \ 192 else \ 193 $(HOST_JMOD_CMD) install $$m/classes -L $$mlib $(JMOD_INSTALL_ARGS) $$m || exit 1; \ 194 fi ; \ 195 $(call copy-module-content,$1,$2) ; \ 196 else \ 197 $(ECHO) "Module $$m already installed in $$image" ; \ 198 fi 199 endef 200 201 202 # Rules for building packages 203 include $(BUILDDIR)/common/BuildNativePackages.gmk 204 205 PKG_TYPES = jmod-pkgs 206 DEBIAN := $(shell \ 207 if [ -f /etc/debian_version ] ; then \ 208 $(ECHO) true; \ 209 else \ 210 $(ECHO) false; \ 211 fi) 212 213 214 # set BUILD_PACKAGES=false to skip building jmod and native packages 215 # 216 ifeq ($(BUILD_PACKAGES), false) 217 PKG_TYPES = 218 DEBIAN = false 219 endif 220 221 ifeq ($(DEBIAN), true) 222 PKG_TYPES += deb-pkgs 223 endif 224 225 gen-pkgs: $(PKG_TYPES) 226 227 228 %-setup: 229 $(RM) -r $(MODULE_IMAGES_DIR)/$* 230 $(MKDIR) $(MODULE_IMAGES_DIR)/$* 231 232 jdk-base-image: jre-base-image \ 233 jdk-base-image-setup \ 234 jdk-base-image-docfiles 235 $(call copy-jre-image,jre-base-image,$@) 236 @for jm in `$(NAWK) '{print $$1}' $(JDK_BASE_MODULES)` ; do \ 237 $(call install-jigsaw-module,$@,$$jm) ; \ 238 done 239 240 jre-base-image: jre-base-image-setup \ 241 jre-base-image-docfiles 242 $(call create-module-library,$@) 243 @for jm in `$(NAWK) '{print $$1}' $(JRE_BASE_MODULES)` ; do \ 244 $(call install-jigsaw-module,$@,$$jm) ; \ 245 done 246 247 # 64-bit solaris jre image contains only the 64-bit add-on files. 248 # FIXME: should there be two sets of modules (one for sparc and one for sparcv9)? 249 jdk-base-image-sol64: jre-base-image-sol64 \ 250 jdk-base-image-setup 251 @# Temporary workaround - install sparcv9 modules 252 $(call copy-jre-image,jre-base-image,jdk-base-image) 253 @for jm in `$(NAWK) '{print $$1}' $(JDK_BASE_MODULES)` ; do \ 254 $(call install-jigsaw-module,jdk-base-image,$$jm) ; \ 255 done 256 257 jre-base-image-sol64: jre-base-image-setup 258 @# Temporary workaround - install sparcv9 modules 259 $(call create-module-library,jre-base-image) 260 @for jm in `$(NAWK) '{print $$1}' $(JRE_BASE_MODULES)` ; do \ 261 $(call install-jigsaw-module,jre-base-image,$$jm) ; \ 262 done 263 264 jdk-base-image-docfiles: $(IMAGE_DOCLIST_JDK:%=$(JDK_BASE_IMAGE_DIR)/%) 265 266 jre-base-image-docfiles: $(IMAGE_DOCLIST_JRE:%=$(JRE_BASE_IMAGE_DIR)/%) 267 268 jdk-module-image: jre-module-image \ 269 jdk-module-image-setup \ 270 jdk-module-image-docfiles 271 $(call copy-jre-image,jre-module-image,$@) 272 @for jm in `$(NAWK) '{print $$1}' $(JDK_MODULES)` ; do \ 273 $(call install-jigsaw-module,$@,$$jm); \ 274 done 275 276 jre-module-image: jre-module-image-setup \ 277 jre-module-image-docfiles 278 $(call create-module-library,$@) 279 @for jm in `$(NAWK) '{print $$1}' $(JRE_MODULES)` ; do \ 280 $(call install-jigsaw-module,$@,$$jm); \ 281 done 282 283 # 64-bit solaris jre image contains only the 64-bit add-on files. 284 # FIXME: should there be two sets of modules (one for sparc and one for sparcv9)? 285 jdk-module-image-sol64: jre-module-image-sol64 \ 286 jdk-module-image-setup \ 287 jdk-module-image-docfiles 288 @# Temporary workaround - install sparcv9 modules 289 $(call copy-jre-image,jre-module-image,jdk-module-image) 290 @for jm in `$(NAWK) '{print $$1}' $(JDK_MODULES)` ; do \ 291 $(call install-jigsaw-module,jdk-module-image,$$jm); \ 292 done 293 294 jre-module-image-sol64: jre-module-image-setup \ 295 jre-module-image-docfiles 296 @# Temporary workaround - install sparcv9 modules 297 $(call create-module-library,jre-module-image) 298 @for jm in `$(NAWK) '{print $$1}' $(JRE_MODULES)` ; do \ 299 $(call install-jigsaw-module,jre-module-image,$$jm); \ 300 done 301 302 jdk-module-image-docfiles: $(IMAGE_DOCLIST_JDK:%=$(JDK_MODULE_IMAGE_DIR)/%) 303 304 jre-module-image-docfiles: $(IMAGE_DOCLIST_JRE:%=$(JRE_MODULE_IMAGE_DIR)/%) 305 306 post-image-build: 307 @# Make sure all directories are read/execute for everyone 308 @# chmod complains arg list too long; so do it one by one 309 $(CHMOD) a+rx `$(FIND) $(JDK_BASE_IMAGE_DIR) -type d` 310 $(CHMOD) a+rx `$(FIND) $(JRE_BASE_IMAGE_DIR) -type d` 311 $(CHMOD) a+rx `$(FIND) $(JDK_MODULE_IMAGE_DIR) -type d` 312 $(CHMOD) a+rx `$(FIND) $(JRE_MODULE_IMAGE_DIR) -type d` 313 314 ###################################################### 315 # clobber 316 ###################################################### 317 modules-clobber:: 318 $(RM) -r $(MODULE_IMAGES_DIR) 319 320 images modules modules-clobber:: 321 @$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..." 322 @$(java-vm-cleanup) 323 324 .PHONY: modules modules-clobber gen-pkgs \ 325 jre-base-image$(MODULE_TARGET_SUFFIX) \ 326 jdk-base-image$(MODULE_TARGET_SUFFIX) \ 327 jre-module-image$(MODULE_TARGET_SUFFIX) \ 328 jdk-module-image$(MODULE_TARGET_SUFFIX) 329 330 # Force rule 331 FRC: 332 --- EOF ---