autogen.sh revision 781:92facce22941
1139749Simp#!/bin/bash
2128967Srik#
3128967Srik# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
4128967Srik# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5128967Srik#
6128967Srik# This code is free software; you can redistribute it and/or modify it
7128967Srik# under the terms of the GNU General Public License version 2 only, as
8128967Srik# published by the Free Software Foundation.
9128967Srik#
10128967Srik# This code is distributed in the hope that it will be useful, but WITHOUT
11128967Srik# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12128967Srik# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13128967Srik# version 2 for more details (a copy is included in the LICENSE file that
14128967Srik# accompanied this code).
15128967Srik#
16128967Srik# You should have received a copy of the GNU General Public License version
17128967Srik# 2 along with this work; if not, write to the Free Software Foundation,
18128967Srik# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19128967Srik#
20128967Srik# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21130985Srik# or visit www.oracle.com if you need additional information or have any
22128967Srik# questions.
23128967Srik#
24128967Srik
25128967Srikscript_dir=`dirname $0`
26128967Srik
27128967Srik# Create a timestamp as seconds since epoch
28128967Srikif test "x`uname -s`" = "xSunOS"; then
29128967Srik  TIMESTAMP=`date +%s`
30128967Srik  if test "x$TIMESTAMP" = "x%s"; then
31128967Srik    # date +%s not available on this Solaris, use workaround from nawk(1):
32128967Srik    TIMESTAMP=`nawk 'BEGIN{print srand()}'`
33129879Sphk  fi
34128967Srikelse
35128967Srik  TIMESTAMP=`date +%s`
36128967Srikfi
37128967Srik
38138823Srikif test "x$CUSTOM_CONFIG_DIR" = "x"; then
39128967Srik  custom_script_dir="$script_dir/../../jdk/make/closed/autoconf"
40130971Srikelse
41128967Srik  custom_script_dir=$CUSTOM_CONFIG_DIR
42128967Srikfi
43128967Srik
44138673Srikcustom_hook=$custom_script_dir/custom-hook.m4
45138673Srik
46128967SrikAUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
47128967Srik
48128967Srikecho "Autoconf found: ${AUTOCONF}"
49128967Srik
50128967Srikif test "x${AUTOCONF}" = x; then
51128967Srik  echo You need autoconf installed to be able to regenerate the configure script
52133646Srik  echo Error: Cannot find autoconf 1>&2
53128967Srik  exit 1
54128967Srikfi
55128967Srik
56130985Srikecho Generating generated-configure.sh with ${AUTOCONF}
57128967Srikcat $script_dir/configure.ac  | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | ${AUTOCONF} -W all -I$script_dir - > $script_dir/generated-configure.sh
58128967Srikrm -rf autom4te.cache
59147256Sbrooks
60147256Sbrooksif test -e $custom_hook; then
61128967Srik  echo Generating custom generated-configure.sh
62130971Srik  # We have custom sources available; also generate configure script
63128967Srik  # with custom hooks compiled in.
64128967Srik  cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \
65128967Srik    sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|" | ${AUTOCONF} -W all -I$script_dir - > $custom_script_dir/generated-configure.sh
66128967Srik  rm -rf autom4te.cache
67128967Srikelse
68128967Srik  echo No custom hook found:  $custom_hook
69128967Srikfi
70128967Srik