autogen.sh revision 289166
1#!/bin/sh
2#
3#
4# Licensed to the Apache Software Foundation (ASF) under one
5# or more contributor license agreements.  See the NOTICE file
6# distributed with this work for additional information
7# regarding copyright ownership.  The ASF licenses this file
8# to you under the Apache License, Version 2.0 (the
9# "License"); you may not use this file except in compliance
10# with the License.  You may obtain a copy of the License at
11#
12#   http://www.apache.org/licenses/LICENSE-2.0
13#
14# Unless required by applicable law or agreed to in writing,
15# software distributed under the License is distributed on an
16# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17# KIND, either express or implied.  See the License for the
18# specific language governing permissions and limitations
19# under the License.
20#
21#
22
23### Run this to produce everything needed for configuration. ###
24
25
26# Some shells can produce output when running 'cd' which interferes
27# with the construct 'abs=`cd dir && pwd`'.
28(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
29
30# Run tests to ensure that our build requirements are met
31RELEASE_MODE=""
32RELEASE_ARGS=""
33SKIP_DEPS=""
34while test $# != 0; do
35  case "$1" in
36    --release)
37      RELEASE_MODE="$1"
38      RELEASE_ARGS="--release"
39      shift
40      ;;
41    -s)
42      SKIP_DEPS="yes"
43      shift
44      ;;
45    --)         # end of option parsing
46      break
47      ;;
48    *)
49      echo "invalid parameter: '$1'"
50      exit 1
51      ;;
52  esac
53done
54# ### The order of parameters is important; buildcheck.sh depends on it and
55# ### we don't want to copy the fancy option parsing loop there. For the
56# ### same reason, all parameters should be quoted, so that buildcheck.sh
57# ### sees an empty arg rather than missing one.
58./build/buildcheck.sh "$RELEASE_MODE" || exit 1
59
60# Handle some libtool helper files
61#
62# ### eventually, we can/should toss this in favor of simply using
63# ### APR's libtool. deferring to a second round of change...
64#
65
66libtoolize="`./build/PrintPath glibtoolize libtoolize libtoolize15`"
67lt_major_version=`$libtoolize --version 2>/dev/null | sed -e 's/^[^0-9]*//' -e 's/\..*//' -e '/^$/d' -e 1q`
68
69if [ "x$libtoolize" = "x" ]; then
70    echo "libtoolize not found in path"
71    exit 1
72fi
73
74rm -f build/config.guess build/config.sub
75$libtoolize --copy --automake --force
76
77ltpath="`dirname $libtoolize`"
78
79if [ "x$LIBTOOL_M4" = "x" ]; then
80    ltm4_error='(try setting the LIBTOOL_M4 environment variable)'
81    if [ -d "$ltpath/../share/aclocal/." ]; then
82        ltm4=`cd "$ltpath/../share/aclocal" && pwd`
83    else
84        echo "Libtool helper path not found $ltm4_error"
85        echo "  expected at: '$ltpath/../share/aclocal'"
86        exit 1
87    fi
88else
89    ltm4_error="(the LIBTOOL_M4 environment variable is: $LIBTOOL_M4)"
90    ltm4="$LIBTOOL_M4"
91fi
92
93ltfile="$ltm4/libtool.m4"
94if [ ! -f "$ltfile" ]; then
95    echo "$ltfile not found $ltm4_error"
96    exit 1
97fi
98
99echo "Copying libtool helper:  $ltfile"
100# An ancient helper might already be present from previous builds,
101# and it might be write-protected (e.g. mode 444, seen on FreeBSD).
102# This would cause cp to fail and print an error message, but leave
103# behind a potentially outdated libtool helper.  So, remove before
104# copying:
105rm -f build/libtool.m4
106cp "$ltfile" build/libtool.m4
107
108for file in ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4; do
109    rm -f build/$file
110
111    if [ $lt_major_version -ge 2 ]; then
112        ltfile="$ltm4/$file"
113
114        if [ ! -f "$ltfile" ]; then
115            echo "$ltfile not found $ltm4_error"
116            exit 1
117        fi
118
119        echo "Copying libtool helper:  $ltfile"
120        cp "$ltfile" "build/$file"
121    fi
122done
123
124if [ $lt_major_version -ge 2 ]; then
125    if [ "x$LIBTOOL_CONFIG" = "x" ]; then
126        ltconfig_error='(try setting the LIBTOOL_CONFIG environment variable)'
127        if [ -d "$ltpath/../share/libtool/config/." ]; then
128            ltconfig=`cd "$ltpath/../share/libtool/config" && pwd`
129        elif [ -d "$ltpath/../share/libtool/build-aux/." ]; then
130            ltconfig=`cd "$ltpath/../share/libtool/build-aux" && pwd`
131        else
132            echo "Autoconf helper path not found $ltconfig_error"
133            echo "  expected at: '$ltpath/../share/libtool/config'"
134            echo "           or: '$ltpath/../share/libtool/build-aux'"
135            exit 1
136        fi
137    else
138        ltconfig_error="(the LIBTOOL_CONFIG environment variable is: $LIBTOOL_CONFIG)"
139        ltconfig="$LIBTOOL_CONFIG"
140    fi
141
142    for file in config.guess config.sub; do
143        configfile="$ltconfig/$file"
144
145        if [ ! -f "$configfile" ]; then
146            echo "$configfile not found $ltconfig_error"
147            exit 1
148        fi
149
150        echo "Copying autoconf helper: $configfile"
151	cp "$configfile" build/$file
152    done
153fi
154
155# Create the file detailing all of the build outputs for SVN.
156#
157# Note: this dependency on Python is fine: only SVN developers use autogen.sh
158#       and we can state that dev people need Python on their machine. Note
159#       that running gen-make.py requires Python 2.5 or newer.
160
161PYTHON="`./build/find_python.sh`"
162if test -z "$PYTHON"; then
163  echo "Python 2.5 or later is required to run autogen.sh"
164  echo "If you have a suitable Python installed, but not on the"
165  echo "PATH, set the environment variable PYTHON to the full path"
166  echo "to the Python executable, and re-run autogen.sh"
167  exit 1
168fi
169
170# Compile SWIG headers into standalone C files if we are in release mode
171if test -n "$RELEASE_MODE"; then
172  echo "Generating SWIG code..."
173  # Generate build-outputs.mk in non-release-mode, so that we can
174  # build the SWIG-related files
175  "$PYTHON" ./gen-make.py build.conf || gen_failed=1
176
177  # Build the SWIG-related files
178  make -f autogen-standalone.mk autogen-swig
179
180  # Remove the .swig_checked file
181  rm -f .swig_checked
182fi
183
184if test -n "$SKIP_DEPS"; then
185  echo "Creating build-outputs.mk (no dependencies)..."
186  "$PYTHON" ./gen-make.py $RELEASE_ARGS -s build.conf || gen_failed=1
187else
188  echo "Creating build-outputs.mk..."
189  "$PYTHON" ./gen-make.py $RELEASE_ARGS build.conf || gen_failed=1
190fi
191
192if test -n "$RELEASE_MODE"; then
193  find build/ -name '*.pyc' -exec rm {} \;
194fi
195
196rm autogen-standalone.mk
197
198if test -n "$gen_failed"; then
199  echo "ERROR: gen-make.py failed"
200  exit 1
201fi
202
203# Produce config.h.in
204echo "Creating svn_private_config.h.in..."
205${AUTOHEADER:-autoheader}
206
207# If there's a config.cache file, we may need to delete it.  
208# If we have an existing configure script, save a copy for comparison.
209if [ -f config.cache ] && [ -f configure ]; then
210  cp configure configure.$$.tmp
211fi
212
213# Produce ./configure
214echo "Creating configure..."
215${AUTOCONF:-autoconf}
216
217# If we have a config.cache file, toss it if the configure script has
218# changed, or if we just built it for the first time.
219if [ -f config.cache ]; then
220  (
221    [ -f configure.$$.tmp ] && cmp configure configure.$$.tmp > /dev/null 2>&1
222  ) || (
223    echo "Tossing config.cache, since configure has changed."
224    rm config.cache
225  )
226  rm -f configure.$$.tmp
227fi
228
229# Remove autoconf 2.5x's cache directory
230rm -rf autom4te*.cache
231
232echo ""
233echo "You can run ./configure now."
234echo ""
235echo "Running autogen.sh implies you are a maintainer.  You may prefer"
236echo "to run configure in one of the following ways:"
237echo ""
238echo "./configure --enable-maintainer-mode"
239echo "./configure --disable-shared"
240echo "./configure --enable-maintainer-mode --disable-shared"
241echo "./configure --disable-optimize --enable-debug"
242echo "./configure CUSERFLAGS='--flags-for-C' CXXUSERFLAGS='--flags-for-C++'"
243echo ""
244echo "Note:  If you wish to run a Subversion HTTP server, you will need"
245echo "Apache 2.x.  See the INSTALL file for details."
246echo ""
247