Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
8035495: Improvements in autoconf integration
Browse files Browse the repository at this point in the history
Reviewed-by: ihse, mduigou, tbell
  • Loading branch information
kevinw committed Apr 11, 2018
1 parent 70d670c commit e6d24ad
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 172 deletions.
4 changes: 2 additions & 2 deletions common/autoconf/Makefile.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2011, 2014, 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
Expand All @@ -24,4 +24,4 @@
# This Makefile was generated by configure @DATE_WHEN_CONFIGURED@
# GENERATED FILE, DO NOT EDIT
SPEC:=@OUTPUT_ROOT@/spec.gmk
include @SRC_ROOT@/Makefile
include @TOPDIR@/Makefile
42 changes: 29 additions & 13 deletions common/autoconf/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@
# questions.
#

generate_configure_script() {
# First create a header
cat > $1 << EOT
#!/bin/bash
#
# ##########################################################
# ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ###
# ##########################################################
#
EOT
# Then replace "magic" variables in configure.ac and append the output
# from autoconf. $2 is either cat (just a no-op) or a filter.
cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \
eval $2 | ${AUTOCONF} -W all -I$script_dir - >> $1
rm -rf autom4te.cache
}

script_dir=`dirname $0`

# Create a timestamp as seconds since epoch
Expand All @@ -36,7 +53,8 @@ else
fi

if test "x$CUSTOM_CONFIG_DIR" = "x"; then
custom_script_dir="$script_dir/../../jdk/make/closed/autoconf"
topdir=`cd $script_dir/../.. >/dev/null && pwd`
custom_script_dir="$topdir/jdk/make/closed/autoconf"
else
custom_script_dir=$CUSTOM_CONFIG_DIR
fi
Expand All @@ -45,25 +63,23 @@ custom_hook=$custom_script_dir/custom-hook.m4

AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"

echo "Autoconf found: ${AUTOCONF}"

if test "x${AUTOCONF}" = x; then
echo You need autoconf installed to be able to regenerate the configure script
echo Error: Cannot find autoconf 1>&2
echo "You need autoconf installed to be able to regenerate the configure script"
echo "Error: Cannot find autoconf" 1>&2
exit 1
fi

echo Generating generated-configure.sh with ${AUTOCONF}
cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | ${AUTOCONF} -W all -I$script_dir - > $script_dir/generated-configure.sh
rm -rf autom4te.cache
autoconf_version=`$AUTOCONF --version | head -1`
echo "Using autoconf at ${AUTOCONF} [$autoconf_version]"

echo "Generating generated-configure.sh"
generate_configure_script "$script_dir/generated-configure.sh" 'cat'

