Blame buildconf

Packit 90a5c9
#!/bin/sh
Packit 90a5c9
#
Packit 90a5c9
# Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
# contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
# this work for additional information regarding copyright ownership.
Packit 90a5c9
# The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
# (the "License"); you may not use this file except in compliance with
Packit 90a5c9
# the License.  You may obtain a copy of the License at
Packit 90a5c9
#
Packit 90a5c9
#     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
#
Packit 90a5c9
# Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
# distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
# See the License for the specific language governing permissions and
Packit 90a5c9
# limitations under the License.
Packit 90a5c9
#
Packit 90a5c9
#
Packit 90a5c9
# buildconf: Build the support scripts needed to compile from a
Packit 90a5c9
#            checked-out version of the source code.
Packit 90a5c9
Packit 90a5c9
# version check for AC_PROG_CC_C99
Packit 90a5c9
ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;q'`
Packit 90a5c9
case "$ac_version" in
Packit 90a5c9
# versions older than 2.50 are denied by AC_PREREQ
Packit 90a5c9
2.5*)
Packit 90a5c9
    echo WARNING: You are using an outdated version of autoconf.
Packit 90a5c9
    echo WARNING: This may lead to less than optimal performance of httpd.
Packit 90a5c9
    echo WARNING: You should use autoconf 2.60 or newer.
Packit 90a5c9
    sleep 1
Packit 90a5c9
    ;;
Packit 90a5c9
esac
Packit 90a5c9
Packit 90a5c9
# set a couple of defaults for where we should be looking for our support libs.
Packit 90a5c9
# can be overridden with --with-apr=[dir] and --with-apr-util=[dir]
Packit 90a5c9
Packit 90a5c9
apr_src_dir="srclib/apr ../apr"
Packit 90a5c9
apu_src_dir=""
Packit 90a5c9
Packit 90a5c9
while test $# -gt 0 
Packit 90a5c9
do
Packit 90a5c9
    # Normalize
Packit 90a5c9
    case "$1" in
Packit 90a5c9
    -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
Packit 90a5c9
    *) optarg= ;;
Packit 90a5c9
    esac
Packit 90a5c9
Packit 90a5c9
    case "$1" in
Packit 90a5c9
    --with-apr=*)
Packit 90a5c9
        apr_src_dir=$optarg
Packit 90a5c9
        ;;
Packit 90a5c9
Packit 90a5c9
    --with-apr-util=*)
Packit 90a5c9
        apu_src_dir=$optarg
Packit 90a5c9
        ;;
Packit 90a5c9
Packit 90a5c9
    -h|--help)
Packit 90a5c9
        cat <
Packit 90a5c9
buildconf: generates the files needed to configure httpd.
Packit 90a5c9
Packit 90a5c9
Usage: $0 [OPTION]...
Packit 90a5c9
Packit 90a5c9
Configuration:
Packit 90a5c9
  -h, --help               display this help and exit
Packit 90a5c9
Packit 90a5c9
  --with-apr=SRCDIR        define a space-separated list of directories to
Packit 90a5c9
                           search for the APR source code. If, instead of a
Packit 90a5c9
                           directory, an apr-config executable name is passed,
Packit 90a5c9
                           APR-Config Mode is enabled (see below). Defaults to
Packit 90a5c9
                           "srclib/apr ../apr"
Packit 90a5c9
  --with-apr-util=SRCDIR   define a space-separated list of directories to
Packit 90a5c9
                           search for the APR-util source code. Defaults to the
Packit 90a5c9
                           same location as the --with-apr SRCDIR, but with
Packit 90a5c9
                           "apr" replaced with "apr-util" or "aprutil". Ignored
Packit 90a5c9
                           in APR-Config Mode.
Packit 90a5c9
Packit 90a5c9
APR-Config Mode:
Packit 90a5c9
Packit 90a5c9
  When passing an apr-config executable to --with-apr, buildconf will attempt to
Packit 90a5c9
  copy build scripts from various installed locations on your system instead of
Packit 90a5c9
  an APR source tree. This allows you to configure httpd from source without
Packit 90a5c9
  also requiring you to download the APR and/or APR-util sources.
Packit 90a5c9
Packit 90a5c9
  For example:
Packit 90a5c9
Packit 90a5c9
      ./buildconf --with-apr=apr-1-config
Packit 90a5c9
Packit 90a5c9
  For this functionality to work reliably, you must have automake >= 1.12 and be
Packit 90a5c9
  using a distribution that includes both find_apr.m4 and find_apu.m4 in the
Packit 90a5c9
  --installbuilddir pointed to by apr-config.
