common/autoconf/autogen.sh
changeset 22722 03797b5d2ba3
parent 22714 a752920c4317
equal deleted inserted replaced
22721:63761da45392 22722:03797b5d2ba3
    20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    21 # or visit www.oracle.com if you need additional information or have any
    21 # or visit www.oracle.com if you need additional information or have any
    22 # questions.
    22 # questions.
    23 #
    23 #
    24 
    24 
       
    25 generate_configure_script() {
       
    26   # First create a header
       
    27   cat > $1 << EOT
       
    28 #!/bin/bash
       
    29 #
       
    30 # ##########################################################
       
    31 # ### THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. ###
       
    32 # ##########################################################
       
    33 #
       
    34 EOT
       
    35   # Then replace "magic" variables in configure.ac and append the output
       
    36   # from autoconf. $2 is either cat (just a no-op) or a filter.
       
    37   cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \
       
    38       eval $2 | ${AUTOCONF} -W all -I$script_dir - >> $1
       
    39   rm -rf autom4te.cache
       
    40 }
       
    41 
    25 script_dir=`dirname $0`
    42 script_dir=`dirname $0`
    26 
    43 
    27 # Create a timestamp as seconds since epoch
    44 # Create a timestamp as seconds since epoch
    28 if test "x`uname -s`" = "xSunOS"; then
    45 if test "x`uname -s`" = "xSunOS"; then
    29   TIMESTAMP=`date +%s`
    46   TIMESTAMP=`date +%s`
    34 else
    51 else
    35   TIMESTAMP=`date +%s`
    52   TIMESTAMP=`date +%s`
    36 fi
    53 fi
    37 
    54 
    38 if test "x$CUSTOM_CONFIG_DIR" = "x"; then
    55 if test "x$CUSTOM_CONFIG_DIR" = "x"; then
    39   custom_script_dir="$script_dir/../../closed/autoconf"
    56   topdir=`cd $script_dir/../..  >/dev/null && pwd`
       
    57   custom_script_dir="$topdir/closed/autoconf"
    40 else
    58 else
    41   custom_script_dir=$CUSTOM_CONFIG_DIR
    59   custom_script_dir=$CUSTOM_CONFIG_DIR
    42 fi
    60 fi
    43 
    61 
    44 custom_hook=$custom_script_dir/custom-hook.m4
    62 custom_hook=$custom_script_dir/custom-hook.m4
    45 
    63 
    46 AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
    64 AUTOCONF="`which autoconf 2> /dev/null | grep -v '^no autoconf in'`"
    47 
    65 
    48 echo "Autoconf found: ${AUTOCONF}"
       
    49 
       
    50 if test "x${AUTOCONF}" = x; then
    66 if test "x${AUTOCONF}" = x; then
    51   echo You need autoconf installed to be able to regenerate the configure script
    67   echo "You need autoconf installed to be able to regenerate the configure script"
    52   echo Error: Cannot find autoconf 1>&2
    68   echo "Error: Cannot find autoconf" 1>&2
    53   exit 1
    69   exit 1
    54 fi
    70 fi
    55 
    71 
    56 echo Generating generated-configure.sh with ${AUTOCONF}
    72 autoconf_version=`$AUTOCONF --version | head -1`
    57 cat $script_dir/configure.ac  | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | ${AUTOCONF} -W all -I$script_dir - > $script_dir/generated-configure.sh
    73 echo "Using autoconf at ${AUTOCONF} [$autoconf_version]"
    58 rm -rf autom4te.cache
    74 
       
    75 echo "Generating generated-configure.sh"
       
    76 generate_configure_script "$script_dir/generated-configure.sh" 'cat'
    59 
    77 
    60 if test -e $custom_hook; then
    78 if test -e $custom_hook; then
    61   echo Generating custom generated-configure.sh
       
    62   # We have custom sources available; also generate configure script
    79   # We have custom sources available; also generate configure script
    63   # with custom hooks compiled in.
    80   # with custom hooks compiled in.
    64   cat $script_dir/configure.ac | sed -e "s|@DATE_WHEN_GENERATED@|$TIMESTAMP|" | \
    81   echo "Generating custom generated-configure.sh"
    65       sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|" | ${AUTOCONF} -W all -I$script_dir - > $custom_script_dir/generated-configure.sh
    82   generate_configure_script "$custom_script_dir/generated-configure.sh" 'sed -e "s|#CUSTOM_AUTOCONF_INCLUDE|m4_include([$custom_hook])|"'
    66   rm -rf autom4te.cache
       
    67 else
    83 else
    68   echo No custom hook found:  $custom_hook
    84   echo "(No custom hook found at $custom_hook)"
    69 fi
    85 fi