]> granicus.if.org Git - apache/blob - buildconf
Vote, promote.
[apache] / buildconf
1 #!/bin/sh
2 #
3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements.  See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License.  You may obtain a copy of the License at
9 #
10 #     http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #
18 #
19 # buildconf: Build the support scripts needed to compile from a
20 #            checked-out version of the source code.
21
22 # version check for AC_PROG_CC_C99
23 ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//;s/[a-z]* *$//;q'`
24 case "$ac_version" in
25 # versions older than 2.50 are denied by AC_PREREQ
26 2.5*)
27     echo WARNING: You are using an outdated version of autoconf.
28     echo WARNING: This may lead to less than optimal performance of httpd.
29     echo WARNING: You should use autoconf 2.60 or newer.
30     sleep 1
31     ;;
32 esac
33
34 # set a couple of defaults for where we should be looking for our support libs.
35 # can be overridden with --with-apr=[dir] and --with-apr-util=[dir]
36
37 apr_src_dir="srclib/apr ../apr"
38 apu_src_dir=""
39
40 while test $# -gt 0 
41 do
42     # Normalize
43     case "$1" in
44     -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
45     *) optarg= ;;
46     esac
47
48     case "$1" in
49     --with-apr=*)
50         apr_src_dir=$optarg
51         ;;
52
53     --with-apr-util=*)
54         apu_src_dir=$optarg
55         ;;
56
57     -h|--help)
58         cat <<EOF
59 buildconf: generates the files needed to configure httpd.
60
61 Usage: $0 [OPTION]...
62
63 Configuration:
64   -h, --help               display this help and exit
65
66   --with-apr=SRCDIR        define a space-separated list of directories to
67                            search for the APR source code. If, instead of a
68                            directory, an apr-config executable name is passed,
69                            APR-Config Mode is enabled (see below). Defaults to
70                            "srclib/apr ../apr"
71   --with-apr-util=SRCDIR   define a space-separated list of directories to
72                            search for the APR-util source code. Defaults to the
73                            same location as the --with-apr SRCDIR, but with
74                            "apr" replaced with "apr-util" or "aprutil". Ignored
75                            in APR-Config Mode.
76
77 APR-Config Mode:
78
79   When passing an apr-config executable to --with-apr, buildconf will attempt to
80   copy build scripts from various installed locations on your system instead of
81   an APR source tree. This allows you to configure httpd from source without
82   also requiring you to download the APR and/or APR-util sources.
83
84   For example:
85
86       ./buildconf --with-apr=apr-1-config
87
88   For this functionality to work reliably, you must have automake >= 1.12 and be
89   using a distribution that includes both find_apr.m4 and find_apu.m4 in the
90   --installbuilddir pointed to by apr-config.
91
92 Environment variables used by buildconf:
93   AUTOCONF           autoconf executable name [autoconf]
94   AUTOMAKE           automake executable name [automake]
95   AUTOHEADER         autoheader executable name [autoheader]
96 EOF
97         exit
98         ;;
99
100     *)
101         echo "unknown option $1 (try --help for usage)"
102         exit 1
103         ;;
104     esac
105
106     shift
107 done
108
109 #
110 # Check to be sure that we have the srclib dependencies checked-out, or that a
111 # working apr-config installation has been specified.
112 #
113
114 should_exit=0
115 apr_config=         # path to apr-config (empty if using a source directory)
116 apr_found=0
117 apu_found=0
118 apr_major_version=2
119
120 for dir in $apr_src_dir
121 do
122     if [ -f "${dir}/build/apr_common.m4" ]; then
123         echo "found apr source: ${dir}"
124         apr_src_dir=$dir
125         apr_found=1
126         break
127     elif which "${dir}" >/dev/null 2>&1; then
128         # We're using apr-config. Do a sanity check.
129         apr_config=`which "${dir}"`
130         echo "testing apr-config executable: ${apr_config}"
131
132         version=`"${apr_config}" --version`
133         version=`echo "${version}" | sed -n '/^[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$/p'`
134
135         if [ -z "${version}" ]; then
136             echo "apr-config gave us an invalid --version"
137             apr_config=
138             continue
139         fi
140
141         echo "using apr-config version ${version}"
142         apr_major_version=${version} # we'll make a real "major version" later
143         apr_src_dir=`"${apr_config}" --installbuilddir`
144         apr_found=1
145         break
146     fi
147 done
148
149 if [ $apr_found -lt 1 ]; then
150     echo ""
151     echo "You don't have a copy of the apr source in srclib/apr. "
152     echo "Please get the source using the following instructions," 
153     echo "or specify the location of the source with " 
154     echo "--with-apr=[path to apr] :"
155     echo ""
156     echo "   svn co http://svn.apache.org/repos/asf/apr/apr/trunk srclib/apr"
157     echo ""
158     should_exit=1
159 elif [ -n "${apr_config}" ]; then
160     apr_major_version=`echo "${apr_major_version}" | sed 's/\..*//'`
161 else
162     apr_major_version=`grep "#define APR_MAJOR_VERSION" \
163                       $apr_src_dir/include/apr_version.h | sed 's/[^0-9]//g'`
164 fi
165
166 # Find APR-util. Note: if we're using apr-config, we can completely skip this,
167 # even if APR is version 1. That's because we only end up caring about
168 # find_apu.m4, which is not actually installed in the standard APR-util
169 # distribution to begin with.
170 if [ -z "${apr_config}" -a $apr_major_version -lt 2 ] ; then
171     if test -z "$apu_src_dir"; then
172         apu_src_dir=`echo $apr_src_dir | sed -e 's#/apr#/apr-util#g;'`
173         apu_src_dir="$apu_src_dir `echo $apr_src_dir | sed -e 's#/apr#/aprutil#;g'`"
174         apu_src_dir="$apu_src_dir srclib/apr-util ../apr-util"
175     fi
176
177     for dir in $apu_src_dir
178     do
179         if [ -f "${dir}/Makefile.in" ]; then
180             echo "found apr-util source: ${dir}"
181             apu_src_dir=$dir
182             apu_found=1
183             break
184         fi
185     done
186
187     if [ $apu_found -lt 1 ]; then
188         echo ""
189         echo "You don't have a copy of the apr-util source in srclib/apr-util. "
190         echo "Please get one the source using the following instructions, "
191         echo "or specify the location of the source with "
192         echo "--with-apr-util=[path to apr-util]:"
193         echo ""
194         echo "   svn co http://svn.apache.org/repos/asf/apr/apr-util/branches/1.5.x srclib/apr-util"
195         echo ""
196         should_exit=1
197     fi
198 fi
199
200 if [ $should_exit -gt 0 ]; then
201     exit 1
202 fi
203
204 # These are temporary until Roy finishes the other build changes
205 #
206 touch .deps
207 rm -f aclocal.m4
208 rm -f generated_lists
209
210 # Remove autoconf 2.5x cache directories
211 rm -rf autom4te*.cache
212
213 case "`uname`" in
214 *BSD/OS*)
215     ./build/bsd_makefile;;
216 esac
217 #
218 # end temporary stuff
219
220 apr_configure="$apr_src_dir/configure"
221 if [ $apr_major_version -lt 2 ] ; then
222     aprutil_configure="$apu_src_dir/configure"
223 fi
224 config_h_in="include/ap_config_auto.h.in"
225
226 cross_compile_warning="warning: AC_TRY_RUN called without default to allow cross compiling"
227
228 if [ "$apr_src_dir" = "srclib/apr" ]; then
229     echo rebuilding $apr_configure
230     (cd srclib/apr && ./buildconf) || {
231         echo "./buildconf failed for apr"
232         exit 1
233     }
234     rm -f srclib/apr/apr.spec
235 fi
236
237 apr_src_dir=`cd $apr_src_dir && pwd` 
238
239 if [ $apr_major_version -lt 2 ] ; then
240     if [ "$apu_src_dir" = "srclib/apr-util" ]; then
241         echo rebuilding $aprutil_configure
242         (cd srclib/apr-util && ./buildconf --with-apr=$apr_src_dir) || {
243             echo "./buildconf failed for apr-util" 
244             exit 1
245         }
246         rm -f srclib/apr-util/apr-util.spec
247     fi
248
249     apu_src_dir=`cd $apu_src_dir && pwd`
250 fi
251
252 echo copying build files
253 if [ -n "${apr_config}" ]; then
254     # If we're using apr-config, we switch things up a little bit:
255     # - use automake's config.* scripts instead of APR's
256     # - use the included PrintPath instead of copying from APR
257     # - assume find_apu.m4 is also in APR's --installbuilddir
258
259     # Figure out where to copy config.* from.
260     automake=${AUTOMAKE:-automake}
261     am_libdir=`"${automake}" --print-libdir`
262     cp "${am_libdir}/config.guess" "${am_libdir}/config.sub" build
263
264     # Remember that in this case, $apr_src_dir points to the build directory.
265     cp "$apr_src_dir/apr_common.m4" "$apr_src_dir/find_apr.m4" build
266     if [ $apr_major_version -lt 2 ] ; then
267         cp "$apr_src_dir/find_apu.m4" build
268     fi
269 else
270     cp $apr_src_dir/build/config.guess $apr_src_dir/build/config.sub \
271        $apr_src_dir/build/PrintPath $apr_src_dir/build/apr_common.m4 \
272        $apr_src_dir/build/find_apr.m4 build
273     if [ $apr_major_version -lt 2 ] ; then
274         cp $apu_src_dir/build/find_apu.m4 build
275     fi
276 fi
277
278 # Remove any libtool files so one can switch between libtool 1.3
279 # and libtool 1.4 by simply rerunning the buildconf script.
280 (cd build ; rm -f ltconfig ltmain.sh)
281
282 if [ -z "${apr_config}" ]; then
283     # Optionally copy libtool-1.3.x files
284     if [ -f $apr_src_dir/build/ltconfig ]; then
285         cp $apr_src_dir/build/ltconfig build
286     fi
287     if [ -f $apr_src_dir/build/ltmain.sh ]; then
288         cp $apr_src_dir/build/ltmain.sh build
289     fi
290 fi
291
292 echo rebuilding $config_h_in
293 rm -f $config_h_in
294 ${AUTOHEADER:-autoheader} 2>&1 | grep -v "$cross_compile_warning"
295
296 echo rebuilding configure
297 rm -f config.cache
298 ${AUTOCONF:-autoconf} 2>&1 | grep -v "$cross_compile_warning"
299
300 # Remove autoconf 2.5x cache directories
301 rm -rf autom4te*.cache
302
303 if [ -f `which cut` ]; then
304   echo rebuilding rpm spec file
305   ( VMMN=`build/get-version.sh mmn include/ap_mmn.h MODULE_MAGIC_NUMBER`
306     EPOCH=`build/get-version.sh epoch include/ap_release.h AP_SERVER`
307     REVISION=`build/get-version.sh all include/ap_release.h AP_SERVER`
308     VERSION=`echo $REVISION | cut -d- -s -f1`
309     RELEASE=`echo $REVISION | cut -d- -s -f2`
310     if [ "x$VERSION" = "x" ]; then
311       VERSION=$REVISION
312       RELEASE=1
313     fi
314     cat ./build/rpm/httpd.spec.in | \
315     sed -e "s/APACHE_VERSION/$VERSION/" \
316         -e "s/APACHE_RELEASE/$RELEASE/" \
317         -e "s/APACHE_MMN/$VMMN/" \
318         -e "s/APACHE_EPOCH/$EPOCH/" \
319     > httpd.spec )
320 fi
321
322 # ensure that the ap_expr expression parser sources are never regenerated
323 # when running make
324 echo fixing timestamps for ap_expr sources
325 cd server
326 touch util_expr_parse.y util_expr_scan.l
327 sleep 1
328 touch util_expr_parse.c util_expr_parse.h util_expr_scan.c
329 cd ..
330
331 exit 0