Packit 90a5c9
Packit 90a5c9
Environment variables used by buildconf:
Packit 90a5c9
  AUTOCONF           autoconf executable name [autoconf]
Packit 90a5c9
  AUTOMAKE           automake executable name [automake]
Packit 90a5c9
  AUTOHEADER         autoheader executable name [autoheader]
Packit 90a5c9
EOF
Packit 90a5c9
        exit
Packit 90a5c9
        ;;
Packit 90a5c9
Packit 90a5c9
    *)
Packit 90a5c9
        echo "unknown option $1 (try --help for usage)"
Packit 90a5c9
        exit 1
Packit 90a5c9
        ;;
Packit 90a5c9
    esac
Packit 90a5c9
Packit 90a5c9
    shift
Packit 90a5c9
done
Packit 90a5c9
Packit 90a5c9
#
Packit 90a5c9
# Check to be sure that we have the srclib dependencies checked-out, or that a
Packit 90a5c9
# working apr-config installation has been specified.
Packit 90a5c9
#
Packit 90a5c9
Packit 90a5c9
should_exit=0
Packit 90a5c9
apr_config=         # path to apr-config (empty if using a source directory)
Packit 90a5c9
apr_found=0
Packit 90a5c9
apu_found=0
Packit 90a5c9
apr_major_version=2
Packit 90a5c9
Packit 90a5c9
for dir in $apr_src_dir
Packit 90a5c9
do
Packit 90a5c9
    if [ -f "${dir}/build/apr_common.m4" ]; then
Packit 90a5c9
        echo "found apr source: ${dir}"
Packit 90a5c9
        apr_src_dir=$dir
Packit 90a5c9
        apr_found=1
Packit 90a5c9
        break
Packit 90a5c9
    elif which "${dir}" >/dev/null 2>&1; then
Packit 90a5c9
        # We're using apr-config. Do a sanity check.
Packit 90a5c9
        apr_config=`which "${dir}"`
Packit 90a5c9
        echo "testing apr-config executable: ${apr_config}"
Packit 90a5c9
Packit 90a5c9
        version=`"${apr_config}" --version`
Packit 90a5c9
        version=`echo "${version}" | sed -n '/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/p'`
Packit 90a5c9
Packit 90a5c9
        if [ -z "${version}" ]; then
Packit 90a5c9
            echo "apr-config gave us an invalid --version"
Packit 90a5c9
            apr_config=
Packit 90a5c9
            continue
Packit 90a5c9
        fi
Packit 90a5c9
Packit 90a5c9
        echo "using apr-config version ${version}"
Packit 90a5c9
        apr_major_version=${version} # we'll make a real "major version" later
Packit 90a5c9
        apr_src_dir=`"${apr_config}" --installbuilddir`
Packit 90a5c9
        apr_found=1
Packit 90a5c9
        break
Packit 90a5c9
    fi
Packit 90a5c9
done
Packit 90a5c9
Packit 90a5c9
if [ $apr_found -lt 1 ]; then
Packit 90a5c9
    echo ""
Packit 90a5c9
    echo "You don't have a copy of the apr source in srclib/apr. "
Packit 90a5c9
    echo "Please get the source using the following instructions," 
Packit 90a5c9
    echo "or specify the location of the source with " 
Packit 90a5c9
    echo "--with-apr=[path to apr] :"
Packit 90a5c9
    echo ""
Packit 90a5c9
    echo "   svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr"
Packit 90a5c9
    echo ""
Packit 90a5c9
    should_exit=1
Packit 90a5c9
elif [ -n "${apr_config}" ]; then
Packit 90a5c9
    apr_major_version=`echo "${apr_major_version}" | sed 's/\..*//'`
Packit 90a5c9
else
Packit 90a5c9
    apr_major_version=`grep "#define APR_MAJOR_VERSION" \
Packit 90a5c9
                      $apr_src_dir/include/apr_version.h | sed 's/[^0-9]//g'`
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
# Find APR-util. Note: if we're using apr-config, we can completely skip this,
Packit 90a5c9
# even if APR is version 1. That's because we only end up caring about
Packit 90a5c9
# find_apu.m4, which is not actually installed in the standard APR-util
Packit 90a5c9
# distribution to begin with.
Packit 90a5c9
if [ -z "${apr_config}" -a $apr_major_version -lt 2 ] ; then
Packit 90a5c9
    if test -z "$apu_src_dir"; then
Packit 90a5c9
        apu_src_dir=`echo $apr_src_dir | sed -e 's#/apr#/apr-util#g;'`
Packit 90a5c9
        apu_src_dir="$apu_src_dir `echo $apr_src_dir | sed -e 's#/apr#/aprutil#;g'`"
