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 # On Windows dll's are installed into the same direcory as native cmds 137 ifeq ($(PLATFORM), windows) 138 NATLIBS_DIR=bin 139 else 140 NATLIBS_DIR=lib/$(LIBARCH) 141 endif 142 143 # 144 # Create a module library for the specified image location 145 define create-module-library 146 image=$(strip $1); \ 147 mlib=$(MODULE_IMAGES_DIR)/$$image/lib/modules; \ 148 natlib=$(MODULE_IMAGES_DIR)/$$image/$(NATLIBS_DIR); \ 149 natcmd=$(MODULE_IMAGES_DIR)/$$image/bin; \ 150 config=$(MODULE_IMAGES_DIR)/$$image/lib; \ 151 $(ECHO) "Creating module library $$mlib" ; \ 152 $(HOST_JMOD_CMD) create -N $(JMOD_CREATE_ARGS) -L $$mlib \ 153 --natlib $$natlib --natcmd $$natcmd --config $$config 154 endef 155 156 # Copy module content to the module image 157 # $1 - image location 158 # $2 - module name 159 # 160 define copy-module-content 161 image=$(strip $1); m=$(strip $2); \ 162 javahome=$(MODULE_IMAGES_DIR)/$$image; \ 163 natlib=$(MODULE_IMAGES_DIR)/$$image/$(NATLIBS_DIR); \ 164 natcmd=$(MODULE_IMAGES_DIR)/$$image/bin; \ 165 config=$(MODULE_IMAGES_DIR)/$$image/lib; \ 166 if [ -d $$m/bin ] ; then \ 167 $(CP) -rf $(ABS_MODULEPATH_DIR)/$$m/bin/* $$natcmd; \ 168 fi ; \ 169 if [ -d $$m/lib ] ; then \ 170 $(CP) -rf $(ABS_MODULEPATH_DIR)/$$m/lib/* $$natlib; \ 171 fi ; \ 172 if [ -d $$m/etc ] ; then \ 173 $(CP) -rf $(ABS_MODULEPATH_DIR)/$$m/etc/* $$config; \ 174 fi 175 endef 176 177 # 178 # Copy JRE image to the dest 179 # $1 - jre image location 180 # $2 - dest location 181 # 182 # Shall investigate if we can eliminate the dependency on this special 183 # copy of the lib/dll files. 184 # Probably better to copy these files to part of the jdk.base.tools module 185 # Also, need to copy jawt.lib. 186 # 187 # Should *_SUFFIX variable either have "." or not dot? 188 # 189 define copy-jre-image 190 from=$(strip $1); dest=$(strip $2); \ 191 ($(CD) $(MODULE_IMAGES_DIR)/$$from && $(FIND) . -depth -print \ 192 | $(CPIO) -pdum $(MODULE_IMAGES_DIR)/$$dest) ; \ 193 if [ -d "$(ABS_MODULEPATH_DIR)/jdk.base/include" ] ; then \ 194 $(CP) -rf $(ABS_MODULEPATH_DIR)/jdk.base/include $(MODULE_IMAGES_DIR)/$$dest; \ 195 fi 196 endef 197 198 # 199 # Install jigsaw module 200 # Install from the jmod file, if it has been created (see BUILD_PACKAGES) 201 # $1 - image location 202 # $2 - module name 203 define install-jigsaw-module 204 image=$(strip $1); m=$(strip $2); \ 205 mlib=$(MODULE_IMAGES_DIR)/$$image/lib/modules; \ 206 mid=`$(HOST_JMOD_CMD) ls -L $$mlib $$m | $(GREP) -v '#'` ; \ 207 jmodfile=$(ABS_OUTPUTDIR)/jigsaw-pkgs/jmod/$$m@$(MODULE_VERSION).jmod ; \ 208 if [ "x$$mid" = "x" ] ; then \ 209 $(CD) $(ABS_MODULEPATH_DIR) && \ 210 if [ -f $$jmodfile ] ; then \ 211 $(ECHO) "Installing module $$m in $$image, from $$jmodfile" ; \ 212 $(HOST_JMOD_CMD) install $$jmodfile -L $$mlib || exit 1; \ 213 else \ 214 $(ECHO) "Installing module $$m in $$image, from $$m/classes and copy" ; \ 215 $(HOST_JMOD_CMD) install $$m/classes -L $$mlib $(JMOD_INSTALL_ARGS) $$m || exit 1; \ 216 $(call copy-module-content,$1,$2) ; \ 217 fi ; \ 218 else \ 219 $(ECHO) "Module $$m already installed in $$image" ; \ 220 fi 221 endef 222 223 # Rules for building packages 224 include $(BUILDDIR)/common/BuildNativePackages.gmk 225 226 # set BUILD_PACKAGES=false to skip building jmod packages 227 # 228 PKG_TYPES = jmod-pkgs 229 ifeq ($(BUILD_PACKAGES), false) 230 PKG_TYPES = 231 endif 232 233 DEBIAN := $(shell \ 234 if [ -f /etc/debian_version ] ; then \ 235 $(ECHO) true; \ 236 else \ 237 $(ECHO) false; \ 238 fi) 239 240 # FIXME: turn on building debian packages by default once 241 # the debian-related issues are fixed (e.g. views, version). 242 # 243 BUILD_NATIVE_PACKAGES=false 244 245 # set BUILD_NATIVE_PACKAGES=false to skip building native packages 246 # 247 ifeq ($(BUILD_NATIVE_PACKAGES), false) 248 DEBIAN = false 249 endif 250 251 ifeq ($(DEBIAN), true) 252 PKG_TYPES += deb-pkgs 253 endif 254 255 gen-pkgs: $(PKG_TYPES) 256 257 %-setup: 258 $(RM) -r $(MODULE_IMAGES_DIR)/$* 259 $(MKDIR) $(MODULE_IMAGES_DIR)/$* 260 261 jdk-base-image: jre-base-image \ 262 jdk-base-image-setup \ 263 jdk-base-image-docfiles 264 $(call copy-jre-image,jre-base-image,$@) 265 @for jm in `$(NAWK) '{print $$1}' $(JDK_BASE_MODULES)` ; do \ 266 $(call install-jigsaw-module,$@,$$jm) ; \ 267 done 268 269 jre-base-image: jre-base-image-setup \ 270 jre-base-image-docfiles 271 $(call create-module-library,$@) 272 @for jm in `$(NAWK) '{print $$1}' $(JRE_BASE_MODULES)` ; do \ 273 $(call install-jigsaw-module,$@,$$jm) ; \ 274 done 275 276 # 64-bit solaris jre image contains only the 64-bit add-on files. 277 # FIXME: should there be two sets of modules (one for sparc and one for sparcv9)? 278 jdk-base-image-sol64: jre-base-image-sol64 \ 279 jdk-base-image-setup 280 @# Temporary workaround - install sparcv9 modules 281 $(call copy-jre-image,jre-base-image,jdk-base-image) 282 @for jm in `$(NAWK) '{print $$1}' $(JDK_BASE_MODULES)` ; do \ 283 $(call install-jigsaw-module,jdk-base-image,$$jm) ; \ 284 done 285 286 jre-base-image-sol64: jre-base-image-setup 287 @# Temporary workaround - install sparcv9 modules 288 $(call create-module-library,jre-base-image) 289 @for jm in `$(NAWK) '{print $$1}' $(JRE_BASE_MODULES)` ; do \ 290 $(call install-jigsaw-module,jre-base-image,$$jm) ; \ 291 done 292 293 jdk-base-image-docfiles: $(IMAGE_DOCLIST_JDK:%=$(JDK_BASE_IMAGE_DIR)/%) 294 295 jre-base-image-docfiles: $(IMAGE_DOCLIST_JRE:%=$(JRE_BASE_IMAGE_DIR)/%) 296 297 jdk-module-image: jre-module-image \ 298 jdk-module-image-setup \ 299 jdk-module-image-docfiles 300 $(call copy-jre-image,jre-module-image,$@) 301 @for jm in `$(NAWK) '{print $$1}' $(JDK_MODULES)` ; do \ 302 $(call install-jigsaw-module,$@,$$jm); \ 303 done 304 305 jre-module-image: jre-module-image-setup \ 306 jre-module-image-docfiles 307 $(call create-module-library,$@) 308 @for jm in `$(NAWK) '{print $$1}' $(JRE_MODULES)` ; do \ 309 $(call install-jigsaw-module,$@,$$jm); \ 310 done 311 312 # 64-bit solaris jre image contains only the 64-bit add-on files. 313 # FIXME: should there be two sets of modules (one for sparc and one for sparcv9)? 314 jdk-module-image-sol64: jre-module-image-sol64 \ 315 jdk-module-image-setup \ 316 jdk-module-image-docfiles 317 @# Temporary workaround - install sparcv9 modules 318 $(call copy-jre-image,jre-module-image,jdk-module-image) 319 @for jm in `$(NAWK) '{print $$1}' $(JDK_MODULES)` ; do \ 320 $(call install-jigsaw-module,jdk-module-image,$$jm); \ 321 done 322 323 jre-module-image-sol64: jre-module-image-setup \ 324 jre-module-image-docfiles 325 @# Temporary workaround - install sparcv9 modules 326 $(call create-module-library,jre-module-image) 327 @for jm in `$(NAWK) '{print $$1}' $(JRE_MODULES)` ; do \ 328 $(call install-jigsaw-module,jre-module-image,$$jm); \ 329 done 330 331 jdk-module-image-docfiles: $(IMAGE_DOCLIST_JDK:%=$(JDK_MODULE_IMAGE_DIR)/%) 332 333 jre-module-image-docfiles: $(IMAGE_DOCLIST_JRE:%=$(JRE_MODULE_IMAGE_DIR)/%) 334 335 post-image-build: 336 @# Make sure all directories are read/execute for everyone 337 @# chmod complains arg list too long; so do it one by one 338 $(CHMOD) a+rx `$(FIND) $(JDK_BASE_IMAGE_DIR) -type d` 339 $(CHMOD) a+rx `$(FIND) $(JRE_BASE_IMAGE_DIR) -type d` 340 $(CHMOD) a+rx `$(FIND) $(JDK_MODULE_IMAGE_DIR) -type d` 341 $(CHMOD) a+rx `$(FIND) $(JRE_MODULE_IMAGE_DIR) -type d` 342 343 ###################################################### 344 # clobber 345 ###################################################### 346 modules-clobber:: 347 $(RM) -r $(MODULE_IMAGES_DIR) 348 349 images modules modules-clobber:: 350 @$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..." 351 @$(java-vm-cleanup) 352 353 .PHONY: modules modules-clobber gen-pkgs \ 354 jre-base-image$(MODULE_TARGET_SUFFIX) \ 355 jdk-base-image$(MODULE_TARGET_SUFFIX) \ 356 jre-module-image$(MODULE_TARGET_SUFFIX) \ 357 jdk-module-image$(MODULE_TARGET_SUFFIX) 358 359 # Force rule 360 FRC: 361