1 #
   2 # Copyright (c) 2011, 2012, 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 include $(SPEC)
  27 include MakeBase.gmk
  28 include JavaCompilation.gmk
  29 include Setup.gmk
  30 
  31 default: images
  32 
  33 include Tools.gmk
  34 
  35 include Profiles.gmk
  36 
  37 # Note: This double-colon rule is intentional, to support
  38 # custom make file integration.
  39 images:: jre-image jdk-image
  40 
  41 overlay-images: jre-overlay-image jdk-overlay-image
  42 
  43 
  44 -include $(CUSTOM_MAKE_DIR)/Images.gmk
  45 
  46 
  47 # Processing license files from source area to image area
  48 # These will be modified to have the platform specific EOL chars.
  49 define process-doc-file
  50         $(ECHO) $(LOG_INFO) Processing $(patsubst $(OUTPUT_ROOT)/%,%,$@)
  51         $(MKDIR) -p $(@D)
  52         $(RM) $@
  53         $(SED) 's/$$//g' $< > $@
  54         $(CHMOD) 444 $@
  55 endef
  56 
  57 define AddFileToCopy
  58   # Param 1 - src root dir
  59   # Param 2 - dest root dir
  60   # Param 3 - src file
  61   # Param 4 - variable to add targets to
  62 
  63   # Remove src dir root from src file
  64   $2_$3_FILE := $$(patsubst $1/%,%,$3)
  65 
  66   $2/$$($2_$3_FILE): $3
  67         $(ECHO) $(LOG_INFO) Copying $$(patsubst $(OUTPUT_ROOT)/%,%,$$@)
  68         $$(install-file)
  69 
  70   $4 += $2/$$($2_$3_FILE)
  71 endef
  72 
  73 JDK_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2sdk-image
  74 JRE_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2re-image
  75 
  76 JDK_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2sdk-overlay-image
  77 JRE_OVERLAY_IMAGE_DIR:=$(IMAGES_OUTPUTDIR)/j2re-overlay-image
  78 
  79 ################################################################################
  80 #
  81 # JRE and JDK build rules
  82 #
  83 ################################################################################
  84 #
  85 # Variable prefixes explained:
  86 # JRE_ refers to files in the j2re-*-image.
  87 # JDK_ refers to files in the j2sdk-image outside of the jre subdir.
  88 # JDKJRE_ refers to files in the j2sdk-image inside the jre subdir.
  89 #
  90 
  91 ################################################################################
  92 # /bin dir
  93 
  94 WINDOWS_JDK_BIN_FILES = \
  95         $(EXE_SUFFIX) \
  96         $(LIBRARY_PREFIX)jli$(SHARED_LIBRARY_SUFFIX) \
  97         $(notdir $(MSVCR_DLL))
  98 
  99 WINDOWS_JDKJRE_BIN_FILES := \
 100         $(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) \
 101         $(SALIB_NAME)
 102 
 103 # Find all files in bin dir
 104 ALL_BIN_LIST := $(shell $(FIND) $(JDK_OUTPUTDIR)/bin -type f)
 105 
 106 # Prevent sjavac from entering the images.
 107 ALL_BIN_LIST := $(filter-out %/sjavac,$(ALL_BIN_LIST))
 108 
 109 # For unknown reason the debuginfo files for executables are not put into images
 110 # e.g filter them out
 111 ifneq ($(OPENJDK_TARGET_OS),windows)
 112     ALL_BIN_LIST := $(filter-out %.debuginfo %.diz, $(ALL_BIN_LIST))
 113 else
 114 # On windows, the libraries are in the bin dir, only filter out debuginfo files
 115 # for executables. "java" is both a library and executable.
 116     ALL_BIN_EXEC_FILES := $(filter-out java.exe,$(notdir $(shell $(FIND) $(JDK_OUTPUTDIR)/bin -type f -name "*.exe")))
 117     ALL_BIN_DEBUG_FILTER := $(addprefix %,$(patsubst %.exe,%.debuginfo,$(ALL_BIN_EXEC_FILES)) \
 118                                            $(patsubst %.exe,%.diz,$(ALL_BIN_EXEC_FILES))) %.pdb
 119     ALL_BIN_LIST := $(filter-out $(ALL_BIN_DEBUG_FILTER),$(ALL_BIN_LIST))
 120 endif
 121 
 122 JDKJRE_BIN_LIST := $(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES)), $(ALL_BIN_LIST))
 123 JRE_BIN_LIST := $(filter-out $(addprefix %,$(WINDOWS_JDKJRE_BIN_FILES)), $(JDKJRE_BIN_LIST))
 124 
 125 ifeq ($(OPENJDK_TARGET_OS),windows)
 126     JDK_BIN_LIST := $(filter $(addprefix %,$(WINDOWS_JDK_BIN_FILES)), $(ALL_BIN_LIST))
 127     # On windows x86, the server jvm is filtered out from the j2re image. This could possibly 
 128     # be handled by profiles in the future. If no client jvm is built, leave server in.
 129     ifeq ($(OPENJDK_TARGET_CPU),x86)
 130         ifeq ($(JVM_VARIANT_CLIENT),true)
 131             JRE_BIN_LIST := $(filter-out $(JDK_OUTPUTDIR)/bin/server/%,$(JRE_BIN_LIST))
 132         endif
 133     endif
 134 else
 135     JDK_BIN_LIST := $(ALL_BIN_LIST)
 136 endif
 137 
 138 ifneq ($(OPENJDK_TARGET_CPU_ISADIR),)
 139     OVERLAY_FILTER := $(JDK_OUTPUTDIR)/bin$(OPENJDK_TARGET_CPU_ISADIR)%
 140 endif
 141 
 142 $(foreach f,$(filter-out $(OVERLAY_FILTER),$(JRE_BIN_LIST)),\
 143     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JRE_IMAGE_DIR),$f,JRE_BIN_TARGETS)))
 144 $(foreach f,$(filter-out $(OVERLAY_FILTER),$(JDK_BIN_LIST)),\
 145     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_IMAGE_DIR),$f,JDK_BIN_TARGETS)))
 146 $(foreach f,$(filter-out $(OVERLAY_FILTER),$(JDKJRE_BIN_LIST)),\
 147     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_IMAGE_DIR)/jre,$f,JDKJRE_BIN_TARGETS)))
 148 
 149 $(foreach f,$(filter $(OVERLAY_FILTER),$(JRE_BIN_LIST)),\
 150     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JRE_OVERLAY_IMAGE_DIR),$f,JRE_BIN_TARGETS)))
 151 $(foreach f,$(filter $(OVERLAY_FILTER),$(JDK_BIN_LIST)),\
 152     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_OVERLAY_IMAGE_DIR),$f,JDK_BIN_TARGETS)))
 153 $(foreach f,$(filter $(OVERLAY_FILTER),$(JDKJRE_BIN_LIST)),\
 154     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_OVERLAY_IMAGE_DIR)/jre,$f,JDKJRE_BIN_TARGETS)))
 155 
 156 ################################################################################
 157 # /lib dir
 158 ifneq ($(OPENJDK_TARGET_OS), macosx)
 159     JDKJRE_LIB_FILES := \
 160         $(LIBRARY_PREFIX)attach$(SHARED_LIBRARY_SUFFIX) \
 161         $(SALIB_NAME)
 162 endif
 163 
 164 JDK_LIB_FILES := $(NOT_JRE_LIB_FILES)
 165 ifeq ($(OPENJDK_TARGET_OS), linux)
 166     JDK_LIB_FILES += jexec
 167 endif
 168 
 169 # Find all files to copy from $(JDK_OUTPUTDIR)/lib
 170 # Jar files are not expected to be here
 171 ALL_JDKOUT_LIB_LIST := $(shell $(FIND) $(JDK_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \
 172                        \( -name "_the*" -o -name "javac_state " -o -name "*.jar" \) )
 173 # Find all files to copy from $(IMAGES_OUTPUTDIR)/lib
 174 # This is were the jar files are and might not exist if building overlay-images
 175 ifneq ($(wildcard $(IMAGES_OUTPUTDIR)/lib),)
 176     ALL_IMAGES_LIB_LIST := $(shell $(FIND) $(IMAGES_OUTPUTDIR)/lib \( -type f -o -type l \) -a ! \
 177                        \( -name "_the*" -o -name "javac_state " \) )
 178 endif
 179 
 180 # Filter files to copy for each destination
 181 JRE_JDKOUT_LIB_LIST := $(filter-out $(addprefix %,$(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
 182                        $(ALL_JDKOUT_LIB_LIST))
 183 JDKJRE_JDKOUT_LIB_LIST := $(filter-out $(addprefix %,$(NOT_JRE_LIB_FILES)),$(ALL_JDKOUT_LIB_LIST))
 184 JDK_JDKOUT_LIB_LIST := $(filter $(addprefix %,$(JDK_LIB_FILES)),$(ALL_JDKOUT_LIB_LIST))
 185 
 186 JRE_IMAGES_LIB_LIST := $(filter-out $(addprefix %,$(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
 187                        $(ALL_IMAGES_LIB_LIST))
 188 JDKJRE_IMAGES_LIB_LIST := $(filter-out $(addprefix %,$(NOT_JRE_LIB_FILES)),$(ALL_IMAGES_LIB_LIST))
 189 JDK_IMAGES_LIB_LIST := $(filter $(addprefix %,$(JDK_LIB_FILES)),$(ALL_IMAGES_LIB_LIST))
 190 
 191 # Iterate over files to copy to create rules for each one
 192 $(foreach f,$(JRE_JDKOUT_LIB_LIST),\
 193     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JRE_IMAGE_DIR),$f,JRE_LIB_TARGETS)))
 194 $(foreach f,$(JDK_JDKOUT_LIB_LIST),\
 195     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_IMAGE_DIR),$f,JDK_LIB_TARGETS)))
 196 $(foreach f,$(JDKJRE_JDKOUT_LIB_LIST),\
 197     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_IMAGE_DIR)/jre,$f,JDKJRE_LIB_TARGETS)))
 198 
 199 $(foreach f,$(JRE_IMAGES_LIB_LIST),\
 200     $(eval $(call AddFileToCopy,$(IMAGES_OUTPUTDIR),$(JRE_IMAGE_DIR),$f,JRE_LIB_TARGETS)))
 201 $(foreach f,$(JDK_IMAGES_LIB_LIST),\
 202     $(eval $(call AddFileToCopy,$(IMAGES_OUTPUTDIR),$(JDK_IMAGE_DIR),$f,JDK_LIB_TARGETS)))
 203 $(foreach f,$(JDKJRE_IMAGES_LIB_LIST),\
 204     $(eval $(call AddFileToCopy,$(IMAGES_OUTPUTDIR),$(JDK_IMAGE_DIR)/jre,$f,JDKJRE_LIB_TARGETS)))
 205 
 206 $(foreach f,$(filter $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_ISADIR)/%,$(JRE_JDKOUT_LIB_LIST)),\
 207     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JRE_OVERLAY_IMAGE_DIR),$f,JRE_OVERLAY_LIB_TARGETS)))
 208 $(foreach f,$(filter $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_ISADIR)/%,$(JDK_JDKOUT_LIB_LIST)),\
 209     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_OVERLAY_IMAGE_DIR),$f,JDK_OVERLAY_LIB_TARGETS)))
 210 $(foreach f,$(filter $(JDK_OUTPUTDIR)/lib$(OPENJDK_TARGET_CPU_ISADIR)/%,$(JDKJRE_JDKOUT_LIB_LIST)),\
 211     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_OVERLAY_IMAGE_DIR)/jre,$f,JDKJRE_OVERLAY_LIB_TARGETS)))
 212 
 213 # CTE plugin security change require new empty directory lib/applet
 214 $(JRE_IMAGE_DIR)/lib/applet: 
 215         $(ECHO) $(LOG_INFO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 216         $(MKDIR) -p $@
 217 
 218 $(JDK_IMAGE_DIR)/jre/lib/applet: 
 219         $(ECHO) $(LOG_INFO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 220         $(MKDIR) -p $@
 221 
 222 # In the old build, JObjC.jar is not part of the meta-index
 223 $(JRE_IMAGE_DIR)/lib/meta-index: $(JRE_LIB_TARGETS)
 224         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 225         $(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index `$(LS) *.jar | $(SED) 's/JObjC\.jar//g'`
 226 
 227 $(JDK_IMAGE_DIR)/jre/lib/meta-index: $(JDKJRE_LIB_TARGETS)
 228         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 229         $(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index `$(LS) *.jar | $(SED) 's/JObjC\.jar//g'`
 230 
 231 $(JRE_IMAGE_DIR)/lib/ext/meta-index: $(JRE_LIB_TARGETS)
 232         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 233         $(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index *.jar
 234 
 235 $(JDK_IMAGE_DIR)/jre/lib/ext/meta-index: $(JDKJRE_LIB_TARGETS)
 236         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 237         $(CD) $(@D) && $(TOOL_BUILDMETAINDEX) -o meta-index *.jar
 238 
 239 ################################################################################
 240 # /man dir
 241 # Avoid evaluating this whole section on windows for speed and stability
 242 ifneq ($(OPENJDK_TARGET_OS),windows)
 243     JRE_MAN_PAGES := \
 244         java.1          \
 245         keytool.1       \
 246         orbd.1          \
 247         pack200.1       \
 248         policytool.1    \
 249         rmid.1          \
 250         rmiregistry.1   \
 251         servertool.1    \
 252         tnameserv.1     \
 253         unpack200.1
 254 
 255     ifndef OPENJDK
 256         JRE_MAN_PAGES += javaws.1
 257     endif
 258 
 259     JDK_MAN_PAGES =        \
 260         $(JRE_MAN_PAGES)   \
 261         appletviewer.1     \
 262         extcheck.1         \
 263         idlj.1             \
 264         jar.1              \
 265         jarsigner.1        \
 266         javac.1            \
 267         javadoc.1          \
 268         javah.1            \
 269         javap.1            \
 270         jconsole.1         \
 271         jcmd.1             \
 272         jdb.1              \
 273         jhat.1             \
 274         jinfo.1            \
 275         jmap.1             \
 276         jps.1              \
 277         jrunscript.1       \
 278         jsadebugd.1        \
 279         jstack.1           \
 280         jstat.1            \
 281         jstatd.1           \
 282         native2ascii.1     \
 283         rmic.1             \
 284         schemagen.1        \
 285         serialver.1        \
 286         wsgen.1            \
 287         wsimport.1         \
 288         xjc.1
 289 
 290     ifndef OPENJDK
 291         JDK_MAN_PAGES += jvisualvm.1
 292     endif
 293 
 294     ifeq ($(OPENJDK_TARGET_OS), linux)
 295         MAN_SRC_DIR:=$(JDK_TOPDIR)/src/linux/doc
 296         MAN1_SUBDIR:=man
 297     endif
 298     ifeq ($(OPENJDK_TARGET_OS), solaris)
 299         MAN_SRC_DIR:=$(JDK_TOPDIR)/src/solaris/doc
 300         MAN1_SUBDIR:=sun/man/man1
 301     endif
 302     ifeq ($(OPENJDK_TARGET_OS), macosx)
 303         MAN_SRC_DIR:=$(JDK_TOPDIR)/src/bsd/doc
 304         MAN1_SUBDIR:=man
 305         JDK_MAN_PAGES := $(filter-out jcmd.1, $(JDK_MAN_PAGES))
 306         JDK_MAN_PAGES := $(filter-out jvisualvm.1, $(JDK_MAN_PAGES))
 307     endif
 308 
 309 
 310     $(JRE_IMAGE_DIR)/man/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/%
 311         $(ECHO) $(LOG_INFO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 312         $(install-file)
 313 
 314     $(JDK_IMAGE_DIR)/man/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/%
 315         $(ECHO) $(LOG_INFO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 316         $(install-file)
 317 
 318     $(JRE_IMAGE_DIR)/man/man1/%: $(JDK_OUTPUTDIR)/impdoc/$(MAN1_SUBDIR)/%
 319         $(ECHO) $(LOG_INFO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 320         $(install-file)
 321 
 322     $(JDK_IMAGE_DIR)/man/man1/%: $(JDK_OUTPUTDIR)/impdoc/$(MAN1_SUBDIR)/%
 323         $(ECHO) $(LOG_INFO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 324         $(install-file)
 325 
 326     define install-ja-manpage
 327         $(MKDIR) -p $(@D)
 328         $(CAT) $< \
 329                 | $(NATIVE2ASCII) -encoding eucJP \
 330                 | $(SED) 's/@@VERSION@@/$(THIS_JDK_VERSION)/g' \
 331                 | $(NATIVE2ASCII) -reverse -encoding $1 \
 332                 > $@
 333     endef
 334 
 335     $(JRE_IMAGE_DIR)/man/ja_JP.UTF-8/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 336         $(ECHO) $(LOG_INFO) Converting $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 337         $(call install-ja-manpage,UTF-8)
 338 
 339     $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 340         $(ECHO) $(LOG_INFO) Converting $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 341         $(call install-ja-manpage,UTF-8)
 342 
 343     $(JRE_IMAGE_DIR)/man/ja_JP.PCK/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 344         $(ECHO) $(LOG_INFO) Converting $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 345         $(call install-ja-manpage,PCK)
 346 
 347     $(JDK_IMAGE_DIR)/man/ja_JP.PCK/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 348         $(ECHO) $(LOG_INFO) Converting $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 349         $(call install-ja-manpage,PCK)
 350 
 351     ifeq ($(OPENJDK_TARGET_OS), solaris)
 352         $(JRE_IMAGE_DIR)/man/ja/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 353                 $(ECHO) $(LOG_INFO) Converting $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 354                 $(install-file)
 355 
 356         $(JDK_IMAGE_DIR)/man/ja/man1/%: $(MAN_SRC_DIR)/$(MAN1_SUBDIR)/ja/%
 357                 $(ECHO) $(LOG_INFO) Converting $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 358                 $(install-file)
 359     endif
 360 
 361     # Old build creates empty man page for this, mimicing behaviour.
 362     $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/jcmd.1 $(JDK_IMAGE_DIR)/man/ja_JP.PCK/man1/jcmd.1 $(JDK_IMAGE_DIR)/man/ja/man1/jcmd.1:
 363         $(ECHO) $(LOG_INFO) Creating dummy $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 364         $(MKDIR) -p $(@D)
 365         $(TOUCH) $@
 366 
 367     ifeq ($(OPENJDK_TARGET_OS), linux)
 368         $(JRE_IMAGE_DIR)/man/ja:
 369                 $(ECHO) $(LOG_INFO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 370                 $(CD) $(@D) && $(RM) ja && $(LN) -s ja_JP.UTF-8 ja
 371 
 372         $(JDK_IMAGE_DIR)/man/ja:
 373                 $(ECHO) $(LOG_INFO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 374                 $(CD) $(@D) && $(RM) ja && $(LN) -s ja_JP.UTF-8 ja
 375     endif
 376 
 377     ifeq ($(OPENJDK_TARGET_OS), macosx)
 378         $(JRE_IMAGE_DIR)/man/ja:
 379                 $(ECHO) $(LOG_INFO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 380                 $(CD) $(@D) && $(RM) ja && $(LN) -s ja_JP.UTF-8 ja
 381 
 382         $(JDK_IMAGE_DIR)/man/ja:
 383                 $(ECHO) $(LOG_INFO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 384                 $(CD) $(@D) && $(RM) ja && $(LN) -s ja_JP.UTF-8 ja
 385     endif
 386 
 387     ifeq ($(OPENJDK_TARGET_OS), linux)
 388         JRE_MAN_PAGE_LIST := $(addprefix $(JRE_IMAGE_DIR)/man/man1/,$(JRE_MAN_PAGES)) \
 389                              $(addprefix $(JRE_IMAGE_DIR)/man/ja_JP.UTF-8/man1/,$(JRE_MAN_PAGES)) \
 390                              $(JRE_IMAGE_DIR)/man/ja
 391 
 392         JDK_MAN_PAGE_LIST := $(addprefix $(JDK_IMAGE_DIR)/man/man1/,$(JDK_MAN_PAGES)) \
 393                              $(addprefix $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/,$(JDK_MAN_PAGES)) \
 394                              $(JDK_IMAGE_DIR)/man/ja
 395     endif
 396 
 397     ifeq ($(OPENJDK_TARGET_OS), solaris)
 398         JRE_MAN_PAGE_LIST := $(addprefix $(JRE_IMAGE_DIR)/man/man1/,$(JRE_MAN_PAGES)) \
 399                              $(addprefix $(JRE_IMAGE_DIR)/man/ja/man1/,$(JRE_MAN_PAGES)) \
 400                              $(addprefix $(JRE_IMAGE_DIR)/man/ja_JP.UTF-8/man1/,$(JRE_MAN_PAGES)) \
 401                              $(addprefix $(JRE_IMAGE_DIR)/man/ja_JP.PCK/man1/,$(JRE_MAN_PAGES))
 402 
 403         JDK_MAN_PAGE_LIST := $(addprefix $(JDK_IMAGE_DIR)/man/man1/,$(JDK_MAN_PAGES)) \
 404                              $(addprefix $(JDK_IMAGE_DIR)/man/ja/man1/,$(JDK_MAN_PAGES)) \
 405                              $(addprefix $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/,$(JDK_MAN_PAGES)) \
 406                              $(addprefix $(JDK_IMAGE_DIR)/man/ja_JP.PCK/man1/,$(JDK_MAN_PAGES))
 407     endif
 408 
 409     ifeq ($(OPENJDK_TARGET_OS), macosx)
 410         JRE_MAN_PAGE_LIST := $(addprefix $(JRE_IMAGE_DIR)/man/man1/,$(JRE_MAN_PAGES)) \
 411                              $(addprefix $(JRE_IMAGE_DIR)/man/ja_JP.UTF-8/man1/,$(JRE_MAN_PAGES)) \
 412                              $(JRE_IMAGE_DIR)/man/ja
 413 
 414         JDK_MAN_PAGE_LIST := $(addprefix $(JDK_IMAGE_DIR)/man/man1/,$(JDK_MAN_PAGES)) \
 415                              $(addprefix $(JDK_IMAGE_DIR)/man/ja_JP.UTF-8/man1/,$(JDK_MAN_PAGES)) \
 416                              $(JDK_IMAGE_DIR)/man/ja
 417     endif
 418 
 419 endif # Windows
 420 
 421 ################################################################################
 422 # /demo dir
 423 
 424 # FIXME: demo/applets/GraphLayout/GraphPanel$2.class is sometimes not copied.
 425 
 426 #   The db demo contains an empty dir that needs to be copied. The other 
 427 #   directories will always trigger the rule for recompile since 
 428 #   _the.list_of_packages files are touched.
 429 $(JDK_IMAGE_DIR)/demo/%: $(JDK_OUTPUTDIR)/demo/%
 430         if [ ! -d "$@" ]; then \
 431           $(ECHO) $(LOG_INFO) Copying '$(patsubst $(OUTPUT_ROOT)/%,%,$@)'; \
 432           $(MKDIR) -p $(@D); \
 433           if [ -d "$<" ]; then $(MKDIR) -p $@; else $(CP) '$<' '$@'; fi \
 434         fi
 435 
 436 #   Find all files including directories
 437 JDK_DEMO_TARGETS := $(patsubst $(JDK_OUTPUTDIR)/demo/%,$(JDK_IMAGE_DIR)/demo/%,\
 438                         $(shell $(FIND) $(JDK_OUTPUTDIR)/demo ! \( -name "_the*" -o -name "javac_state" \) ))
 439 
 440 
 441 
 442 # Param 1 is source file
 443 define CreateOverlayDemoRule
 444     $1_TARGET:=$$(subst $(JDK_OUTPUTDIR),$(JDK_OVERLAY_IMAGE_DIR),\
 445                         $$(dir $1)$(OPENJDK_TARGET_CPU_ISADIR)/$$(notdir $1))
 446     $$($1_TARGET): $1
 447                 $(ECHO) $(LOG_INFO) Copying '$$(patsubst $(OUTPUT_ROOT)/%,%,$$@)'
 448                 $$(call install-file)
 449 
 450     JDK_OVERLAY_DEMO_TARGETS += $$($1_TARGET)
 451 endef
 452 JDK_OVERLAY_DEMO_SOURCES := $(shell $(FIND) $(JDK_OUTPUTDIR)/demo -name "*$(SHARED_LIBRARY_SUFFIX)")
 453 $(foreach lib,$(JDK_OVERLAY_DEMO_SOURCES),$(eval $(call CreateOverlayDemoRule,$(lib))))
 454 
 455 ################################################################################
 456 # /sample dir
 457 
 458 $(foreach f,$(shell $(FIND) $(JDK_OUTPUTDIR)/sample -type f),\
 459     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_IMAGE_DIR),$f,JDK_SAMPLE_TARGETS)))
 460 
 461 ################################################################################
 462 # /db dir
 463 
 464 ifndef OPENJDK
 465     $(IMAGES_OUTPUTDIR)/_unzip/%.unzipped: $(JDK_TOPDIR)/src/closed/share/db/%
 466         $(ECHO) Unzipping $(patsubst $(SRC_ROOT)/%,%,$<)
 467         $(MKDIR) -p $(JDK_IMAGE_DIR)/db
 468         cd $(JDK_IMAGE_DIR)/db && $(UNZIP) -q -o $< -x index.html 2> /dev/null
 469         $(MKDIR) -p $(@D)
 470         $(TOUCH) $@
 471 
 472     $(JDK_IMAGE_DIR)/db/README-JDK.html: $(JDK_TOPDIR)/src/closed/share/db/README-JDK.html
 473         $(ECHO) $(LOG_INFO) Copying '$(patsubst $(OUTPUT_ROOT)/%,%,$@)'
 474         $(install-file)
 475 
 476     JDK_DB_TARGETS := $(patsubst $(JDK_TOPDIR)/src/closed/share/db/%,$(IMAGES_OUTPUTDIR)/_unzip/%.unzipped,\
 477                         $(shell $(FIND) $(JDK_TOPDIR)/src/closed/share/db -name "*.zip" ! -name "*demo*")) \
 478                       $(JDK_IMAGE_DIR)/db/README-JDK.html
 479 
 480 endif
 481 
 482 ################################################################################
 483 # /include dir
 484 
 485 $(foreach f,$(shell $(FIND) $(JDK_OUTPUTDIR)/include -type f),\
 486     $(eval $(call AddFileToCopy,$(JDK_OUTPUTDIR),$(JDK_IMAGE_DIR),$f,JDK_INCLUDE_TARGETS)))
 487 
 488 ################################################################################
 489 # doc files
 490 
 491 ifdef OPENJDK
 492     JRE_DOC_FILES := LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README
 493     JDK_DOC_FILES := LICENSE ASSEMBLY_EXCEPTION THIRD_PARTY_README
 494     JRE_DOC_LOCATION := $(JDK_TOPDIR)
 495     JDK_DOC_LOCATION := $(JDK_TOPDIR)
 496 else
 497     JRE_DOC_FILES := COPYRIGHT Welcome.html LICENSE THIRDPARTYLICENSEREADME.txt
 498     JDK_DOC_FILES := COPYRIGHT README.html  LICENSE THIRDPARTYLICENSEREADME.txt
 499     ifeq ($(OPENJDK_TARGET_OS), windows)
 500         JRE_DOC_FILES += README.txt
 501     else
 502         JRE_DOC_FILES += README
 503     endif
 504     JDK_DOC_FILES += demo/DEMOS_LICENSE sample/SAMPLES_LICENSE
 505     JRE_DOC_LOCATION := $(JDK_TOPDIR)/src/closed/share/doc/jre
 506     JDK_DOC_LOCATION := $(JDK_TOPDIR)/src/closed/share/doc/jdk
 507 endif
 508 JRE_DOC_TARGETS := $(addprefix $(JRE_IMAGE_DIR)/,$(JRE_DOC_FILES))
 509 JDKJRE_DOC_TARGETS := $(addprefix $(JDK_IMAGE_DIR)/jre/,$(JRE_DOC_FILES))
 510 JDK_DOC_TARGETS := $(addprefix $(JDK_IMAGE_DIR)/,$(JDK_DOC_FILES))
 511 
 512 $(JRE_IMAGE_DIR)/%: $(JRE_DOC_LOCATION)/%
 513         $(process-doc-file)
 514 
 515 $(JDK_IMAGE_DIR)/jre/%: $(JRE_DOC_LOCATION)/%
 516         $(process-doc-file)
 517 
 518 $(JRE_IMAGE_DIR)/README.txt: $(JRE_DOC_LOCATION)/README
 519         $(process-doc-file)
 520 
 521 $(JDK_IMAGE_DIR)/jre/README.txt: $(JRE_DOC_LOCATION)/README
 522         $(process-doc-file)
 523 
 524 $(JDK_IMAGE_DIR)/%: $(JDK_DOC_LOCATION)/%
 525         $(process-doc-file)
 526 
 527 $(JDK_IMAGE_DIR)/demo/%: $(JDK_DOC_LOCATION)/%
 528         $(process-doc-file)
 529 
 530 $(JDK_IMAGE_DIR)/sample/%: $(JDK_DOC_LOCATION)/%
 531         $(process-doc-file)
 532 
 533 JRE_INFO_FILE := $(JRE_IMAGE_DIR)/release
 534 JDK_INFO_FILE := $(JDK_IMAGE_DIR)/release
 535 
 536 JRE_OVERLAY_INFO_FILE := $(JRE_OVERLAY_IMAGE_DIR)/release
 537 JDK_OVERLAY_INFO_FILE := $(JDK_OVERLAY_IMAGE_DIR)/release
 538 
 539 # Common way to emit a line into the release or info file
 540 define info-file-item # name value
 541 $(PRINTF) '%s="%s"\n' $1 $2 >> $@
 542 endef
 543 
 544 define create-info-file
 545         $(MKDIR) -p $(@D)
 546         $(RM) $@
 547         $(call info-file-item, "JAVA_VERSION", "$(JDK_VERSION)")
 548         $(call info-file-item, "OS_NAME",      "$(REQUIRED_OS_NAME)")
 549         $(call info-file-item, "OS_VERSION",   "$(REQUIRED_OS_VERSION)")
 550         $(call info-file-item, "OS_ARCH",      "$(OPENJDK_TARGET_CPU_LEGACY)")
 551         $(call info-file-item, "SOURCE",       "$(ALL_SOURCE_TIPS)")
 552 endef
 553 
 554 ALL_SOURCE_TIPS = $(shell \
 555   if [ -f $(OUTPUT_ROOT)/source_tips ] ; then \
 556     $(CAT) $(OUTPUT_ROOT)/source_tips ; \
 557   fi)
 558 
 559 $(JRE_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 560         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 561         $(call create-info-file)
 562 ifneq ($(PROFILE),)
 563         $(call info-file-item, "JAVA_PROFILE", "$(call profile_name, $(call profile_number, $(PROFILE)))")
 564 endif
 565 
 566 $(JDK_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 567         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 568         $(call create-info-file)
 569 
 570 $(JRE_OVERLAY_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 571         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 572         $(call create-info-file)
 573 
 574 $(JDK_OVERLAY_INFO_FILE): $(OUTPUT_ROOT)/spec.gmk $(OUTPUT_ROOT)/source_tips
 575         $(ECHO) $(LOG_INFO) Generating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 576         $(call create-info-file)
 577 
 578 $(JDK_IMAGE_DIR)/src.zip: $(IMAGES_OUTPUTDIR)/src.zip
 579         $(ECHO) $(LOG_INFO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 580         $(install-file)
 581 
 582 ################################################################################
 583 # Post processing (strip etc)
 584 
 585 ifneq ($(POST_STRIP_CMD),)
 586     ifeq ($(OPENJDK_TARGET_OS), windows)
 587         EXEC_LIST_BIN:=$(shell $(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*.exe \
 588                 -o -name \*.dll | $(EGREP) -v -i "$(MSVCR_DLL)")
 589     else
 590         # Find all executables in JDK_OUTPUTDIR since they exist when this makefile is parsed
 591         EXEC_LIST_BIN:=$(shell $(FILE) `$(FIND) $(JDK_OUTPUTDIR)/bin -type f -name \*$(EXE_SUFFIX)` \
 592                 | $(EGREP) 'ELF' | $(CUT) -d':' -f1)
 593         # On mac, the old build searches for static libraries for stripping instead of shared.
 594         # Not clear if it's intentional.
 595         ifneq ($(OPENJDK_TARGET_OS), macosx)
 596             EXEC_LIST_LIB:=$(shell $(FIND) $(JDK_OUTPUTDIR)/lib -type f -name \*$(SHARED_LIBRARY_SUFFIX))
 597         endif
 598     endif
 599     # Filter out sjavac
 600     EXEC_LIST_BIN:=$(filter-out %sjavac$(EXE_SUFFIX),$(EXEC_LIST_BIN))
 601 
 602     # Filter out the overlay specific bin files
 603     EXEC_LIST:=$(filter-out $(OVERLAY_FILTER),$(EXEC_LIST_BIN)) $(EXEC_LIST_LIB)
 604     EXEC_LIST_OVERLAY:=$(filter $(OVERLAY_FILTER),$(EXEC_LIST_BIN)) $(EXEC_LIST_LIB)
 605 
 606     # Filter out non JRE files and convert to unique touch files to depend on
 607     JRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre$(PROFILE)/%.stripped,\
 608                         $(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
 609                                  $(EXEC_LIST)))
 610 
 611     JDKJRE_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
 612                         $(IMAGES_OUTPUTDIR)/_strip_jdk/jre/%.stripped, \
 613                         $(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES)), $(EXEC_LIST)))
 614 
 615     JDK_BIN_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
 616                           $(IMAGES_OUTPUTDIR)/_strip_jdk/%.stripped, \
 617                           $(filter-out $(JDK_OUTPUTDIR)/lib/%, $(EXEC_LIST)))
 618 
 619     # Do the same for overlay image
 620     JRE_OVERLAY_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%,$(IMAGES_OUTPUTDIR)/_strip_jre_overlay/%.stripped,\
 621                         $(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES) $(JDKJRE_LIB_FILES)),\
 622                                  $(EXEC_LIST_OVERLAY)))
 623 
 624     JDKJRE_OVERLAY_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
 625                         $(IMAGES_OUTPUTDIR)/_strip_jdk_overlay/jre/%.stripped, \
 626                         $(filter-out $(addprefix %,$(NOT_JRE_BIN_FILES) $(NOT_JRE_LIB_FILES)), $(EXEC_LIST_OVERLAY)))
 627 
 628     JDK_OVERLAY_BIN_STRIP_LIST:=$(patsubst $(JDK_OUTPUTDIR)/%, \
 629                           $(IMAGES_OUTPUTDIR)/_strip_jdk_overlay/%.stripped, \
 630                           $(filter-out $(JDK_OUTPUTDIR)/lib/%, $(EXEC_LIST_OVERLAY)))
 631 
 632     define mcs-file
 633         $(if $(POST_MCS_CMD),$(POST_MCS_CMD) $<)
 634     endef
 635 
 636     define strip-file
 637         $(ECHO) Stripping $(LOG_INFO) $(patsubst $(OUTPUT_ROOT)/%,%,$<)
 638         $(CHMOD) u+w $<
 639         $(POST_STRIP_CMD) $<
 640         $(call mcs-file)
 641         $(CHMOD) go-w $<
 642         $(MKDIR) -p $(@D)
 643         $(TOUCH) $@
 644     endef
 645 
 646     # Setup a rule for stripping files based on touch files
 647     $(IMAGES_OUTPUTDIR)/_strip_jre$(PROFILE)/%.stripped: $(JRE_IMAGE_DIR)/%
 648         $(call strip-file)
 649 
 650     $(IMAGES_OUTPUTDIR)/_strip_jdk/%.stripped: $(JDK_IMAGE_DIR)/%
 651         $(call strip-file)
 652 
 653     $(IMAGES_OUTPUTDIR)/_strip_jre_overlay/%.stripped: $(JRE_OVERLAY_IMAGE_DIR)/%
 654         $(call strip-file)
 655 
 656     $(IMAGES_OUTPUTDIR)/_strip_jdk_overlay/%.stripped: $(JDK_OVERLAY_IMAGE_DIR)/%
 657         $(call strip-file)
 658 
 659 endif
 660 
 661 ################################################################################
 662 # Main targets
 663 
 664 jre-image: $(JRE_BIN_TARGETS) $(JRE_LIB_TARGETS) $(JRE_IMAGE_DIR)/lib/applet \
 665         $(JRE_IMAGE_DIR)/lib/meta-index $(JRE_IMAGE_DIR)/lib/ext/meta-index \
 666         $(JRE_MAN_PAGE_LIST) $(JRE_DOC_TARGETS) $(JRE_INFO_FILE) $(JRE_STRIP_LIST)
 667 
 668 jdk-image: $(JDK_BIN_TARGETS) $(JDKJRE_BIN_TARGETS) \
 669         $(JDK_LIB_TARGETS) $(JDKJRE_LIB_TARGETS) \
 670         $(JDK_IMAGE_DIR)/jre/lib/applet \
 671         $(JDK_DEMO_TARGETS) \
 672         $(JDK_IMAGE_DIR)/jre/lib/meta-index $(JDK_IMAGE_DIR)/jre/lib/ext/meta-index \
 673         $(JDK_MAN_PAGE_LIST) $(JDK_SAMPLE_TARGETS) \
 674         $(JDK_DB_TARGETS) $(JDK_INCLUDE_TARGETS) \
 675         $(JDKJRE_DOC_TARGETS) $(JDK_DOC_TARGETS) \
 676         $(JDK_INFO_FILE) $(JDKJRE_STRIP_LIST) $(JDK_BIN_STRIP_LIST) \
 677         $(JDK_IMAGE_DIR)/src.zip
 678 
 679 jre-overlay-image: $(JRE_OVERLAY_BIN_TARGETS) $(JRE_OVERLAY_LIB_TARGETS) \
 680          $(JRE_OVERLAY_INFO_FILE) $(JRE_OVERLAY_STRIP_LIST)
 681 
 682 jdk-overlay-image: $(JDK_OVERLAY_BIN_TARGETS) $(JDKJRE_OVERLAY_BIN_TARGETS) \
 683         $(JDK_OVERLAY_LIB_TARGETS) $(JDKJRE_OVERLAY_LIB_TARGETS) \
 684         $(JDK_OVERLAY_DEMO_TARGETS) $(JDK_OVERLAY_INFO_FILE) \
 685         $(JDKJRE_OVERLAY_STRIP_LIST) $(JDK_OVERLAY_BIN_STRIP_LIST) 
 686 
 687 ifneq ($(PROFILE),)
 688 # Files in lib$(PROFILE) are excluded from the generic copying routines so
 689 # we have to add them back in here
 690 $(foreach f,$(CUSTOM_PROFILE_JARS),\
 691     $(eval $(call AddFileToCopy,$(IMAGES_OUTPUTDIR)/lib$(PROFILE),$(JRE_IMAGE_DIR)/lib,$f,JRE_LIB_TARGETS)))
 692 
 693 profile-image1:
 694         @$(ECHO) JRE_BIN_LIST = $(JRE_BIN_LIST)
 695         @$(ECHO) NOT_JRE_BIN_FILES = $(NOT_JRE_BIN_FILES)
 696 
 697 profile-image: $(JRE_BIN_TARGETS) $(JRE_LIB_TARGETS) \
 698         $(JRE_IMAGE_DIR)/lib/meta-index $(JRE_IMAGE_DIR)/lib/ext/meta-index \
 699         $(JRE_INFO_FILE) $(JRE_STRIP_LIST)
 700 
 701 .PHONY: profile-image
 702 
 703 endif # Profile
 704 
 705 ################################################################################
 706 
 707 .PHONY: default images jre-image jdk-image