if test -e $custom_hook; then
echo Generating custom generated-configure.sh
# We have custom sources available; also generate configure script
# with custom hooks compiled in.
cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \
sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|" | ${AUTOCONF} -W all -I$script_dir - > $custom_script_dir/generated-configure.sh
rm -rf autom4te.cache
echo "Generating custom generated-configure.sh"
generate_configure_script "$custom_script_dir/generated-configure.sh" 'sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
else
echo No custom hook found: $custom_hook
echo "(No custom hook found at $custom_hook)"
fi
28 changes: 17 additions & 11 deletions common/autoconf/basics.m4
Original file line number Diff line number Diff line change
Expand Up @@ -418,28 +418,29 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS],
# Setup basic configuration paths, and platform-specific stuff related to PATHs.
AC_DEFUN_ONCE([BASIC_SETUP_PATHS],
[
# We get the top-level directory from the supporting wrappers.
AC_MSG_CHECKING([for top-level directory])
AC_MSG_RESULT([$TOPDIR])
BASIC_FIXUP_PATH(TOPDIR)
AC_SUBST(TOPDIR)
# SRC_ROOT is a traditional alias for TOPDIR.
SRC_ROOT=$TOPDIR
# Locate the directory of this script.
SCRIPT="[$]0"
AUTOCONF_DIR=`cd \`$DIRNAME $SCRIPT\`; $THEPWDCMD -L`
AUTOCONF_DIR=$TOPDIR/common/autoconf
# Where is the source? It is located two levels above the configure script.
# Save the current directory this script was started from
CURDIR="$PWD"
cd "$AUTOCONF_DIR/../.."
SRC_ROOT="`$THEPWDCMD -L`"
BASIC_FIXUP_PATH(CURDIR)
if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
PATH_SEP=";"
BASIC_CHECK_PATHS_WINDOWS
else
PATH_SEP=":"
fi
AC_SUBST(SRC_ROOT)
AC_SUBST(PATH_SEP)
cd "$CURDIR"
BASIC_FIXUP_PATH(SRC_ROOT)
BASIC_FIXUP_PATH(CURDIR)
if test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
# Add extra search paths on solaris for utilities like ar and as etc...
Expand Down Expand Up @@ -493,13 +494,17 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
[ CONF_NAME=${with_conf_name} ])
# Test from where we are running configure, in or outside of src root.
AC_MSG_CHECKING([where to store configuration])
if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" \
|| test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" \
|| test "x$CURDIR" = "x$SRC_ROOT/make" ; then
# We are running configure from the src root.
# Create a default ./build/target-variant-debuglevel output root.
if test "x${CONF_NAME}" = x; then
AC_MSG_RESULT([in default location])
CONF_NAME="${OPENJDK_TARGET_OS}-${OPENJDK_TARGET_CPU}-${JDK_VARIANT}-${ANDED_JVM_VARIANTS}-${DEBUG_LEVEL}"
else
AC_MSG_RESULT([in build directory with custom name])
fi
OUTPUT_ROOT="$SRC_ROOT/build/${CONF_NAME}"
$MKDIR -p "$OUTPUT_ROOT"
Expand All @@ -515,6 +520,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
CONF_NAME=`$ECHO $CURDIR | $SED -e "s!^${SRC_ROOT}/build/!!"`
fi
OUTPUT_ROOT="$CURDIR"
AC_MSG_RESULT([in current directory])
# WARNING: This might be a bad thing to do. You need to be sure you want to
# have a configuration in this directory. Do some sanity checks!
Expand Down
4 changes: 2 additions & 2 deletions common/autoconf/compare.sh.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, 2014, 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
Expand Down Expand Up @@ -64,7 +64,7 @@ UNIQ="@UNIQ@"
UNPACK200="@FIXPATH@ @BOOT_JDK@/bin/unpack200"
UNZIP="@UNZIP@"

SRC_ROOT="@SRC_ROOT@"
SRC_ROOT="@TOPDIR@"

if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
PATH="@VS_PATH@"
Expand Down
23 changes: 15 additions & 8 deletions common/autoconf/configure
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,29 @@
# questions.
#

if test "x$BASH_VERSION" = x; then
echo This script needs bash to run.
echo It is recommended to use the configure script in the source tree root instead.
if test "x$1" != xCHECKME; then
echo "This script cannot be run directly."
echo "Use the 'configure' script in the top-level directory instead."
exit 1
fi

# Force autoconf to use bash. This also means we must disable autoconf re-exec.
export CONFIG_SHELL=$BASH
export _as_can_reexec=no

conf_script_dir=`dirname $0`
# Now the next argument is the absolute top-level directory path.
# The TOPDIR variable is passed on to configure.ac.
TOPDIR="$2"
# Remove these two arguments to get to the user supplied arguments
shift
shift

conf_script_dir="$TOPDIR/common/autoconf"

if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
conf_custom_script_dir="$TOPDIR/jdk/make/closed/autoconf"
else
conf_custom_script_dir=$CUSTOM_CONFIG_DIR
conf_custom_script_dir="$CUSTOM_CONFIG_DIR"
fi

###
Expand Down Expand Up @@ -230,10 +237,10 @@ conf_processed_arguments=("--enable-option-checking=fatal" "${conf_processed_arg
###
if test -e $conf_custom_script_dir/generated-configure.sh; then
# Custom source configure available; run that instead
echo Running custom generated-configure.sh
echo "Running custom generated-configure.sh"
conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
else
echo Running generated-configure.sh
echo "Running generated-configure.sh"
conf_script_to_run=$conf_script_dir/generated-configure.sh
fi

Expand Down
2 changes: 1 addition & 1 deletion common/autoconf/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
AC_PREREQ([2.69])
AC_INIT(OpenJDK, jdk8, build-dev@openjdk.java.net,,http://openjdk.java.net)

AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_AUX_DIR([common/autoconf/build-aux])
m4_include([build-aux/pkg.m4])

# Include these first...
Expand Down
Loading

0 comments on commit e6d24ad

Please sign in to comment.