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
12 # http://www.apache.org/licenses/LICENSE-2.0
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
23 ### Run this to produce everything needed for configuration. ###
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
30 # Run tests to ensure that our build requirements are met
34 while test $# != 0; do
38 RELEASE_ARGS="--release"
45 --) # end of option parsing
49 echo "invalid parameter: '$1'"
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
60 # Handle some libtool helper files
62 # ### eventually, we can/should toss this in favor of simply using
63 # ### APR's libtool. deferring to a second round of change...
66 # Much like APR except we do not prefer libtool 1 over libtool 2.
67 libtoolize="`./build/PrintPath glibtoolize libtoolize glibtoolize1 libtoolize15 libtoolize14`"
68 lt_major_version=`$libtoolize --version 2>/dev/null | sed -e 's/^[^0-9]*//' -e 's/\..*//' -e '/^$/d' -e 1q`
70 if [ "x$libtoolize" = "x" ]; then
71 echo "libtoolize not found in path"
75 rm -f build/config.guess build/config.sub
76 $libtoolize --copy --automake --force
78 ltpath="`dirname $libtoolize`"
80 if [ "x$LIBTOOL_M4" = "x" ]; then
81 ltm4_error='(try setting the LIBTOOL_M4 environment variable)'
82 if [ -d "$ltpath/../share/aclocal/." ]; then
83 ltm4=`cd "$ltpath/../share/aclocal" && pwd`
85 echo "Libtool helper path not found $ltm4_error"
86 echo " expected at: '$ltpath/../share/aclocal'"
90 ltm4_error="(the LIBTOOL_M4 environment variable is: $LIBTOOL_M4)"
94 ltfile="$ltm4/libtool.m4"
95 if [ ! -f "$ltfile" ]; then
96 echo "$ltfile not found $ltm4_error"
100 echo "Copying libtool helper: $ltfile"
101 # An ancient helper might already be present from previous builds,
102 # and it might be write-protected (e.g. mode 444, seen on FreeBSD).
103 # This would cause cp to fail and print an error message, but leave
104 # behind a potentially outdated libtool helper. So, remove before
106 rm -f build/libtool.m4
107 cp "$ltfile" build/libtool.m4
109 for file in ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4; do
112 if [ $lt_major_version -ge 2 ]; then
115 if [ ! -f "$ltfile" ]; then
116 echo "$ltfile not found $ltm4_error"
120 echo "Copying libtool helper: $ltfile"
121 cp "$ltfile" "build/$file"
125 if [ $lt_major_version -ge 2 ]; then
126 if [ "x$LIBTOOL_CONFIG" = "x" ]; then
127 ltconfig_error='(try setting the LIBTOOL_CONFIG environment variable)'
128 if [ -d "$ltpath/../share/libtool/config/." ]; then
129 ltconfig=`cd "$ltpath/../share/libtool/config" && pwd`
130 elif [ -d "$ltpath/../share/libtool/build-aux/." ]; then
131 ltconfig=`cd "$ltpath/../share/libtool/build-aux" && pwd`
133 echo "Autoconf helper path not found $ltconfig_error"
134 echo " expected at: '$ltpath/../share/libtool/config'"
135 echo " or: '$ltpath/../share/libtool/build-aux'"
139 ltconfig_error="(the LIBTOOL_CONFIG environment variable is: $LIBTOOL_CONFIG)"
140 ltconfig="$LIBTOOL_CONFIG"
143 for file in config.guess config.sub; do
144 configfile="$ltconfig/$file"
146 if [ ! -f "$configfile" ]; then
147 echo "$configfile not found $ltconfig_error"
151 echo "Copying autoconf helper: $configfile"
152 cp "$configfile" build/$file
156 # Create the file detailing all of the build outputs for SVN.
158 # Note: this dependency on Python is fine: only SVN developers use autogen.sh
159 # and we can state that dev people need Python on their machine. Note
160 # that running gen-make.py requires Python 2.7 or newer.
162 PYTHON="`./build/find_python.sh`"
163 if test -z "$PYTHON"; then
164 echo "Python 2.7 or later is required to run autogen.sh"
165 echo "If you have a suitable Python installed, but not on the"
166 echo "PATH, set the environment variable PYTHON to the full path"
167 echo "to the Python executable, and re-run autogen.sh"
171 # Compile SWIG headers into standalone C files if we are in release mode
172 if test -n "$RELEASE_MODE"; then
173 echo "Generating SWIG code..."
174 # Generate build-outputs.mk in non-release-mode, so that we can
175 # build the SWIG-related files
176 "$PYTHON" ./gen-make.py build.conf || gen_failed=1
178 # Build the SWIG-related files
179 make -f autogen-standalone.mk autogen-swig
181 # Remove the .swig_checked file
185 if test -n "$SKIP_DEPS"; then
186 echo "Creating build-outputs.mk (no dependencies)..."
187 "$PYTHON" ./gen-make.py $RELEASE_ARGS -s build.conf || gen_failed=1
189 echo "Creating build-outputs.mk..."
190 "$PYTHON" ./gen-make.py $RELEASE_ARGS build.conf || gen_failed=1
193 if test -n "$RELEASE_MODE"; then
194 find build/ -name '*.pyc' -exec rm {} \;
197 rm autogen-standalone.mk
199 if test -n "$gen_failed"; then
200 echo "ERROR: gen-make.py failed"
204 # Produce config.h.in
205 echo "Creating svn_private_config.h.in..."
206 ${AUTOHEADER:-autoheader}
208 # If there's a config.cache file, we may need to delete it.
209 # If we have an existing configure script, save a copy for comparison.
210 if [ -f config.cache ] && [ -f configure ]; then
211 cp configure configure.$$.tmp
214 # Produce ./configure
215 echo "Creating configure..."
216 ${AUTOCONF:-autoconf}
218 # If we have a config.cache file, toss it if the configure script has
219 # changed, or if we just built it for the first time.
220 if [ -f config.cache ]; then
222 [ -f configure.$$.tmp ] && cmp configure configure.$$.tmp > /dev/null 2>&1
224 echo "Tossing config.cache, since configure has changed."
227 rm -f configure.$$.tmp
230 # Remove autoconf 2.5x's cache directory
231 rm -rf autom4te*.cache
234 echo "You can run ./configure now."
236 echo "Running autogen.sh implies you are a maintainer. You may prefer"
237 echo "to run configure in one of the following ways:"
239 echo "./configure --enable-maintainer-mode"
240 echo "./configure --disable-shared"
241 echo "./configure --enable-maintainer-mode --disable-shared"
242 echo "./configure --disable-optimize --enable-debug"
243 echo "./configure CFLAGS='--flags-for-C' CXXFLAGS='--flags-for-C++'"
245 echo "Note: If you wish to run a Subversion HTTP server, you will need"
246 echo "Apache 2.x. See the INSTALL file for details."