1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
#!/bin/bash
#
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# This script copies part of an Xcode installer into a devkit suitable
# for building OpenJDK and OracleJDK. The installation .dmg files for Xcode
# and the aux tools need to be available.
# erik.joelsson@oracle.com
USAGE="$0 <Xcode.dmg> <XQuartz.dmg> <gnu make binary> [<auxtools.dmg>]"
if [ "$1" = "" ] || [ "$2" = "" ]; then
echo $USAGE
exit 1
fi
XCODE_DMG="$1"
XQUARTZ_DMG="$2"
GNU_MAKE="$3"
AUXTOOLS_DMG="$4"
SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
# Mount XCODE_DMG
if [ -e "/Volumes/Xcode" ]; then
hdiutil detach /Volumes/Xcode
fi
hdiutil attach $XCODE_DMG
# Find the version of Xcode
XCODE_VERSION="$(/Volumes/Xcode/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version \
| awk '/Xcode/ { print $2 }' )"
SDK_VERSION="MacOSX10.9"
if [ ! -e "/Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk" ]; then
echo "Expected SDK version not found: ${SDK_VERSION}"
exit 1
fi
DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-${SDK_VERSION}"
DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
echo "Xcode version: $XCODE_VERSION"
echo "Creating devkit in $DEVKIT_ROOT"
################################################################################
# Copy files to root
mkdir -p $DEVKIT_ROOT
if [ ! -d $DEVKIT_ROOT/Xcode.app ]; then
echo "Copying Xcode.app..."
cp -RH "/Volumes/Xcode/Xcode.app" $DEVKIT_ROOT/
fi
# Trim out some seemingly unneeded parts to save space.
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Applications
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/iPhone*
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Documentation
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/share/man
( cd $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs \
&& rm -rf `ls | grep -v ${SDK_VERSION}` )
rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/${SDK_VERSION}.sdk/usr/share/man
hdiutil detach /Volumes/Xcode
################################################################################
# Copy Freetype into sysroot
if [ -e "/Volumes/XQuartz-*" ]; then
hdiutil detach /Volumes/XQuartz-*
fi
hdiutil attach $XQUARTZ_DMG
echo "Copying freetype..."
rm -rf /tmp/XQuartz
pkgutil --expand /Volumes/XQuartz-*/XQuartz.pkg /tmp/XQuartz/
rm -rf /tmp/x11
mkdir /tmp/x11
cd /tmp/x11
cat /tmp/XQuartz/x11.pkg/Payload | gunzip -dc | cpio -i
mkdir -p $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/
mkdir -p $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/lib/
cp -RH opt/X11/include/freetype2 \
$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/
cp -RH opt/X11/include/ft2build.h \
$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/include/
cp -RH opt/X11/lib/libfreetype.* \
$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/X11/lib/
cd -
hdiutil detach /Volumes/XQuartz-*
################################################################################
# Copy gnu make
mkdir -p $DEVKIT_ROOT/bin
cp $GNU_MAKE $DEVKIT_ROOT/bin
################################################################################
# Optionally copy PackageMaker
if [ -e "$AUXTOOLS_DMG" ]; then
if [ -e "/Volumes/Auxiliary Tools" ]; then
hdiutil detach "/Volumes/Auxiliary Tools"
fi
hdiutil attach $AUXTOOLS_DMG
echo "Copying PackageMaker.app..."
cp -RH "/Volumes/Auxiliary Tools/PackageMaker.app" $DEVKIT_ROOT/
hdiutil detach "/Volumes/Auxiliary Tools"
fi
################################################################################
# Generate devkit.info
echo-info() {
echo "$1" >> $DEVKIT_ROOT/devkit.info
}
echo "Generating devkit.info..."
rm -f $DEVKIT_ROOT/devkit.info
echo-info "# This file describes to configure how to interpret the contents of this devkit"
echo-info "# The parameters used to create this devkit were:"
echo-info "# $*"
echo-info "DEVKIT_NAME=\"Xcode $XCODE_VERSION (devkit)\""
echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk\""
echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/bin:\$DEVKIT_ROOT/PackageMaker.app/Contents/MacOS:\$DEVKIT_TOOLCHAIN_PATH\""
################################################################################
# Copy this script
echo "Copying this script..."
cp $0 $DEVKIT_ROOT/
################################################################################
# Create bundle
echo "Creating bundle..."
(cd $DEVKIT_ROOT && tar c - . | gzip - > "$DEVKIT_BUNDLE")
|