createSolarisDevkit.sh revision 1839:237c481cc3e3
119914Swollman#!/bin/bash
250476Speter#
31558Srgrimes# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
4156905Sru# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5156905Sru#
61558Srgrimes# This code is free software; you can redistribute it and/or modify it
725451Speter# under the terms of the GNU General Public License version 2 only, as
8138593Ssam# published by the Free Software Foundation.  Oracle designates this
925451Speter# particular file as subject to the "Classpath" exception as provided
10138593Ssam# by Oracle in the LICENSE file that accompanied this code.
11138593Ssam#
12138593Ssam# This code is distributed in the hope that it will be useful, but WITHOUT
13138593Ssam# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14138593Ssam# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15138593Ssam# version 2 for more details (a copy is included in the LICENSE file that
16138593Ssam# accompanied this code).
17138593Ssam#
18138593Ssam# You should have received a copy of the GNU General Public License version
19138593Ssam# 2 along with this work; if not, write to the Free Software Foundation,
20138593Ssam# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2144764Swpaul#
22138593Ssam# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23138593Ssam# or visit www.oracle.com if you need additional information or have any
24138593Ssam# questions.
25138593Ssam#
26181224Sthompsa
27193664Shrs# This script creates a devkit for building OpenJDK on Solaris by copying
2877217Sphk# part of a Solaris Studio installation and cretaing a sysroot by installing
29178354Ssam# a limited set of system packages. It is assumed that a suitable pkg
30178354Ssam# publisher is configured for the system where the script is executed.
31178354Ssam#
32178354Ssam# The Solaris Studio installation must contain at least these packages:
33142215Sglebius# developer/solarisstudio-124/backend               12.4-1.0.6.0               i--
34159781Smlaier# developer/solarisstudio-124/c++                   12.4-1.0.10.0              i--
35142215Sglebius# developer/solarisstudio-124/cc                    12.4-1.0.4.0               i--
36142215Sglebius# developer/solarisstudio-124/library/c++-libs      12.4-1.0.10.0              i--
37146987Sthompsa# developer/solarisstudio-124/library/math-libs     12.4-1.0.0.1               i--
38168793Sthompsa# developer/solarisstudio-124/library/studio-gccrt  12.4-1.0.0.1               i--
39146987Sthompsa# developer/solarisstudio-124/studio-common         12.4-1.0.0.1               i--
40156905Sru# developer/solarisstudio-124/studio-ja             12.4-1.0.0.1               i--
41138593Ssam# developer/solarisstudio-124/studio-legal          12.4-1.0.0.1               i--
42178354Ssam# developer/solarisstudio-124/studio-zhCN           12.4-1.0.0.1               i--
43178354Ssam# In particular backend 12.4-1.0.6.0 contains a critical patch for the sparc
4480057Sobrien# version.
4580057Sobrien#
46138593Ssam# erik.joelsson@oracle.com
47138593Ssam
48144130SbrooksUSAGE="$0 <Solaris Studio installation> <Path to gnu make binary>"
49126178Sjohan
501558Srgrimesif [ "$1" = "" ] || [ "$2" = "" ]; then
511558Srgrimes  echo $USAGE
52  exit 1
53fi
54
55SOLARIS_STUDIO_VERSION=12u4
56SOLARIS_VERSION=11u1
57case `uname -p` in
58  i*)
59    ARCH=x86
60    ;;
61  sparc*)
62    ARCH=sparc
63    ;;
64esac
65
66SOLARIS_STUDIO_SRC=$1
67GNU_MAKE=$2
68
69SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
70BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
71
72DEVKIT_NAME=SS${SOLARIS_STUDIO_VERSION}-Solaris${SOLARIS_VERSION}
73DEVKIT_ROOT=${BUILD_DIR}/${DEVKIT_NAME}
74BUNDLE_NAME=${DEVKIT_NAME}.tar.gz
75BUNDLE=${BUILD_DIR}/${BUNDLE_NAME}
76INSTALL_ROOT=${BUILD_DIR}/install-root
77SYSROOT=${DEVKIT_ROOT}/sysroot
78SOLARIS_STUDIO_SUBDIR=SS${SOLARIS_STUDIO_VERSION}
79SOLARIS_STUDIO_DIR=${DEVKIT_ROOT}/${SOLARIS_STUDIO_SUBDIR}
80
81# Extract the publisher from the system
82if [ -z "${PUBLISHER_URI}" ]; then
83  PUBLISHER_URI="$(pkg publisher solaris | grep URI | awk '{ print $3 }')"
84fi
85
86if [ ! -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)
91else
92  echo "Skipping installing packages"
93fi
94
95if [ ! -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 $DEVKIT_ROOT/gnu
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/gnu/bin $DEVKIT_ROOT/gnu/
106  cp -rH $INSTALL_ROOT/usr/lib $SYSROOT/usr/
107  cp -rH $INSTALL_ROOT/usr/include $SYSROOT/usr/
108  pkg -R $INSTALL_ROOT list > $SYSROOT/pkg-list.txt
109else
110  echo "Skipping copying to $SYSROOT"
111fi
112
113if [ ! -d $SOLARIS_STUDIO_DIR ]; then
114  echo "Copying Solaris Studio from $SOLARIS_STUDIO_SRC"
115  cp -rH $SOLARIS_STUDIO_SRC ${SOLARIS_STUDIO_DIR%/*}
116  mv ${SOLARIS_STUDIO_DIR%/*}/${SOLARIS_STUDIO_SRC##*/} $SOLARIS_STUDIO_DIR
117  # Solaris Studio 12.4 requires /lib/libmmheap.so.1 to run, but this lib is not
118  # installed by default on all Solaris systems. Sneak it in from the sysroot to
119  # make it run OOTB on more systems.
120  cp $SYSROOT/lib/libmmheap.so.1 $SOLARIS_STUDIO_DIR/lib/compilers/sys/
121else
122  echo "Skipping copying of Solaris Studio"
123fi
124
125echo "Copying gnu make to $DEVKIT_ROOT/bin"
126mkdir -p $DEVKIT_ROOT/bin
127cp $GNU_MAKE $DEVKIT_ROOT/bin/
128if [ ! -e $DEVKIT_ROOT/bin/gmake ]; then
129  ln -s make $DEVKIT_ROOT/bin/gmake
130fi
131
132# Create the devkit.info file
133echo Creating devkit.info
134INFO_FILE=$DEVKIT_ROOT/devkit.info
135rm -f $INFO_FILE
136echo "# This file describes to configure how to interpret the contents of this devkit" >> $INFO_FILE
137echo "DEVKIT_NAME=\"Solaris Studio $SOLARIS_STUDIO_VERSION - Solaris $SOLARIS_VERSION - $ARCH\"" >> $INFO_FILE
138echo "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/$SOLARIS_STUDIO_SUBDIR/bin:\$DEVKIT_ROOT/bin\"" >> $INFO_FILE
139echo "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/bin\"" >> $INFO_FILE
140echo "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/sysroot\"" >> $INFO_FILE
141
142if [ ! -e $BUNDLE ]; then
143  echo "Creating $BUNDLE from $DEVKIT_ROOT"
144  cd $DEVKIT_ROOT/..
145  tar zcf $BUNDLE $DEVKIT_NAME
146else
147  echo "Skipping creation of $BUNDLE"
148fi
149