Packit 90a5c9
        apu_src_dir="$apu_src_dir srclib/apr-util ../apr-util"
Packit 90a5c9
    fi
Packit 90a5c9
Packit 90a5c9
    for dir in $apu_src_dir
Packit 90a5c9
    do
Packit 90a5c9
        if [ -f "${dir}/Makefile.in" ]; then
Packit 90a5c9
            echo "found apr-util source: ${dir}"
Packit 90a5c9
            apu_src_dir=$dir
Packit 90a5c9
            apu_found=1
Packit 90a5c9
            break
Packit 90a5c9
        fi
Packit 90a5c9
    done
Packit 90a5c9
Packit 90a5c9
    if [ $apu_found -lt 1 ]; then
Packit 90a5c9
        echo ""
Packit 90a5c9
        echo "You don't have a copy of the apr-util source in srclib/apr-util. "
Packit 90a5c9
        echo "Please get one the source using the following instructions, "
Packit 90a5c9
        echo "or specify the location of the source with "
Packit 90a5c9
        echo "--with-apr-util=[path to apr-util]:"
Packit 90a5c9
        echo ""
Packit 90a5c9
        echo "   svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/1.5.x srclib/apr-util"
Packit 90a5c9
        echo ""
Packit 90a5c9
        should_exit=1
Packit 90a5c9
    fi
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
if [ $should_exit -gt 0 ]; then
Packit 90a5c9
    exit 1
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
# These are temporary until Roy finishes the other build changes
Packit 90a5c9
#
Packit 90a5c9
touch .deps
Packit 90a5c9
rm -f aclocal.m4
Packit 90a5c9
rm -f generated_lists
Packit 90a5c9
Packit 90a5c9
# Remove autoconf 2.5x cache directories
Packit 90a5c9
rm -rf autom4te*.cache
Packit 90a5c9
Packit 90a5c9
case "`uname`" in
Packit 90a5c9
*BSD/OS*)
Packit 90a5c9
    ./build/bsd_makefile;;
Packit 90a5c9
esac
Packit 90a5c9
#
Packit 90a5c9
# end temporary stuff
Packit 90a5c9
Packit 90a5c9
apr_configure="$apr_src_dir/configure"
Packit 90a5c9
if [ $apr_major_version -lt 2 ] ; then
Packit 90a5c9
    aprutil_configure="$apu_src_dir/configure"
Packit 90a5c9
fi
Packit 90a5c9
config_h_in="include/ap_config_auto.h.in"
Packit 90a5c9
Packit 90a5c9
cross_compile_warning="warning: AC_TRY_RUN called without default to allow cross compiling"
Packit 90a5c9
Packit 90a5c9
if [ "$apr_src_dir" = "srclib/apr" ]; then
Packit 90a5c9
    echo rebuilding $apr_configure
Packit 90a5c9
    (cd srclib/apr && ./buildconf) || {
Packit 90a5c9
        echo "./buildconf failed for apr"
Packit 90a5c9
        exit 1
Packit 90a5c9
    }
Packit 90a5c9
    rm -f srclib/apr/apr.spec
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
apr_src_dir=`cd $apr_src_dir && pwd` 
Packit 90a5c9
Packit 90a5c9
if [ $apr_major_version -lt 2 ] ; then
Packit 90a5c9
    if [ "$apu_src_dir" = "srclib/apr-util" ]; then
Packit 90a5c9
        echo rebuilding $aprutil_configure
Packit 90a5c9
        (cd srclib/apr-util && ./buildconf --with-apr=$apr_src_dir) || {
Packit 90a5c9
            echo "./buildconf failed for apr-util" 
Packit 90a5c9
            exit 1
Packit 90a5c9
        }
Packit 90a5c9
        rm -f srclib/apr-util/apr-util.spec
Packit 90a5c9
    fi
Packit 90a5c9
Packit 90a5c9
    apu_src_dir=`cd $apu_src_dir && pwd`
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
echo copying build files
Packit 90a5c9
if [ -n "${apr_config}" ]; then
Packit 90a5c9
    # If we're using apr-config, we switch things up a little bit:
Packit 90a5c9
    # - use automake's config.* scripts instead of APR's
Packit 90a5c9
    # - use the included PrintPath instead of copying from APR
Packit 90a5c9
    # - assume find_apu.m4 is also in APR's --installbuilddir
Packit 90a5c9
Packit 90a5c9
    # Figure out where to copy config.* from.
Packit 90a5c9
    automake=${AUTOMAKE:-automake}
Packit 90a5c9
    am_libdir=`"${automake}" --print-libdir`
