make/devkit/createSolarisDevkit.sh
changeset 49093 ca29679eafe5
parent 49092 6dc5e0cdb44c
parent 48923 b75c9e2e3b1f
child 49094 ca51cc708843
equal deleted inserted replaced
49092:6dc5e0cdb44c 49093:ca29679eafe5
     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-$SOLARIS_VERSION
       
    77 INSTALL_ROOT_TOOLS=${BUILD_DIR}/install-root-tools-$SOLARIS_VERSION
       
    78 SYSROOT=${DEVKIT_ROOT}/sysroot
       
    79 SOLARIS_STUDIO_SUBDIR=SS${SOLARIS_STUDIO_VERSION}
       
    80 SOLARIS_STUDIO_DIR=${DEVKIT_ROOT}/${SOLARIS_STUDIO_SUBDIR}
       
    81 
       
    82 # Extract the publisher from the system
       
    83 if [ -z "${PUBLISHER_URI}" ]; then
       
    84   PUBLISHER_URI="$(pkg publisher solaris | grep URI | awk '{ print $3 }')"
       
    85 fi
       
    86 
       
    87 if [ ! -d $INSTALL_ROOT ]; then
       
    88   echo "Creating $INSTALL_ROOT and installing packages"
       
    89   pkg image-create $INSTALL_ROOT
       
    90   pkg -R $INSTALL_ROOT set-publisher -P -g ${PUBLISHER_URI} solaris
       
    91   pkg -R $INSTALL_ROOT install --accept $(cat solaris11.1-package-list.txt)
       
    92 else
       
    93   echo "Skipping installing packages"
       
    94 fi
       
    95 
       
    96 # Since we have implicitly been running 11.2 tools for a long time, we need
       
    97 # to pick them for the tools dir in the devkit. Create a separate install-root
       
    98 # for it.
       
    99 if [ ! -d $INSTALL_ROOT_TOOLS ]; then
       
   100   echo "Creating $INSTALL_ROOT_TOOLS and installing packages"
       
   101   pkg image-create $INSTALL_ROOT_TOOLS
       
   102   pkg -R $INSTALL_ROOT_TOOLS set-publisher -P -g ${PUBLISHER_URI} solaris
       
   103   sudo pkg -R $INSTALL_ROOT_TOOLS install --accept \
       
   104       entire@0.5.11-0.175.2.5.0.5.0 \
       
   105       system/linker \
       
   106       developer/base-developer-utilities \
       
   107       developer/gnu-binutils
       
   108 else
       
   109   echo "Skipping installing tools packages"
       
   110 fi
       
   111 
       
   112 if [ ! -d $SYSROOT ]; then
       
   113   echo "Copying from $INSTALL_ROOT to $SYSROOT"
       
   114   mkdir -p $SYSROOT
       
   115   cp -rH $INSTALL_ROOT/lib $SYSROOT/
       
   116   mkdir $SYSROOT/usr
       
   117   cp -rH $INSTALL_ROOT/usr/lib $SYSROOT/usr/
       
   118   cp -rH $INSTALL_ROOT/usr/include $SYSROOT/usr/
       
   119   pkg -R $INSTALL_ROOT list > $SYSROOT/pkg-list.txt
       
   120 else
       
   121   echo "Skipping copying to $SYSROOT"
       
   122 fi
       
   123 
       
   124 if [ ! -d $DEVKIT_ROOT/tools ]; then
       
   125   echo "Copying from $INSTALL_ROOT_TOOLS to $DEVKIT_ROOT/tools"
       
   126   # Some of the tools in sysroot are needed in the OpenJDK build. We need
       
   127   # to copy them into a tools dir, including their specific libraries.
       
   128   mkdir -p $DEVKIT_ROOT/tools/usr/bin/sparcv9 $DEVKIT_ROOT/tools/lib/sparcv9 \
       
   129       $DEVKIT_ROOT/tools/usr/gnu/bin
       
   130   cp $INSTALL_ROOT_TOOLS/usr/bin/{ar,nm,strip,ld,ldd} \
       
   131        $DEVKIT_ROOT/tools/usr/bin/
       
   132   cp $INSTALL_ROOT_TOOLS/usr/bin/sparcv9/{ar,nm,strip,ld,ldd} \
       
   133        $DEVKIT_ROOT/tools/usr/bin/sparcv9/
       
   134   cp $INSTALL_ROOT_TOOLS/usr/sbin/dtrace $DEVKIT_ROOT/tools/usr/bin/
       
   135   cp $INSTALL_ROOT_TOOLS/usr/sbin/sparcv9/dtrace $DEVKIT_ROOT/tools/usr/bin/sparcv9/
       
   136   cp -rH $INSTALL_ROOT_TOOLS/usr/gnu/bin/* $DEVKIT_ROOT/tools/usr/gnu/bin/
       
   137   cp $INSTALL_ROOT_TOOLS/lib/{libelf.so*,libld.so*,liblddbg.so*} \
       
   138       $DEVKIT_ROOT/tools/lib/
       
   139   cp $INSTALL_ROOT_TOOLS/lib/sparcv9/{libelf.so*,libld.so*,liblddbg.so*} \
       
   140       $DEVKIT_ROOT/tools/lib/sparcv9/
       
   141   for t in $(ls $DEVKIT_ROOT/tools/usr/gnu/bin); do
       
   142     if [ -f $DEVKIT_ROOT/tools/usr/gnu/bin/$t ]; then
       
   143       ln -s ../gnu/bin/$t $DEVKIT_ROOT/tools/usr/bin/g$t
       
   144     fi
       
   145   done
       
   146 else
       
   147   echo "Skipping copying to tools dir $DEVKIT_ROOT/tools"
       
   148 fi
       
   149 
       
   150 if [ ! -d $SOLARIS_STUDIO_DIR ]; then
       
   151   echo "Copying Solaris Studio from $SOLARIS_STUDIO_SRC"
       
   152   mkdir -p ${SOLARIS_STUDIO_DIR}
       
   153   cp -rH $SOLARIS_STUDIO_SRC/. ${SOLARIS_STUDIO_DIR}/
       
   154   # Solaris Studio 12.4 requires /lib/libmmheap.so.1 to run, but this lib is not
       
   155   # installed by default on all Solaris systems. Sneak it in from the sysroot to
       
   156   # make it run OOTB on more systems.
       
   157   cp $SYSROOT/lib/libmmheap.so.1 $SOLARIS_STUDIO_DIR/lib/compilers/sys/
       
   158 else
       
   159   echo "Skipping copying of Solaris Studio"
       
   160 fi
       
   161 
       
   162 echo "Copying gnu make to $DEVKIT_ROOT/bin"
       
   163 cp $GNU_MAKE $DEVKIT_ROOT/tools/usr/bin/
       
   164 if [ ! -e $DEVKIT_ROOT/tools/usr/bin/gmake ]; then
       
   165   ln -s make $DEVKIT_ROOT/tools/usr/bin/gmake
       
   166 fi
       
   167 
       
   168 # Create the devkit.info file
       
   169 echo Creating devkit.info
       
   170 INFO_FILE=$DEVKIT_ROOT/devkit.info
       
   171 rm -f $INFO_FILE
       
   172 echo "# This file describes to configure how to interpret the contents of this devkit" >> $INFO_FILE
       
   173 echo "DEVKIT_NAME=\"Solaris Studio $SOLARIS_STUDIO_VERSION - Solaris $SOLARIS_VERSION - $ARCH\"" >> $INFO_FILE
       
   174 echo "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/$SOLARIS_STUDIO_SUBDIR/bin:\$DEVKIT_ROOT/bin\"" >> $INFO_FILE
       
   175 echo "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/tools/usr/bin\"" >> $INFO_FILE
       
   176 echo "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/sysroot\"" >> $INFO_FILE
       
   177 
       
   178 if [ ! -e $BUNDLE ]; then
       
   179   echo "Creating $BUNDLE from $DEVKIT_ROOT"
       
   180   cd $DEVKIT_ROOT/..
       
   181   tar zcf $BUNDLE $DEVKIT_NAME
       
   182 else
       
   183   echo "Skipping creation of $BUNDLE"
       
   184 fi