blob: c7abf74fed798b250015fe803092ebb8c7f7b126 [file] [log] [blame]
Behdad Esfahbod29aa4002009-11-02 16:28:39 -05001#!/bin/sh
2# Run this to generate all the initial makefiles, etc.
3set -e
4
5ARGV0=$0
6
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
9srcdir=`dirname $ARGV0`
10test -z "$srcdir" && srcdir=.
11
12ORIGDIR=`pwd`
13cd $srcdir
14
15PACKAGE=harfbuzz
16
17LIBTOOLIZE_FLAGS="--copy --force --automake"
18ACLOCAL_FLAGS=""
19AUTOHEADER=${AUTOHEADER-autoheader}
20GTKDOCIZE_FLAGS="--copy"
21GTKDOCIZE=${GTKDOCIZE-gtkdocize}
22AUTOMAKE_FLAGS="--add-missing --gnu -Wall"
23AUTOCONF=${AUTOCONF-autoconf}
24
25CONFIGURE_AC=
26test -f configure.ac && CONFIGURE_AC=configure.ac
27
28if test "X$CONFIGURE_AC" = X; then
29 echo "$ARGV0: ERROR: No $srcdir/configure.in or $srcdir/configure.ac found."
30 exit 1
31fi
32
33extract_version() {
34 grep "^ *$1" "$CONFIGURE_AC" | sed 's/.*(\[*\([^])]*\)]*).*/\1/'
35}
36
37autoconf_min_vers=`extract_version AC_PREREQ`
38automake_min_vers=`extract_version AM_INIT_AUTOMAKE`
39libtoolize_min_vers=`extract_version AC_PROG_LIBTOOL`
40aclocal_min_vers=$automake_min_vers
41
42
43# Not all echo versions allow -n, so we check what is possible. This test is
44# based on the one in autoconf.
45case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
46 *c*,-n*) ECHO_N= ;;
47 *c*,* ) ECHO_N=-n ;;
48 *) ECHO_N= ;;
49esac
50
51
52# some terminal codes ...
53boldface="`tput bold 2>/dev/null || true`"
54normal="`tput sgr0 2>/dev/null || true`"
55printbold() {
56 echo $ECHO_N "$boldface"
57 echo "$@"
58 echo $ECHO_N "$normal"
59}
60printerr() {
61 echo "$@" >&2
62}
63
64
65# Usage:
66# compare_versions MIN_VERSION ACTUAL_VERSION
67# returns true if ACTUAL_VERSION >= MIN_VERSION
68compare_versions() {
69 ch_min_version=$1
70 ch_actual_version=$2
71 ch_status=0
72 IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="."
73 set $ch_actual_version
74 for ch_min in $ch_min_version; do
75 ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
76 if [ -z "$ch_min" ]; then break; fi
77 if [ -z "$ch_cur" ]; then ch_status=1; break; fi
78 if [ $ch_cur -gt $ch_min ]; then break; fi
79 if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
80 done
81 IFS="$ch_save_IFS"
82 return $ch_status
83}
84
85# Usage:
86# version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
87# checks to see if the package is available
88version_check() {
89 vc_package=$1
90 vc_variable=$2
91 vc_checkprogs=$3
92 vc_min_version=$4
93 vc_source=$5
94 vc_status=1
95
96 vc_checkprog=`eval echo "\\$$vc_variable"`
97 if [ -n "$vc_checkprog" ]; then
98 printbold "using $vc_checkprog for $vc_package"
99 return 0
100 fi
101
102 printbold "checking for $vc_package >= $vc_min_version..."
103 for vc_checkprog in $vc_checkprogs; do
104 echo $ECHO_N " testing $vc_checkprog... "
105 if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
106 vc_actual_version=`$vc_checkprog --version | head -n 1 | \
107 sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
108 if compare_versions $vc_min_version $vc_actual_version; then
109 echo "found $vc_actual_version"
110 # set variable
111 eval "$vc_variable=$vc_checkprog"
112 vc_status=0
113 break
114 else
115 echo "too old (found version $vc_actual_version)"
116 fi
117 else
118 echo "not found."
119 fi
120 done
121 if [ "$vc_status" != 0 ]; then
122 printerr "***Error***: You must have $vc_package >= $vc_min_version installed"
123 printerr " to build $PROJECT. Download the appropriate package for"
124 printerr " from your distribution or get the source tarball at"
125 printerr " $vc_source"
126 printerr
127 fi
128 return $vc_status
129}
130
131
132version_check autoconf AUTOCONF $AUTOCONF $autoconf_min_vers \
133 "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-${autoconf_min_vers}.tar.gz" || DIE=1
134
135#
136# Hunt for an appropriate version of automake and aclocal; we can't
137# assume that 'automake' is necessarily the most recent installed version
138#
139# We check automake first to allow it to be a newer version than we know about.
140#
141version_check automake AUTOMAKE "$AUTOMAKE automake automake-1.10 automake-1.9 automake-1.8 automake-1.7" $automake_min_vers \
142 "http://ftp.gnu.org/pub/gnu/automake/automake-${automake_min_vers}.tar.gz" || DIE=1
143ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
144
145
146version_check libtool LIBTOOLIZE "$LIBTOOLIZE glibtoolize libtoolize" $libtoolize_min_vers \
147 "http://ftp.gnu.org/pub/gnu/libtool/libtool-${libtool_min_vers}.tar.gz" || DIE=1
148
149if test -n "$DIE"; then
150 exit 1
151fi
152
153
154if test -z "$*"; then
155 echo "$ARGV0: Note: \`./configure' will be run with no arguments."
156 echo " If you wish to pass any to it, please specify them on the"
157 echo " \`$0' command line."
158 echo
159fi
160
161do_cmd() {
162 echo "$ARGV0: running \`$@'"
163 $@
164}
165
166do_cmd $LIBTOOLIZE $LIBTOOLIZE_FLAGS
167
168do_cmd $ACLOCAL $ACLOCAL_FLAGS
169
170do_cmd $AUTOHEADER
171
172touch ChangeLog
173
174# We don't call gtkdocize right now. When we do, we should then modify
175# the generated gtk-doc.make and move it to build/Makefile.am.gtk-doc.
176# See that file for details.
177#do_cmd $GTKDOCIZE $GTKDOCIZE_FLAGS
178
179do_cmd $AUTOMAKE $AUTOMAKE_FLAGS
180
181do_cmd $AUTOCONF
182
183cd "$ORIGDIR" || exit 1
184
185rm -f config.cache
186
187do_cmd $srcdir/configure \
188 --cache-file=config.cache \
189 ${1+"$@"} && echo "Now type \`make' to compile $PROJECT." || exit 1