ohair@494: #!/bin/bash ohair@425: # ohair@425: # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. ohair@425: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@425: # ohair@425: # This code is free software; you can redistribute it and/or modify it ohair@425: # under the terms of the GNU General Public License version 2 only, as ohair@425: # published by the Free Software Foundation. ohair@425: # ohair@425: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@425: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@425: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@425: # version 2 for more details (a copy is included in the LICENSE file that ohair@425: # accompanied this code). ohair@425: # ohair@425: # You should have received a copy of the GNU General Public License version ohair@425: # 2 along with this work; if not, write to the Free Software Foundation, ohair@425: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@425: # ohair@425: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@425: # or visit www.oracle.com if you need additional information or have any ohair@425: # questions. ohair@425: # ohair@425: kevinw@2212: generate_configure_script() { kevinw@2212: # First create a header kevinw@2212: cat > $1 << EOT kevinw@2212: #!/bin/bash kevinw@2212: # kevinw@2212: # ########################################################## kevinw@2212: # ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ### kevinw@2212: # ########################################################## kevinw@2212: # kevinw@2212: EOT kevinw@2212: # Then replace "magic" variables in configure.ac and append the output kevinw@2212: # from autoconf. $2 is either cat (just a no-op) or a filter. kevinw@2212: cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \ kevinw@2212: eval $2 | ${AUTOCONF} -W all -I$script_dir - >> $1 kevinw@2212: rm -rf autom4te.cache kevinw@2212: } kevinw@2212: erikj@458: script_dir=`dirname $0` erikj@458: erikj@458: # Create a timestamp as seconds since epoch ohair@478: if test "x`uname -s`" = "xSunOS"; then tbell@571: TIMESTAMP=`date +%s` tbell@571: if test "x$TIMESTAMP" = "x%s"; then tbell@571: # date +%s not available on this Solaris, use workaround from nawk(1): tbell@571: TIMESTAMP=`nawk 'BEGIN{print srand()}'` tbell@571: fi ohair@478: else ohair@478: TIMESTAMP=`date +%s` ohair@478: fi erikj@458: ohair@494: if test "x$CUSTOM_CONFIG_DIR" = "x"; then kevinw@2212: topdir=`cd $script_dir/../.. >/dev/null && pwd` kevinw@2212: custom_script_dir="$topdir/jdk/make/closed/autoconf" ohair@478: else ohair@478: custom_script_dir=$CUSTOM_CONFIG_DIR ohair@478: fi ohair@478: ohair@478: custom_hook=$custom_script_dir/custom-hook.m4 ohair@478: tbell@674: AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`" andrew@664: andrew@664: if test "x${AUTOCONF}" = x; then kevinw@2212: echo "You need autoconf installed to be able to regenerate the configure script" kevinw@2212: echo "Error: Cannot find autoconf" 1>&2 ohair@494: exit 1 ohair@494: fi ohair@494: kevinw@2212: autoconf_version=`$AUTOCONF --version | head -1` kevinw@2212: echo "Using autoconf at ${AUTOCONF} [$autoconf_version]" kevinw@2212: kevinw@2212: echo "Generating generated-configure.sh" kevinw@2212: generate_configure_script "$script_dir/generated-configure.sh" 'cat' erikj@458: ohair@494: if test -e $custom_hook; then ohair@478: # We have custom sources available; also generate configure script ohair@478: # with custom hooks compiled in. kevinw@2212: echo "Generating custom generated-configure.sh" kevinw@2212: generate_configure_script "$custom_script_dir/generated-configure.sh" 'sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"' ohair@478: else kevinw@2212: echo "(No custom hook found at $custom_hook)" erikj@458: fi