autogen.sh revision 662:15c1642967c9
138494Sobrien#!/bin/bash
238494Sobrien#
338494Sobrien# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
438494Sobrien# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
538494Sobrien#
638494Sobrien# This code is free software; you can redistribute it and/or modify it
738494Sobrien# under the terms of the GNU General Public License version 2 only, as
838494Sobrien# published by the Free Software Foundation.
938494Sobrien#
1038494Sobrien# This code is distributed in the hope that it will be useful, but WITHOUT
1138494Sobrien# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1238494Sobrien# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1338494Sobrien# version 2 for more details (a copy is included in the LICENSE file that
1438494Sobrien# accompanied this code).
1538494Sobrien#
1638494Sobrien# You should have received a copy of the GNU General Public License version
1738494Sobrien# 2 along with this work; if not, write to the Free Software Foundation,
1838494Sobrien# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1938494Sobrien#
2038494Sobrien# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2138494Sobrien# or visit www.oracle.com if you need additional information or have any
2238494Sobrien# questions.
2338494Sobrien#
2438494Sobrien
2538494Sobrienscript_dir=`dirname $0`
2638494Sobrien
2738494Sobrien# Create a timestamp as seconds since epoch
2838494Sobrienif test "x`uname -s`" = "xSunOS"; then
2938494Sobrien  TIMESTAMP=`date +%s`
3038494Sobrien  if test "x$TIMESTAMP" = "x%s"; then
3141142Sobrien    # date +%s not available on this Solaris, use workaround from nawk(1):
3241142Sobrien    TIMESTAMP=`nawk 'BEGIN{print srand()}'`
3351292Sobrien  fi
3451292Sobrienelse
3551292Sobrien  TIMESTAMP=`date +%s`
3651292Sobrienfi
3738494Sobrien
3838494Sobrienif test "x$CUSTOM_CONFIG_DIR" = "x"; then
3938494Sobrien  custom_script_dir="$script_dir/../../jdk/make/closed/autoconf"
4038494Sobrienelse
4138494Sobrien  custom_script_dir=$CUSTOM_CONFIG_DIR
4238494Sobrienfi
4338494Sobrien
4438494Sobriencustom_hook=$custom_script_dir/custom-hook.m4
4538494Sobrien
4638494SobrienAUTOCONF=$(which autoconf 2> /dev/null);
4738494SobrienAUTOCONF_267=$(which autoconf-2.67 2> /dev/null);
4838494Sobrien
4938494Sobrienecho "Autoconf found: ${AUTOCONF}"
5038494Sobrienecho "Autoconf-2.67 found: ${AUTOCONF_267}"
5138494Sobrien
5238494Sobrienif test "x${AUTOCONF}" = x; then
5338494Sobrien  echo You need autoconf installed to be able to regenerate the configure script
5438494Sobrien  echo Error: Cannot find autoconf 1>&2
5538494Sobrien  exit 1
5638494Sobrienfi
5738494Sobrien
5838494Sobrienif test "x${AUTOCONF_267}" != x; then
5938494Sobrien  AUTOCONF=${AUTOCONF_267};
6038494Sobrienfi
6138494Sobrien
6238494Sobrienecho Generating generated-configure.sh with ${AUTOCONF}
6338494Sobriencat $script_dir/configure.ac  | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | ${AUTOCONF} -W all -I$script_dir - > $script_dir/generated-configure.sh
6438494Sobrienrm -rf autom4te.cache
6538494Sobrien
6638494Sobrienif test -e $custom_hook; then
6738494Sobrien  echo Generating custom generated-configure.sh
6838494Sobrien  # We have custom sources available; also generate configure script
6938494Sobrien  # with custom hooks compiled in.
7038494Sobrien  cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \
7138494Sobrien    sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|" | ${AUTOCONF} -W all -I$script_dir - > $custom_script_dir/generated-configure.sh
7238494Sobrien  rm -rf autom4te.cache
7338494Sobrienelse
7438494Sobrien  echo No custom hook found:  $custom_hook
7538494Sobrienfi
7638494Sobrien