[check] Filter programlistings for check-doc-syntax.sh
[cairo/haiku.git] / autogen.sh
blob4253a918d329e72837cb4946dd64081c98c1b04e
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3 set -e
5 ARGV0=$0
7 # Allow invocation from a separate build directory; in that case, we change
8 # to the source directory to run the auto*, then change back before running configure
9 srcdir=`dirname $ARGV0`
10 test -z "$srcdir" && srcdir=.
12 ORIGDIR=`pwd`
13 cd $srcdir
15 PACKAGE=cairo
17 LIBTOOLIZE=${LIBTOOLIZE-libtoolize}
18 LIBTOOLIZE_FLAGS="--copy --force"
19 AUTOHEADER=${AUTOHEADER-autoheader}
20 AUTOMAKE_FLAGS="--add-missing --foreign"
21 AUTOCONF=${AUTOCONF-autoconf}
23 CONFIGURE_IN=
24 test -f configure.in && CONFIGURE_IN=configure.in
25 test -f configure.ac && CONFIGURE_IN=configure.ac
27 if test "X$CONFIGURE_IN" = X; then
28 echo "$ARGV0: ERROR: No $srcdir/configure.in or $srcdir/configure.ac found."
29 exit 1
32 extract_version() {
33 grep "^ *$1" $CONFIGURE_IN | sed 's/.*(\[*\([^])]*\)]*).*/\1/'
36 autoconf_min_vers=`extract_version AC_PREREQ`
37 automake_min_vers=`extract_version AM_INIT_AUTOMAKE`
38 libtoolize_min_vers=`extract_version AC_PROG_LIBTOOL`
39 aclocal_min_vers=$automake_min_vers
42 # Not all echo versions allow -n, so we check what is possible. This test is
43 # based on the one in autoconf.
44 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
45 *c*,-n*) ECHO_N= ;;
46 *c*,* ) ECHO_N=-n ;;
47 *) ECHO_N= ;;
48 esac
51 # some terminal codes ...
52 boldface="`tput bold 2>/dev/null || true`"
53 normal="`tput sgr0 2>/dev/null || true`"
54 printbold() {
55 echo $ECHO_N "$boldface"
56 echo "$@"
57 echo $ECHO_N "$normal"
59 printerr() {
60 echo "$@" >&2
64 # Usage:
65 # compare_versions MIN_VERSION ACTUAL_VERSION
66 # returns true if ACTUAL_VERSION >= MIN_VERSION
67 compare_versions() {
68 ch_min_version=$1
69 ch_actual_version=$2
70 ch_status=0
71 IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="."
72 set $ch_actual_version
73 for ch_min in $ch_min_version; do
74 ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
75 if [ -z "$ch_min" ]; then break; fi
76 if [ -z "$ch_cur" ]; then ch_status=1; break; fi
77 if [ $ch_cur -gt $ch_min ]; then break; fi
78 if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
79 done
80 IFS="$ch_save_IFS"
81 return $ch_status
84 # Usage:
85 # version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
86 # checks to see if the package is available
87 version_check() {
88 vc_package=$1
89 vc_variable=$2
90 vc_checkprogs=$3
91 vc_min_version=$4
92 vc_source=$5
93 vc_status=1
95 vc_checkprog=`eval echo "\\$$vc_variable"`
96 if [ -n "$vc_checkprog" ]; then
97 printbold "using $vc_checkprog for $vc_package"
98 return 0
101 printbold "checking for $vc_package >= $vc_min_version..."
102 for vc_checkprog in $vc_checkprogs; do
103 echo $ECHO_N " testing $vc_checkprog... "
104 if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
105 vc_actual_version=`$vc_checkprog --version | head -n 1 | \
106 sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
107 if compare_versions $vc_min_version $vc_actual_version; then
108 echo "found $vc_actual_version"
109 # set variable
110 eval "$vc_variable=$vc_checkprog"
111 vc_status=0
112 break
113 else
114 echo "too old (found version $vc_actual_version)"
116 else
117 echo "not found."
119 done
120 if [ "$vc_status" != 0 ]; then
121 printerr "***Error***: You must have $vc_package >= $vc_min_version installed"
122 printerr " to build $PROJECT. Download the appropriate package for"
123 printerr " from your distribution or get the source tarball at"
124 printerr " $vc_source"
125 printerr
127 return $vc_status
131 version_check autoconf AUTOCONF $AUTOCONF $autoconf_min_vers \
132 "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-${autoconf_min_vers}.tar.gz" || DIE=1
135 # Hunt for an appropriate version of automake and aclocal; we can't
136 # assume that 'automake' is necessarily the most recent installed version
138 # We check automake first to allow it to be a newer version than we know about.
140 version_check automake AUTOMAKE "$AUTOMAKE automake automake-1.10 automake-1.9 automake-1.8 automake-1.7" $automake_min_vers \
141 "http://ftp.gnu.org/pub/gnu/automake/automake-${automake_min_vers}.tar.gz" || DIE=1
142 ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
145 version_check libtool LIBTOOLIZE $LIBTOOLIZE $libtoolize_min_vers \
146 "http://ftp.gnu.org/pub/gnu/libtool/libtool-${libtool_min_vers}.tar.gz" || DIE=1
148 if test -z "$ACLOCAL_FLAGS"; then
149 acdir=`$ACLOCAL --print-ac-dir`
150 if [ ! -f $acdir/pkg.m4 ]; then
151 echo "$ARGV0: Error: Could not find pkg-config macros."
152 echo " (Looked in $acdir/pkg.m4)"
153 echo " If pkg.m4 is available in /another/directory, please set"
154 echo " ACLOCAL_FLAGS=\"-I /another/directory\""
155 echo " Otherwise, please install pkg-config."
156 echo ""
157 echo "pkg-config is available from:"
158 echo "http://www.freedesktop.org/software/pkgconfig/"
159 DIE=yes
163 if test "X$DIE" != X; then
164 exit 1
168 if test -z "$*"; then
169 echo "$ARGV0: Note: \`./configure' will be run with no arguments."
170 echo " If you wish to pass any to it, please specify them on the"
171 echo " \`$0' command line."
172 echo
175 do_cmd() {
176 echo "$ARGV0: running \`$@'"
180 do_cmd $LIBTOOLIZE $LIBTOOLIZE_FLAGS
182 do_cmd $ACLOCAL $ACLOCAL_FLAGS
184 do_cmd $AUTOHEADER
186 do_cmd $AUTOMAKE $AUTOMAKE_FLAGS
188 do_cmd $AUTOCONF
190 cd $ORIGDIR || exit 1
192 rm -f config.cache
194 do_cmd $srcdir/configure \
195 --cache-file=config.cache \
196 --disable-static \
197 --enable-gtk-doc \
198 --enable-test-surfaces \
199 ${1+"$@"} && echo "Now type \`make' to compile $PROJECT." || exit 1