]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/subversion/autogen.sh
MFC r368207,368607:
[FreeBSD/stable/10.git] / contrib / subversion / autogen.sh
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
31 RELEASE_MODE=""
32 RELEASE_ARGS=""
33 SKIP_DEPS=""
34 while 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
53 done
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
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`
69
70 if [ "x$libtoolize" = "x" ]; then
71     echo "libtoolize not found in path"
72     exit 1
73 fi
74
75 rm -f build/config.guess build/config.sub
76 $libtoolize --copy --automake --force
77
78 ltpath="`dirname $libtoolize`"
79
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`
84     else
85         echo "Libtool helper path not found $ltm4_error"
86         echo "  expected at: '$ltpath/../share/aclocal'"
87         exit 1
88     fi
89 else
90     ltm4_error="(the LIBTOOL_M4 environment variable is: $LIBTOOL_M4)"
91     ltm4="$LIBTOOL_M4"
92 fi
93
94 ltfile="$ltm4/libtool.m4"
95 if [ ! -f "$ltfile" ]; then
96     echo "$ltfile not found $ltm4_error"
97     exit 1
98 fi
99
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
105 # copying:
106 rm -f build/libtool.m4
107 cp "$ltfile" build/libtool.m4
108
109 for file in ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4; do
110     rm -f build/$file
111
112     if [ $lt_major_version -ge 2 ]; then
113         ltfile="$ltm4/$file"
114
115         if [ ! -f "$ltfile" ]; then
116             echo "$ltfile not found $ltm4_error"
117             exit 1
118         fi
119
120         echo "Copying libtool helper:  $ltfile"
121         cp "$ltfile" "build/$file"
122     fi
123 done
124
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`
132         else
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'"
136             exit 1
137         fi
138     else
139         ltconfig_error="(the LIBTOOL_CONFIG environment variable is: $LIBTOOL_CONFIG)"
140         ltconfig="$LIBTOOL_CONFIG"
141     fi
142
143     for file in config.guess config.sub; do
144         configfile="$ltconfig/$file"
145
146         if [ ! -f "$configfile" ]; then
147             echo "$configfile not found $ltconfig_error"
148             exit 1
149         fi
150
151         echo "Copying autoconf helper: $configfile"
152         cp "$configfile" build/$file
153     done
154 fi
155
156 # Create the file detailing all of the build outputs for SVN.
157 #
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.
161
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"
168   exit 1
169 fi
170
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
177
178   # Build the SWIG-related files
179   make -f autogen-standalone.mk autogen-swig
180
181   # Remove the .swig_checked file
182   rm -f .swig_checked
183 fi
184
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
188 else
189   echo "Creating build-outputs.mk..."
190   "$PYTHON" ./gen-make.py $RELEASE_ARGS build.conf || gen_failed=1
191 fi
192
193 if test -n "$RELEASE_MODE"; then
194   find build/ -name '*.pyc' -exec rm {} \;
195 fi
196
197 rm autogen-standalone.mk
198
199 if test -n "$gen_failed"; then
200   echo "ERROR: gen-make.py failed"
201   exit 1
202 fi
203
204 # Produce config.h.in
205 echo "Creating svn_private_config.h.in..."
206 ${AUTOHEADER:-autoheader}
207
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
212 fi
213
214 # Produce ./configure
215 echo "Creating configure..."
216 ${AUTOCONF:-autoconf}
217
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
221   (
222     [ -f configure.$$.tmp ] && cmp configure configure.$$.tmp > /dev/null 2>&1
223   ) || (
224     echo "Tossing config.cache, since configure has changed."
225     rm config.cache
226   )
227   rm -f configure.$$.tmp
228 fi
229
230 # Remove autoconf 2.5x's cache directory
231 rm -rf autom4te*.cache
232
233 echo ""
234 echo "You can run ./configure now."
235 echo ""
236 echo "Running autogen.sh implies you are a maintainer.  You may prefer"
237 echo "to run configure in one of the following ways:"
238 echo ""
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++'"
244 echo ""
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."
247 echo ""