11#! /bin/bash -e
22#
3- # Copyright (c) 2018, 2024 , Oracle and/or its affiliates. All rights reserved.
3+ # Copyright (c) 2018, 2025 , Oracle and/or its affiliates. All rights reserved.
44# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
55#
66# This code is free software; you can redistribute it and/or modify it
2424# questions.
2525#
2626
27- # Create a bundle in the current directory , containing what's needed to run
27+ # Create a bundle in OpenJDK build folder , containing what's needed to run
2828# the 'autoconf' program by the OpenJDK build. To override TARGET_PLATFORM
2929# just set the variable before running this script.
3030
31+ # This script fetches sources from network so make sure your proxy is setup appropriately.
32+
33+ # colored print to highlight some of the logs
34+ function print_log()
35+ {
36+ Color_Cyan=' \033[1;36m' # Cyan
37+ Color_Off=' \033[0m' # Reset color
38+ printf " ${Color_Cyan} > $1 ${Color_Off} \n"
39+ }
40+
41+
3142# Autoconf depends on m4, so download and build that first.
3243AUTOCONF_VERSION=2.69
3344M4_VERSION=1.4.18
@@ -58,11 +69,12 @@ MODULE_NAME=autoconf-$TARGET_PLATFORM-$AUTOCONF_VERSION+$PACKAGE_VERSION
5869BUNDLE_NAME=$MODULE_NAME .tar.gz
5970
6071SCRIPT_DIR=" $( cd " $( dirname $0 ) " > /dev/null && pwd) "
61- OUTPUT_ROOT=" ${SCRIPT_DIR} /../../build/autoconf"
72+ BASEDIR=" $( cd " $SCRIPT_DIR /../.." > /dev/null && pwd) "
73+ OUTPUT_ROOT=" $BASEDIR /build/autoconf"
6274
63- cd $OUTPUT_ROOT
6475IMAGE_DIR=$OUTPUT_ROOT /$MODULE_NAME
6576mkdir -p $IMAGE_DIR /usr
77+ cd $OUTPUT_ROOT
6678
6779# Download and build m4
6880
@@ -76,7 +88,7 @@ elif test "x$TARGET_PLATFORM" = xcygwin_x86; then
7688 cp /usr/bin/m4 $IMAGE_DIR /usr/bin
7789elif test " x$TARGET_PLATFORM " = xlinux_x64; then
7890 M4_VERSION=1.4.13-5
79- wget http ://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/m4-$M4_VERSION .el6.x86_64.rpm
91+ wget https ://yum.oracle.com/repo/OracleLinux/OL6/latest/x86_64/getPackage/m4-$M4_VERSION .el6.x86_64.rpm
8092 cd $IMAGE_DIR
8193 rpm2cpio $OUTPUT_ROOT /m4-$M4_VERSION .el6.x86_64.rpm | cpio -d -i
8294elif test " x$TARGET_PLATFORM " = xlinux_x86; then
@@ -85,27 +97,38 @@ elif test "x$TARGET_PLATFORM" = xlinux_x86; then
8597 cd $IMAGE_DIR
8698 rpm2cpio $OUTPUT_ROOT /m4-$M4_VERSION .el6.i686.rpm | cpio -d -i
8799else
100+ print_log " m4: download"
88101 wget https://ftp.gnu.org/gnu/m4/m4-$M4_VERSION .tar.gz
89- tar xzf m4-$M4_VERSION .tar.gz
102+ tar - xzf m4-$M4_VERSION .tar.gz
90103 cd m4-$M4_VERSION
104+ print_log " m4: configure"
91105 ./configure --prefix=$IMAGE_DIR /usr CFLAGS=" -w -Wno-everything"
106+ print_log " m4: make"
92107 make
108+ print_log " m4: make install"
93109 make install
94110 cd ..
95111fi
96112
97113# Download and build autoconf
98114
115+ print_log " autoconf: download"
99116wget https://ftp.gnu.org/gnu/autoconf/autoconf-$AUTOCONF_VERSION .tar.gz
100- tar xzf autoconf-$AUTOCONF_VERSION .tar.gz
117+ tar - xzf autoconf-$AUTOCONF_VERSION .tar.gz
101118cd autoconf-$AUTOCONF_VERSION
119+ print_log " autoconf: configure"
102120./configure --prefix=$IMAGE_DIR /usr M4=$IMAGE_DIR /usr/bin/m4
121+ print_log " autoconf: make"
103122make
123+ print_log " autoconf: make install"
104124make install
105125cd ..
106126
127+ # The resulting scripts from installation folder use absolute paths to reference other files within installation folder
128+ print_log " replace absolue paths from installation files with a relative ."
107129perl -pi -e " s!$IMAGE_DIR /!./!" $IMAGE_DIR /usr/bin/auto* $IMAGE_DIR /usr/share/autoconf/autom4te.cfg
108130
131+ print_log " creating $IMAGE_DIR /autoconf wrapper script"
109132cat > $IMAGE_DIR /autoconf << EOF
110133#!/bin/bash
111134# Get an absolute path to this script
@@ -123,6 +146,9 @@ PREPEND_INCLUDE="--prepend-include \$this_script_dir/usr/share/autoconf"
123146
124147exec \$ this_script_dir/usr/bin/autoconf \$ PREPEND_INCLUDE "\$ @"
125148EOF
149+
126150chmod +x $IMAGE_DIR /autoconf
151+
152+ print_log " archiving $IMAGE_DIR directory as $OUTPUT_ROOT /$BUNDLE_NAME "
127153cd $IMAGE_DIR
128154tar -cvzf $OUTPUT_ROOT /$BUNDLE_NAME *
0 commit comments