blob: 861a0a47242c0368d08c3c17634077ef3ca1d9a1 [file] [log] [blame]
Magnus Ihse Bursiea4630a52018-02-05 09:15:32 +01001#!/bin/bash -e
2#
3# Copyright (c) 2018, 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# Create a bundle in the current directory, containing what's needed to run
28# the 'autoconf' program by the OpenJDK build.
29
30# Autoconf depends on m4, so download and build that first.
31AUTOCONF_VERSION=2.69
32M4_VERSION=1.4.18
33
34PACKAGE_VERSION=1.0.1
35TARGET_PLATFORM=linux_x86
36MODULE_NAME=autoconf-$TARGET_PLATFORM-$AUTOCONF_VERSION+$PACKAGE_VERSION
37BUNDLE_NAME=$MODULE_NAME.tar.gz
38
39TMPDIR=`mktemp -d -t autoconfbundle-XXXX`
40trap "rm -rf \"$TMPDIR\"" EXIT
41
42ORIG_DIR=`pwd`
43cd $TMPDIR
44OUTPUT_DIR=$TMPDIR/$MODULE_NAME
45mkdir -p $OUTPUT_DIR/usr
46
47# Download and build m4
48
49if test "x$TARGET_PLATFORM" = xcygwin_x64; then
50 # On cygwin 64-bit, just copy the cygwin .exe file
51 mkdir -p $OUTPUT_DIR/usr/bin
52 cp /usr/bin/m4 $OUTPUT_DIR/usr/bin
53elif test "x$TARGET_PLATFORM" = xcygwin_x86; then
54 # On cygwin 32-bit, just copy the cygwin .exe file
55 mkdir -p $OUTPUT_DIR/usr/bin
56 cp /usr/bin/m4 $OUTPUT_DIR/usr/bin
57elif test "x$TARGET_PLATFORM" = xlinux_x64; then
58 M4_VERSION=1.4.13-5
59 wget http://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/m4-$M4_VERSION.el6.x86_64.rpm
60 cd $OUTPUT_DIR
61 rpm2cpio ../m4-$M4_VERSION.el6.x86_64.rpm | cpio -d -i
62elif test "x$TARGET_PLATFORM" = xlinux_x86; then
63 M4_VERSION=1.4.13-5
64 wget http://yum.oracle.com/repo/OracleLinux/OL6/latest/i386/getPackage/m4-$M4_VERSION.el6.i686.rpm
65 cd $OUTPUT_DIR
66 rpm2cpio ../m4-$M4_VERSION.el6.i686.rpm | cpio -d -i
67else
68 wget https://ftp.gnu.org/gnu/m4/m4-$M4_VERSION.tar.gz
69 tar xzf m4-$M4_VERSION.tar.gz
70 cd m4-$M4_VERSION
71 ./configure --prefix=$OUTPUT_DIR/usr
72 make
73 make install
74 cd ..
75fi
76
77# Download and build autoconf
78
79wget https://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION.tar.gz
80tar xzf autoconf-$AUTOCONF_VERSION.tar.gz
81cd autoconf-$AUTOCONF_VERSION
82./configure --prefix=$OUTPUT_DIR/usr M4=$OUTPUT_DIR/usr/bin/m4
83make
84make install
85cd ..
86
87perl -pi -e "s!$OUTPUT_DIR/!./!" $OUTPUT_DIR/usr/bin/auto* $OUTPUT_DIR/usr/share/autoconf/autom4te.cfg
88cp $OUTPUT_DIR/usr/share/autoconf/autom4te.cfg $OUTPUT_DIR/autom4te.cfg
89
90cat > $OUTPUT_DIR/autoconf << EOF
91#!/bin/bash
92# Get an absolute path to this script
93this_script_dir=\`dirname \$0\`
94this_script_dir=\`cd \$this_script_dir > /dev/null && pwd\`
95
96export M4="\$this_script_dir/usr/bin/m4"
97export AUTOM4TE="\$this_script_dir/usr/bin/autom4te"
98export AUTOCONF="\$this_script_dir/usr/bin/autoconf"
99export AUTOHEADER="\$this_script_dir/usr/bin/autoheader"
100export AC_MACRODIR="\$this_script_dir/usr/share/autoconf"
101export autom4te_perllibdir="\$this_script_dir/usr/share/autoconf"
102
103autom4te_cfg=\$this_script_dir/usr/share/autoconf/autom4te.cfg
104cp \$this_script_dir/autom4te.cfg \$autom4te_cfg
105
106echo 'begin-language: "M4sugar"' >> \$autom4te_cfg
107echo "args: --prepend-include '"\$this_script_dir/usr/share/autoconf"'" >> \$autom4te_cfg
108echo 'end-language: "M4sugar"' >> \$autom4te_cfg
109
110exec \$this_script_dir/usr/bin/autoconf "\$@"
111EOF
112chmod +x $OUTPUT_DIR/autoconf
113cd $OUTPUT_DIR
114tar -cvzf ../$BUNDLE_NAME *
115cd ..
116cp $BUNDLE_NAME "$ORIG_DIR"