createSolarisDevkit.sh revision 1828:ca96c0c2104b
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
48USAGE="$0 <Solaris Studio installation> <Path to gnu make binary>"
49
50if [ "$1" = "" ] || [ "$2" = "" ]; then
51  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
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
108else
109  echo "Skipping copying to $SYSROOT"
110fi
111
112if [ ! -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/
120else
121  echo "Skipping copying of Solaris Studio"
122fi
123
124echo "Copying gnu make to $DEVKIT_ROOT/bin"
125mkdir -p $DEVKIT_ROOT/bin
126cp $GNU_MAKE $DEVKIT_ROOT/bin/
127if [ ! -e $DEVKIT_ROOT/bin/gmake ]; then
128  ln -s make $DEVKIT_ROOT/bin/gmake
129fi
130
131# Create the devkit.info file
132echo Creating devkit.info
133INFO_FILE=$DEVKIT_ROOT/devkit.info
134rm -f $INFO_FILE
135echo "# This file describes to configure how to interpret the contents of this devkit" >> $INFO_FILE
136echo "DEVKIT_NAME=\"Solaris Studio $SOLARIS_STUDIO_VERSION - Solaris $SOLARIS_VERSION - $ARCH\"" >> $INFO_FILE
137echo "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/$SOLARIS_STUDIO_SUBDIR/bin:\$DEVKIT_ROOT/bin\"" >> $INFO_FILE
138echo "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/bin\"" >> $INFO_FILE
139echo "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/sysroot\"" >> $INFO_FILE
140
141if [ ! -e $BUNDLE ]; then
142  echo "Creating $BUNDLE from $DEVKIT_ROOT"
143  cd $DEVKIT_ROOT/..
144  tar zcf $BUNDLE $DEVKIT_NAME
145else
146  echo "Skipping creation of $BUNDLE"
147fi
148