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 --natlib $$mlib/.. --natcmd $$mlib/../../bin --config $$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 # Install from the jmod file, if it has been created (see BUILD_PACKAGES)
 182 #   $1 - image location
 183 #   $2 - module name
 184 define install-jigsaw-module
 185 image=$(strip $1); m=$(strip $2); \
 186 mlib=$(MODULE_IMAGES_DIR)/$$image/lib/modules; \
 187 mid=`$(HOST_JMOD_CMD) ls -L $$mlib $$m | $(GREP) -v '#'` ; \
 188 jmodfile=$(ABS_OUTPUTDIR)/jigsaw-pkgs/jmod/$$m@$(MODULE_VERSION).jmod ; \
 189 if [ "x$$mid" = "x" ] ; then \
 190    $(CD) $(ABS_MODULEPATH_DIR) && \
 191    if [ -f $$jmodfile ] ; then \
 192       $(ECHO) "Installing module $$m in $$image, from $$jmodfile" ; \
 193       $(HOST_JMOD_CMD) install $$jmodfile -L $$mlib || exit 1; \
 194    else \
 195       $(ECHO) "Installing module $$m in $$image, from $$m/classes and copy" ; \
 196       $(HOST_JMOD_CMD) install $$m/classes -L $$mlib $(JMOD_INSTALL_ARGS) $$m || exit 1; \
 197       $(call copy-module-content,$1,$2) ; \
 198    fi ; \
 199 else \
 200    $(ECHO) "Module $$m already installed in $$image" ; \
 201 fi
 202 endef
 203 
 204 
 205 # Rules for building packages
 206 include $(BUILDDIR)/common/BuildNativePackages.gmk
 207 
 208 PKG_TYPES = jmod-pkgs
 209 DEBIAN := $(shell \
 210                if [ -f /etc/debian_version ] ; then \
 211                   $(ECHO) true; \
 212                else \
 213                   $(ECHO) false; \
 214                fi)
 215 
 216 
 217 # set BUILD_PACKAGES=false to skip building jmod and native packages
 218 #
 219 ifeq ($(BUILD_PACKAGES), false)
 220 PKG_TYPES =
 221 DEBIAN = false
 222 endif
 223 
 224 ifeq ($(DEBIAN), true)
 225 PKG_TYPES += deb-pkgs
 226 endif
 227 
 228 gen-pkgs: $(PKG_TYPES)
 229 
 230 
 231 %-setup:
 232         $(RM) -r $(MODULE_IMAGES_DIR)/$*
 233         $(MKDIR) $(MODULE_IMAGES_DIR)/$*
 234 
 235 jdk-base-image: jre-base-image \
 236                 jdk-base-image-setup \
 237                 jdk-base-image-docfiles
 238         $(call copy-jre-image,jre-base-image,$@)
 239         @for jm in `$(NAWK) '{print $$1}' $(JDK_BASE_MODULES)` ; do \
 240             $(call install-jigsaw-module,$@,$$jm) ; \
 241         done
 242 
 243 jre-base-image: jre-base-image-setup \
 244                 jre-base-image-docfiles
 245         $(call create-module-library,$@)
 246         @for jm in `$(NAWK) '{print $$1}' $(JRE_BASE_MODULES)` ; do \
 247             $(call install-jigsaw-module,$@,$$jm) ; \
 248         done
 249 
 250 # 64-bit solaris jre image contains only the 64-bit add-on files.
 251 # FIXME: should there be two sets of modules (one for sparc and one for sparcv9)?
 252 jdk-base-image-sol64: jre-base-image-sol64 \
 253                       jdk-base-image-setup
 254         @# Temporary workaround - install sparcv9 modules
 255         $(call copy-jre-image,jre-base-image,jdk-base-image)
 256         @for jm in `$(NAWK) '{print $$1}' $(JDK_BASE_MODULES)` ; do \
 257             $(call install-jigsaw-module,jdk-base-image,$$jm) ; \
 258         done
 259 
 260 jre-base-image-sol64: jre-base-image-setup
 261         @# Temporary workaround - install sparcv9 modules
 262         $(call create-module-library,jre-base-image)
 263         @for jm in `$(NAWK) '{print $$1}' $(JRE_BASE_MODULES)` ; do \
 264             $(call install-jigsaw-module,jre-base-image,$$jm) ; \
 265         done
 266 
 267 jdk-base-image-docfiles: $(IMAGE_DOCLIST_JDK:%=$(JDK_BASE_IMAGE_DIR)/%)
 268 
 269 jre-base-image-docfiles: $(IMAGE_DOCLIST_JRE:%=$(JRE_BASE_IMAGE_DIR)/%)
 270 
 271 jdk-module-image: jre-module-image \
 272                   jdk-module-image-setup \
 273                   jdk-module-image-docfiles
 274         $(call copy-jre-image,jre-module-image,$@)
 275         @for jm in `$(NAWK) '{print $$1}' $(JDK_MODULES)` ; do \
 276             $(call install-jigsaw-module,$@,$$jm); \
 277         done
 278 
 279 jre-module-image: jre-module-image-setup \
 280                   jre-module-image-docfiles
 281         $(call create-module-library,$@)
 282         @for jm in `$(NAWK) '{print $$1}' $(JRE_MODULES)` ; do \
 283             $(call install-jigsaw-module,$@,$$jm); \
 284         done
 285 
 286 # 64-bit solaris jre image contains only the 64-bit add-on files.
 287 # FIXME: should there be two sets of modules (one for sparc and one for sparcv9)?
 288 jdk-module-image-sol64: jre-module-image-sol64 \
 289                         jdk-module-image-setup \
 290                         jdk-module-image-docfiles
 291         @# Temporary workaround - install sparcv9 modules
 292         $(call copy-jre-image,jre-module-image,jdk-module-image)
 293         @for jm in `$(NAWK) '{print $$1}' $(JDK_MODULES)` ; do \
 294             $(call install-jigsaw-module,jdk-module-image,$$jm); \
 295         done
 296 
 297 jre-module-image-sol64: jre-module-image-setup \
 298                         jre-module-image-docfiles
 299         @# Temporary workaround - install sparcv9 modules
 300         $(call create-module-library,jre-module-image)
 301         @for jm in `$(NAWK) '{print $$1}' $(JRE_MODULES)` ; do \
 302             $(call install-jigsaw-module,jre-module-image,$$jm); \
 303         done
 304 
 305 jdk-module-image-docfiles: $(IMAGE_DOCLIST_JDK:%=$(JDK_MODULE_IMAGE_DIR)/%)
 306 
 307 jre-module-image-docfiles: $(IMAGE_DOCLIST_JRE:%=$(JRE_MODULE_IMAGE_DIR)/%)
 308 
 309 post-image-build:
 310         @# Make sure all directories are read/execute for everyone
 311         @# chmod complains arg list too long; so do it one by one
 312         $(CHMOD) a+rx `$(FIND) $(JDK_BASE_IMAGE_DIR) -type d`
 313         $(CHMOD) a+rx `$(FIND) $(JRE_BASE_IMAGE_DIR) -type d`
 314         $(CHMOD) a+rx `$(FIND) $(JDK_MODULE_IMAGE_DIR) -type d`
 315         $(CHMOD) a+rx `$(FIND) $(JRE_MODULE_IMAGE_DIR) -type d`
 316 
 317 ######################################################
 318 # clobber
 319 ######################################################
 320 modules-clobber::
 321         $(RM) -r $(MODULE_IMAGES_DIR)
 322 
 323 images modules modules-clobber::
 324         @$(ECHO) ">>>Finished making "$@" @ `$(DATE)` ..."
 325         @$(java-vm-cleanup)
 326 
 327 .PHONY: modules modules-clobber gen-pkgs \
 328         jre-base-image$(MODULE_TARGET_SUFFIX) \
 329         jdk-base-image$(MODULE_TARGET_SUFFIX) \
 330         jre-module-image$(MODULE_TARGET_SUFFIX) \
 331         jdk-module-image$(MODULE_TARGET_SUFFIX)
 332 
 333 # Force rule
 334 FRC:
 335