Packit 90a5c9
    cp "${am_libdir}/config.guess" "${am_libdir}/config.sub" build
Packit 90a5c9
Packit 90a5c9
    # Remember that in this case, $apr_src_dir points to the build directory.
Packit 90a5c9
    cp "$apr_src_dir/apr_common.m4" "$apr_src_dir/find_apr.m4" build
Packit 90a5c9
    if [ $apr_major_version -lt 2 ] ; then
Packit 90a5c9
        cp "$apr_src_dir/find_apu.m4" build
Packit 90a5c9
    fi
Packit 90a5c9
else
Packit 90a5c9
    cp $apr_src_dir/build/config.guess $apr_src_dir/build/config.sub \
Packit 90a5c9
       $apr_src_dir/build/PrintPath $apr_src_dir/build/apr_common.m4 \
Packit 90a5c9
       $apr_src_dir/build/find_apr.m4 build
Packit 90a5c9
    if [ $apr_major_version -lt 2 ] ; then
Packit 90a5c9
        cp $apu_src_dir/build/find_apu.m4 build
Packit 90a5c9
    fi
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
# Remove any libtool files so one can switch between libtool 1.3
Packit 90a5c9
# and libtool 1.4 by simply rerunning the buildconf script.
Packit 90a5c9
(cd build ; rm -f ltconfig ltmain.sh)
Packit 90a5c9
Packit 90a5c9
if [ -z "${apr_config}" ]; then
Packit 90a5c9
    # Optionally copy libtool-1.3.x files
Packit 90a5c9
    if [ -f $apr_src_dir/build/ltconfig ]; then
Packit 90a5c9
        cp $apr_src_dir/build/ltconfig build
Packit 90a5c9
    fi
Packit 90a5c9
    if [ -f $apr_src_dir/build/ltmain.sh ]; then
Packit 90a5c9
        cp $apr_src_dir/build/ltmain.sh build
Packit 90a5c9
    fi
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
echo rebuilding $config_h_in
Packit 90a5c9
rm -f $config_h_in
Packit 90a5c9
${AUTOHEADER:-autoheader} 2>&1 | grep -v "$cross_compile_warning"
Packit 90a5c9
Packit 90a5c9
echo rebuilding configure
Packit 90a5c9
rm -f config.cache
Packit 90a5c9
${AUTOCONF:-autoconf} 2>&1 | grep -v "$cross_compile_warning"
Packit 90a5c9
Packit 90a5c9
# Remove autoconf 2.5x cache directories
Packit 90a5c9
rm -rf autom4te*.cache
Packit 90a5c9
Packit 90a5c9
if [ -f `which cut` ]; then
Packit 90a5c9
  echo rebuilding rpm spec file
Packit 90a5c9
  ( VMMN=`build/get-version.sh mmn include/ap_mmn.h MODULE_MAGIC_NUMBER`
Packit 90a5c9
    EPOCH=`build/get-version.sh epoch include/ap_release.h AP_SERVER`
Packit 90a5c9
    REVISION=`build/get-version.sh all include/ap_release.h AP_SERVER`
Packit 90a5c9
    VERSION=`echo $REVISION | cut -d- -s -f1`
Packit 90a5c9
    RELEASE=`echo $REVISION | cut -d- -s -f2`
Packit 90a5c9
    if [ "x$VERSION" = "x" ]; then
Packit 90a5c9
      VERSION=$REVISION
Packit 90a5c9
      RELEASE=1
Packit 90a5c9
    fi
Packit 90a5c9
    cat ./build/rpm/httpd.spec.in | \
Packit 90a5c9
    sed -e "s/APACHE_VERSION/$VERSION/" \
Packit 90a5c9
        -e "s/APACHE_RELEASE/$RELEASE/" \
Packit 90a5c9
        -e "s/APACHE_MMN/$VMMN/" \
Packit 90a5c9
        -e "s/APACHE_EPOCH/$EPOCH/" \
Packit 90a5c9
    > httpd.spec )
Packit 90a5c9
fi
Packit 90a5c9
Packit 90a5c9
# ensure that the ap_expr expression parser sources are never regenerated
Packit 90a5c9
# when running make
Packit 90a5c9
echo fixing timestamps for ap_expr sources
Packit 90a5c9
cd server
Packit 90a5c9
touch util_expr_parse.y util_expr_scan.l
Packit 90a5c9
sleep 1
Packit 90a5c9
touch util_expr_parse.c util_expr_parse.h util_expr_scan.c
Packit 90a5c9
cd ..
Packit 90a5c9
Packit 90a5c9
exit 0