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 
  29 default: bundles
  30 
  31 # Only macosx has bundles defined.
  32 ifeq ($(OPENJDK_TARGET_OS), macosx)
  33 
  34 bundles: jre-bundle jdk-bundle
  35 
  36 # JDK_BUNDLE_DIR and JRE_BUNDLE_DIR are defined in SPEC.
  37 
  38 MACOSX_SRC := $(JDK_TOPDIR)/src/macosx
  39 
  40 # All these OPENJDK checks are needed since there is no coherency between
  41 # these values in open and closed. Should probably be fixed.
  42 ifndef OPENJDK
  43     BUNDLE_ID := $(MACOSX_BUNDLE_ID_BASE).$(JDK_MINOR_VERSION)u$(JDK_UPDATE_VERSION)
  44 else
  45     BUNDLE_ID := $(MACOSX_BUNDLE_ID_BASE)
  46 endif
  47 BUNDLE_ID_JRE := $(BUNDLE_ID).jre
  48 BUNDLE_ID_JDK := $(BUNDLE_ID).jdk
  49 
  50 BUNDLE_NAME := $(MACOSX_BUNDLE_NAME_BASE) $(JDK_MINOR_VERSION)
  51 BUNDLE_NAME_JRE := $(BUNDLE_NAME)
  52 BUNDLE_NAME_JDK := $(BUNDLE_NAME)
  53 
  54 ifndef OPENJDK
  55     BUNDLE_INFO := $(MACOSX_BUNDLE_NAME_BASE) $(JDK_VERSION)
  56 else
  57     BUNDLE_INFO := $(MACOSX_BUNDLE_NAME_BASE) ($(JDK_VERSION))
  58 endif
  59 BUNDLE_INFO_JRE := $(BUNDLE_INFO)
  60 BUNDLE_INFO_JDK := $(BUNDLE_INFO)
  61 
  62 BUNDLE_PLATFORM_VERSION := $(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION)
  63 BUNDLE_VERSION := $(JDK_VERSION)
  64 ifeq ($(COMPANY_NAME),N/A)
  65     BUNDLE_VENDOR := UNDEFINED
  66 else
  67     BUNDLE_VENDOR := $(COMPANY_NAME)
  68 endif
  69 
  70 
  71 JDK_FILE_LIST := $(shell $(FIND) $(JDK_IMAGE_DIR) ! -type d)
  72 JRE_FILE_LIST := $(shell $(FIND) $(JRE_IMAGE_DIR) ! -type d)
  73 
  74 JDK_TARGET_LIST := $(subst $(JDK_IMAGE_DIR),$(JDK_BUNDLE_DIR)/Home,$(JDK_FILE_LIST))
  75 JRE_TARGET_LIST := $(subst $(JRE_IMAGE_DIR),$(JRE_BUNDLE_DIR)/Home,$(JRE_FILE_LIST))
  76 
  77 # The old builds implementation of this did not preserve symlinks so
  78 # make sure they are followed and the contents copied instead.
  79 # To fix this, just replace copy with install-file macro.
  80 $(JDK_BUNDLE_DIR)/Home/%: $(JDK_IMAGE_DIR)/%
  81         $(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
  82         $(MKDIR) -p $(@D)
  83         $(CP) -f -R -L '$<' '$@'
  84 
  85 $(JRE_BUNDLE_DIR)/Home/%: $(JRE_IMAGE_DIR)/%
  86         $(ECHO) Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)
  87         $(MKDIR) -p $(@D)
  88         $(CP) -f -R -L '$<' '$@'
  89 
  90 $(JDK_BUNDLE_DIR)/MacOS/libjli.dylib:
  91         $(ECHO) Creating link $(patsubst $(OUTPUT_ROOT)/%,%,$@)
  92         $(MKDIR) -p $(@D)
  93         $(RM) $@
  94         $(LN) -s ../Home/lib/jli/libjli.dylib $@
  95 
  96 $(JRE_BUNDLE_DIR)/MacOS/libjli.dylib:
  97         $(ECHO) Creating link $(patsubst $(OUTPUT_ROOT)/%,%,$@)
  98         $(MKDIR) -p $(@D)
  99         $(RM) $@
 100         $(LN) -s ../Home/lib/jli/libjli.dylib $@
 101 
 102 $(JDK_BUNDLE_DIR)/Info.plist: $(SPEC)
 103         $(ECHO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 104         $(MKDIR) -p $(@D)
 105         $(SED)  -e "s/@@ID@@/$(BUNDLE_ID_JDK)/g" \
 106                 -e "s/@@NAME@@/$(BUNDLE_NAME_JDK)/g" \
 107                 -e "s/@@INFO@@/$(BUNDLE_INFO_JDK)/g" \
 108                 -e "s/@@PLATFORM_VERSION@@/$(BUNDLE_PLATFORM_VERSION)/g" \
 109                 -e "s/@@VERSION@@/$(BUNDLE_VERSION)/g" \
 110                 -e "s/@@VENDOR@@/$(BUNDLE_VENDOR)/g" \
 111                 < $(MACOSX_SRC)/bundle/JDK-Info.plist > $@
 112 
 113 $(JRE_BUNDLE_DIR)/Info.plist: $(SPEC)
 114         $(ECHO) Creating $(patsubst $(OUTPUT_ROOT)/%,%,$@)
 115         $(MKDIR) -p $(@D)
 116         $(SED)  -e "s/@@ID@@/$(BUNDLE_ID_JRE)/g" \
 117                 -e "s/@@NAME@@/$(BUNDLE_NAME_JRE)/g" \
 118                 -e "s/@@INFO@@/$(BUNDLE_INFO_JRE)/g" \
 119                 -e "s/@@PLATFORM_VERSION@@/$(BUNDLE_PLATFORM_VERSION)/g" \
 120                 -e "s/@@VERSION@@/$(BUNDLE_VERSION)/g" \
 121                 -e "s/@@VENDOR@@/$(BUNDLE_VENDOR)/g" \
 122                 < $(MACOSX_SRC)/bundle/JRE-Info.plist > $@
 123 
 124 jdk-bundle: $(JDK_TARGET_LIST) $(JDK_BUNDLE_DIR)/MacOS/libjli.dylib \
 125                 $(JDK_BUNDLE_DIR)/Info.plist
 126         $(SETFILE) -a B $(dir $(JDK_BUNDLE_DIR))
 127 
 128 jre-bundle: $(JRE_TARGET_LIST) $(JRE_BUNDLE_DIR)/MacOS/libjli.dylib \
 129                 $(JRE_BUNDLE_DIR)/Info.plist
 130         $(SETFILE) -a B $(dir $(JRE_BUNDLE_DIR))
 131 
 132 else # Not macosx
 133 
 134 bundles:
 135         $(ECHO) "No bundles defined for $(OPENJDK_TARGET_OS)"
 136 
 137 endif # macosx
 138 
 139 .PHONY: jdk-bundle jre-bundle bundles