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# buildcheck.sh: Inspects the build setup to make detection and
23# correction of problems an easier process.
24
25# Initialize parameters
26VERSION_CHECK="$1"
27
28if test "$VERSION_CHECK" != "--release"; then
29  echo "buildcheck: checking installation..."
30else
31  echo "buildcheck: checking installation for a source release..."
32fi
33
34#--------------------------------------------------------------------------
35# autoconf 2.59 or newer
36#
37ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//' -e 1q`
38if test -z "$ac_version"; then
39  echo "buildcheck: autoconf not found."
40  echo "            You need autoconf version 2.59 or newer installed."
41  exit 1
42fi
43IFS=.; set $ac_version; IFS=' '
44if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then
45  echo "buildcheck: autoconf version $ac_version found."
46  echo "            You need autoconf version 2.59 or newer installed."
47  echo "            If you have a sufficient autoconf installed, but it"
48  echo "            is not named 'autoconf', then try setting the"
49  echo "            AUTOCONF environment variable.  (See the INSTALL file"
50  echo "            for details.)"
51  exit 1
52fi
53
54echo "buildcheck: autoconf version $ac_version (ok)"
55
56#--------------------------------------------------------------------------
57# autoheader 2.59 or newer
58#
59ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//' -e 1q`
60if test -z "$ah_version"; then
61  echo "buildcheck: autoheader not found."
62  echo "            You need autoheader version 2.59 or newer installed."
63  exit 1
64fi
65IFS=.; set $ah_version; IFS=' '
66if test "$1" = "2" -a "$2" -lt "59" || test "$1" -lt "2"; then
67  echo "buildcheck: autoheader version $ah_version found."
68  echo "            You need autoheader version 2.59 or newer installed."
69  echo "            If you have a sufficient autoheader installed, but it"
70  echo "            is not named 'autoheader', then try setting the"
71  echo "            AUTOHEADER environment variable.  (See the INSTALL file"
72  echo "            for details.)"
73  exit 1
74fi
75
76echo "buildcheck: autoheader version $ah_version (ok)"
77
78#--------------------------------------------------------------------------
79# libtool 2.0 or newer
80#
81LIBTOOL_WANTED_MAJOR=2
82LIBTOOL_WANTED_MINOR=0
83LIBTOOL_WANTED_PATCH=
84LIBTOOL_WANTED_VERSION=2.0
85
86# Much like APR except we do not prefer libtool 1 over libtool 2.
87libtoolize=${LIBTOOLIZE:-`./build/PrintPath glibtoolize libtoolize glibtoolize1 libtoolize15 libtoolize14`}
88# Extract the libtool version number: everything from the first number in
89# the version text until a hyphen or space.
90lt_pversion=`$libtoolize --version 2>/dev/null |
91  sed -e 's/^[^0-9]*//' -e 's/[- ].*//' -e '/^$/d' |
92  sed -e 1q`
93if test -z "$lt_pversion"; then
94  echo "buildcheck: libtoolize not found."
95  echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
96  exit 1
97fi
98lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$/.\1/'`
99IFS=.; set $lt_version; IFS=' '
100lt_status="good"
101if test "$1" = "$LIBTOOL_WANTED_MAJOR"; then
102   if test "$2" -gt "$LIBTOOL_WANTED_MINOR"; then
103      lt_status="good"
104   elif test "$2" -lt "$LIBTOOL_WANTED_MINOR"; then
105      lt_status="bad"
106   elif test ! -z "$LIBTOOL_WANTED_PATCH"; then
107       if test "$3" -lt "$LIBTOOL_WANTED_PATCH"; then
108           lt_status="bad"
109       fi
110   fi
111fi
112if test $lt_status != "good"; then
113  echo "buildcheck: libtool version $lt_pversion found."
114  echo "            You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
115  exit 1
116fi
117
118echo "buildcheck: libtool version $lt_pversion (ok)"
119
120#--------------------------------------------------------------------------
121# check that our local copies of files match up with those in APR(UTIL)
122#
123if test -d ./apr; then
124  if cmp -s ./build/ac-macros/find_apr.m4 ./apr/build/find_apr.m4; then
125    :
126  else
127    echo "buildcheck: local copy of find_apr.m4 does not match APR's copy."
128    echo "            An updated copy of find_apr.m4 may need to be checked in."
129  fi
130  if cmp -s ./build/PrintPath ./apr/build/PrintPath; then
131    :
132  else
133    echo "buildcheck: local copy of PrintPath does not match APR's copy."
134    echo "            An updated copy of PrintPath may need to be checked in."
135  fi
136fi
137
138if test -d ./apr-util; then
139  if cmp -s ./build/ac-macros/find_apu.m4 ./apr-util/build/find_apu.m4; then
140    :
141  else
142    echo "buildcheck: local copy of find_apu.m4 does not match APRUTIL's copy."
143    echo "            An updated copy of find_apu.m4 may need to be checked in."
144  fi
145fi
146
147#--------------------------------------------------------------------------
148exit 0
149