make/devkit/createSolarisDevkit.sh
changeset 34595 09596fe63e2d
child 34606 83c270cae5e1
equal deleted inserted replaced
34594:7e0595aab028 34595:09596fe63e2d
       
     1 #!/bin/bash
       
     2 #
       
     3 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
       
     4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     5 #
       
     6 # This code is free software; you can redistribute it and/or modify it
       
     7 # under the terms of the GNU General Public License version 2 only, as
       
     8 # published by the Free Software Foundation.  Oracle designates this
       
     9 # particular file as subject to the "Classpath" exception as provided
       
    10 # by Oracle in the LICENSE file that accompanied this code.
       
    11 #
       
    12 # This code is distributed in the hope that it will be useful, but WITHOUT
       
    13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    14 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    15 # version 2 for more details (a copy is included in the LICENSE file that
       
    16 # accompanied this code).
       
    17 #
       
    18 # You should have received a copy of the GNU General Public License version
       
    19 # 2 along with this work; if not, write to the Free Software Foundation,
       
    20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    21 #
       
    22 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    23 # or visit www.oracle.com if you need additional information or have any
       
    24 # questions.
       
    25 #
       
    26 
       
    27 # This script creates a devkit for building OpenJDK on Solaris by copying
       
    28 # part of a Solaris Studio installation and cretaing a sysroot by installing
       
    29 # a limited set of system packages. It is assumed that a suitable pkg
       
    30 # publisher is configured for the system where the script is executed.
       
    31 #
       
    32 # The Solaris Studio installation must contain at least these packages:
       
    33 # developer/solarisstudio-124/backend               12.4-1.0.6.0               i--
       
    34 # developer/solarisstudio-124/c++                   12.4-1.0.10.0              i--
       
    35 # developer/solarisstudio-124/cc                    12.4-1.0.4.0               i--
       
    36 # developer/solarisstudio-124/library/c++-libs      12.4-1.0.10.0              i--
       
    37 # developer/solarisstudio-124/library/math-libs     12.4-1.0.0.1               i--
       
    38 # developer/solarisstudio-124/library/studio-gccrt  12.4-1.0.0.1               i--
       
    39 # developer/solarisstudio-124/studio-common         12.4-1.0.0.1               i--
       
    40 # developer/solarisstudio-124/studio-ja             12.4-1.0.0.1               i--
       
    41 # developer/solarisstudio-124/studio-legal          12.4-1.0.0.1               i--
       
    42 # developer/solarisstudio-124/studio-zhCN           12.4-1.0.0.1               i--
       
    43 # In particular backend 12.4-1.0.6.0 contains a critical patch for the sparc
       
    44 # version.
       
    45 #
       
    46 # erik.joelsson@oracle.com
       
    47 
       
    48 USAGE="$0 <Solaris Studio installation> <Path to gnu make binary>"
       
    49 
       
    50 if [ "$1" = "" ] || [ "$2" = "" ]; then
       
    51   echo $USAGE
       
    52   exit 1
       
    53 fi
       
    54 
       
    55 SOLARIS_STUDIO_VERSION=12u4
       
    56 SOLARIS_VERSION=11u1
       
    57 case `uname -p` in
       
    58   i*)
       
    59     ARCH=x86
       
    60     ;;
       
    61   sparc*)
       
    62     ARCH=sparc
       
    63     ;;
       
    64 esac
       
    65 
       
    66 SOLARIS_STUDIO_SRC=$1
       
    67 GNU_MAKE=$2
       
    68 
       
    69 SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
       
    70 BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
       
    71 
       
    72 DEVKIT_NAME=SS${SOLARIS_STUDIO_VERSION}-Solaris${SOLARIS_VERSION}
       
    73 DEVKIT_ROOT=${BUILD_DIR}/${DEVKIT_NAME}
       
    74 BUNDLE_NAME=${DEVKIT_NAME}.tar.gz
       
    75 BUNDLE=${BUILD_DIR}/${BUNDLE_NAME}
       
    76 INSTALL_ROOT=${BUILD_DIR}/install-root
       
    77 SYSROOT=${DEVKIT_ROOT}/sysroot
       
    78 SOLARIS_STUDIO_SUBDIR=SS${SOLARIS_STUDIO_VERSION}
       
    79 SOLARIS_STUDIO_DIR=${DEVKIT_ROOT}/${SOLARIS_STUDIO_SUBDIR}
       
    80 
       
    81 # Extract the publisher from the system
       
    82 if [ -z "${PUBLISHER_URI}" ]; then
       
    83   PUBLISHER_URI="$(pkg publisher solaris | grep URI | awk '{ print $3 }')"
       
    84 fi
       
    85 
       
    86 if [ ! -d $INSTALL_ROOT ]; then
       
    87   echo "Creating $INSTALL_ROOT and installing packages"
       
    88   pkg image-create $INSTALL_ROOT
       
    89   pkg -R $INSTALL_ROOT set-publisher -P -g ${PUBLISHER_URI} solaris
       
    90   pkg -R $INSTALL_ROOT install --accept $(cat solaris11.1-package-list.txt)
       
    91 else
       
    92   echo "Skipping installing packages"
       
    93 fi
       
    94 
       
    95 if [ ! -d $SYSROOT ]; then
       
    96   echo "Copying from $INSTALL_ROOT to $SYSROOT"
       
    97   mkdir -p $SYSROOT
       
    98   cp -rH $INSTALL_ROOT/lib $SYSROOT/
       
    99   mkdir $SYSROOT/usr
       
   100   # Some of the tools in sysroot are needed in the OpenJDK build but cannot be
       
   101   # run from their current location due to relative runtime paths in the
       
   102   # binaries. Move the sysroot/usr/bin directory to the outer bin and have them
       
   103   # be runnable from there to force them to link to the system libraries
       
   104   cp -rH $INSTALL_ROOT/usr/bin $DEVKIT_ROOT
       
   105   cp -rH $INSTALL_ROOT/usr/lib $SYSROOT/usr/
       
   106   cp -rH $INSTALL_ROOT/usr/include $SYSROOT/usr/
       
   107   pkg -R $INSTALL_ROOT list > $SYSROOT/pkg-list.txt
       
   108 else
       
   109   echo "Skipping copying to $SYSROOT"
       
   110 fi
       
   111 
       
   112 if [ ! -d $SOLARIS_STUDIO_DIR ]; then
       
   113   echo "Copying Solaris Studio from $SOLARIS_STUDIO_SRC"
       
   114   cp -rH $SOLARIS_STUDIO_SRC ${SOLARIS_STUDIO_DIR%/*}
       
   115   mv ${SOLARIS_STUDIO_DIR%/*}/${SOLARIS_STUDIO_SRC##*/} $SOLARIS_STUDIO_DIR
       
   116   # Solaris Studio 12.4 requires /lib/libmmheap.so.1 to run, but this lib is not
       
   117   # installed by default on all Solaris systems. Sneak it in from the sysroot to
       
   118   # make it run OOTB on more systems.
       
   119   cp $SYSROOT/lib/libmmheap.so.1 $SOLARIS_STUDIO_DIR/lib/compilers/sys/
       
   120 else
       
   121   echo "Skipping copying of Solaris Studio"
       
   122 fi
       
   123 
       
   124 echo "Copying gnu make to $DEVKIT_ROOT/bin"
       
   125 mkdir -p $DEVKIT_ROOT/bin
       
   126 cp $GNU_MAKE $DEVKIT_ROOT/bin/
       
   127 if [ ! -e $DEVKIT_ROOT/bin/gmake ]; then
       
   128   ln -s make $DEVKIT_ROOT/bin/gmake
       
   129 fi
       
   130 
       
   131 # Create the devkit.info file
       
   132 echo Creating devkit.info
       
   133 INFO_FILE=$DEVKIT_ROOT/devkit.info
       
   134 rm -f $INFO_FILE
       
   135 echo "# This file describes to configure how to interpret the contents of this devkit" >> $INFO_FILE
       
   136 echo "DEVKIT_NAME=\"Solaris Studio $SOLARIS_STUDIO_VERSION - Solaris $SOLARIS_VERSION - $ARCH\"" >> $INFO_FILE
       
   137 echo "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/$SOLARIS_STUDIO_SUBDIR/bin:\$DEVKIT_ROOT/bin\"" >> $INFO_FILE
       
   138 echo "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/bin\"" >> $INFO_FILE
       
   139 echo "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/sysroot\"" >> $INFO_FILE
       
   140 
       
   141 if [ ! -e $BUNDLE ]; then
       
   142   echo "Creating $BUNDLE from $DEVKIT_ROOT"
       
   143   cd $DEVKIT_ROOT/..
       
   144   tar zcf $BUNDLE $DEVKIT_NAME
       
   145 else
       
   146   echo "Skipping creation of $BUNDLE"
       
   147 fi