aoqi@0: #!/bin/bash aoqi@0: # aoqi@0: # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. aoqi@0: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: # aoqi@0: # This code is free software; you can redistribute it and/or modify it aoqi@0: # under the terms of the GNU General Public License version 2 only, as aoqi@0: # published by the Free Software Foundation. aoqi@0: # aoqi@0: # This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: # version 2 for more details (a copy is included in the LICENSE file that aoqi@0: # accompanied this code). aoqi@0: # aoqi@0: # You should have received a copy of the GNU General Public License version aoqi@0: # 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: # aoqi@0: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: # or visit www.oracle.com if you need additional information or have any aoqi@0: # questions. aoqi@0: # aoqi@0: 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: aoqi@0: script_dir=`dirname $0` aoqi@0: aoqi@0: # Create a timestamp as seconds since epoch aoqi@0: if test "x`uname -s`" = "xSunOS"; then aoqi@0: TIMESTAMP=`date +%s` aoqi@0: if test "x$TIMESTAMP" = "x%s"; then aoqi@0: # date +%s not available on this Solaris, use workaround from nawk(1): aoqi@0: TIMESTAMP=`nawk 'BEGIN{print srand()}'` aoqi@0: fi aoqi@0: else aoqi@0: TIMESTAMP=`date +%s` aoqi@0: fi aoqi@0: aoqi@0: 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" aoqi@0: else aoqi@0: custom_script_dir=$CUSTOM_CONFIG_DIR aoqi@0: fi aoqi@0: aoqi@0: custom_hook=$custom_script_dir/custom-hook.m4 aoqi@0: aoqi@0: AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`" aoqi@0: aoqi@0: 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 aoqi@0: exit 1 aoqi@0: fi aoqi@0: 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' aoqi@0: aoqi@0: if test -e $custom_hook; then aoqi@0: # We have custom sources available; also generate configure script aoqi@0: # 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])|"' aoqi@0: else kevinw@2212: echo "(No custom hook found at $custom_hook)" aoqi@0: fi