~libmms-devel/libmms/trunk

« back to all changes in this revision

Viewing changes to autogen.sh

  • Committer: jwrdegoede
  • Date: 2007-12-11 20:36:50 UTC
  • Revision ID: vcs-imports@canonical.com-20071211203650-rb3j5ejgzn39yddz
2007-12-11  Hans de Goede <j.w.r.degoede@hhs.nl>

        * Remove out of date (not working with recent autotools) autogen.sh,
          use: "autoreconf -i -f -v" instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
# Run this to generate all the initial makefiles, etc.
3
 
 
4
 
#name of package
5
 
PKG_NAME="libmms"
6
 
srcdir=${srcdir:-.}
7
 
 
8
 
# default version requirements ...
9
 
REQUIRED_AUTOCONF_VERSION=${REQUIRED_AUTOCONF_VERSION:-2.53}
10
 
REQUIRED_AUTOMAKE_VERSION=${REQUIRED_AUTOMAKE_VERSION:-1.5}
11
 
REQUIRED_LIBTOOL_VERSION=${REQUIRED_LIBTOOL_VERSION:-1.4.3}
12
 
REQUIRED_PKG_CONFIG_VERSION=${REQUIRED_PKG_CONFIG_VERSION:-0.14.0}
13
 
 
14
 
# a list of required m4 macros.  Package can set an initial value
15
 
REQUIRED_M4MACROS=${REQUIRED_M4MACROS:-}
16
 
FORBIDDEN_M4MACROS=${FORBIDDEN_M4MACROS:-}
17
 
 
18
 
 
19
 
# some terminal codes ...
20
 
boldface="`tput bold 2>/dev/null`"
21
 
normal="`tput sgr0 2>/dev/null`"
22
 
printbold() {
23
 
    echo -n "$boldface"
24
 
    echo "$@"
25
 
    echo -n "$normal"
26
 
}    
27
 
printerr() {
28
 
    echo "$@" >&2
29
 
}
30
 
 
31
 
# Usage:
32
 
#     compare_versions MIN_VERSION ACTUAL_VERSION
33
 
# returns true if ACTUAL_VERSION >= MIN_VERSION
34
 
compare_versions() {
35
 
    local min_version actual_version status save_IFS cur min
36
 
    min_version=$1
37
 
    actual_version=$2
38
 
    status=0
39
 
    IFS="${IFS=         }"; save_IFS="$IFS"; IFS="."
40
 
    set $actual_version
41
 
    for min in $min_version; do
42
 
        cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
43
 
        if [ -z "$min" ]; then break; fi
44
 
        if [ -z "$cur" ]; then status=1; break; fi
45
 
        if [ $cur -gt $min ]; then break; fi
46
 
        if [ $cur -lt $min ]; then status=1; break; fi
47
 
    done
48
 
    IFS="$save_IFS"
49
 
    return $status
50
 
}
51
 
 
52
 
# Usage:
53
 
#     version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
54
 
# checks to see if the package is available
55
 
version_check() {
56
 
    local package variable checkprogs min_version source status checkprog actual_version
57
 
    package=$1
58
 
    variable=$2
59
 
    checkprogs=$3
60
 
    min_version=$4
61
 
    source=$5
62
 
    status=1
63
 
 
64
 
    checkprog=`eval echo "\\$$variable"`
65
 
    if [ -n "$checkprog" ]; then
66
 
        printbold "using $checkprog for $package"
67
 
        return 0
68
 
    fi
69
 
 
70
 
    printbold "checking for $package >= $min_version..."
71
 
    for checkprog in $checkprogs; do
72
 
        echo -n "  testing $checkprog... "
73
 
        if $checkprog --version < /dev/null > /dev/null 2>&1; then
74
 
            actual_version=`$checkprog --version | head -n 1 | \
75
 
                               sed 's/^.*[      ]\([0-9.]*[a-z]*\).*$/\1/'`
76
 
            if compare_versions $min_version $actual_version; then
77
 
                echo "found."
78
 
                # set variable
79
 
                eval "$variable=$checkprog"
80
 
                status=0
81
 
                break
82
 
            else
83
 
                echo "too old (found version $actual_version)"
84
 
            fi
85
 
        else
86
 
            echo "not found."
87
 
        fi
88
 
    done
89
 
    if [ "$status" != 0 ]; then
90
 
        printerr "***Error***: You must have $package >= $min_version installed"
91
 
        printerr "  to build $PKG_NAME.  Download the appropriate package for"
92
 
        printerr "  from your distribution or get the source tarball at"
93
 
        printerr "    $source"
94
 
        printerr
95
 
    fi
96
 
    return $status
97
 
}
98
 
 
99
 
# Usage:
100
 
#     require_m4macro filename.m4
101
 
# adds filename.m4 to the list of required macros
102
 
require_m4macro() {
103
 
    case "$REQUIRED_M4MACROS" in
104
 
        $1\ * | *\ $1\ * | *\ $1) ;;
105
 
        *) REQUIRED_M4MACROS="$REQUIRED_M4MACROS $1" ;;
106
 
    esac
107
 
}
108
 
 
109
 
forbid_m4macro() {
110
 
    case "$FORBIDDEN_M4MACROS" in
111
 
        $1\ * | *\ $1\ * | *\ $1) ;;
112
 
        *) FORBIDDEN_M4MACROS="$FORBIDDEN_M4MACROS $1" ;;
113
 
    esac
114
 
}
115
 
 
116
 
# Usage:
117
 
#     check_m4macros
118
 
# Checks that all the requested macro files are in the aclocal macro path
119
 
# Uses REQUIRED_M4MACROS and ACLOCAL variables.
120
 
check_m4macros() {
121
 
    local macrodirs status macro dir macrofound
122
 
 
123
 
    # construct list of macro directories
124
 
    macrodirs="`$ACLOCAL --print-ac-dir`"
125
 
    set - $ACLOCAL_FLAGS
126
 
    while [ $# -gt 0 ]; do
127
 
        if [ "$1" = "-I" ]; then
128
 
            macrodirs="$macrodirs $2"
129
 
            shift
130
 
        fi
131
 
        shift
132
 
    done
133
 
 
134
 
    status=0
135
 
    if [ -n "$REQUIRED_M4MACROS" ]; then
136
 
        printbold "Checking for required M4 macros..."
137
 
        # check that each macro file is in one of the macro dirs
138
 
        for macro in $REQUIRED_M4MACROS; do
139
 
            macrofound=false
140
 
            for dir in $macrodirs; do
141
 
                if [ -f "$dir/$macro" ]; then
142
 
                    macrofound=true
143
 
                    break
144
 
                fi
145
 
            done
146
 
            if $macrofound; then
147
 
                :
148
 
            else
149
 
                printerr "  $macro not found"
150
 
                status=1
151
 
            fi
152
 
        done
153
 
    fi
154
 
    if [ -n "$FORBIDDEN_M4MACROS" ]; then
155
 
        printbold "Checking for forbidden M4 macros..."
156
 
        # check that each macro file is in one of the macro dirs
157
 
        for macro in $FORBIDDEN_M4MACROS; do
158
 
            macrofound=false
159
 
            for dir in $macrodirs; do
160
 
                if [ -f "$dir/$macro" ]; then
161
 
                    macrofound=true
162
 
                    break
163
 
                fi
164
 
            done
165
 
            if $macrofound; then
166
 
                printerr "  $macro found (should be cleared from macros dir)"
167
 
                status=1
168
 
            fi
169
 
        done
170
 
    fi
171
 
    if [ "$status" != 0 ]; then
172
 
        printerr "***Error***: some autoconf macros required to build $PKG_NAME"
173
 
        printerr "  were not found in your aclocal path, or some forbidden"
174
 
        printerr "  macros were found.  Perhaps you need to adjust your"
175
 
        printerr "  ACLOCAL_PATH?"
176
 
        printerr
177
 
    fi
178
 
    return $status
179
 
}
180
 
 
181
 
# try to catch the case where the macros2/ directory hasn't been cleared out.
182
 
forbid_m4macro gnome-cxx-check.m4
183
 
 
184
 
want_libtool=false
185
 
want_gettext=false
186
 
want_glib_gettext=false
187
 
want_intltool=false
188
 
want_pkg_config=false
189
 
want_gtk_doc=false
190
 
 
191
 
configure_files="`find $srcdir -name configure.ac -print -or -name configure.in -print`"
192
 
for configure_ac in $configure_files; do
193
 
    if grep "^A[CM]_PROG_LIBTOOL" $configure_ac >/dev/null; then
194
 
        want_libtool=true
195
 
    fi
196
 
    if grep "^AM_GNU_GETTEXT" $configure_ac >/dev/null; then
197
 
        want_gettext=true
198
 
    fi
199
 
    if grep "^AC_PROG_INTLTOOL" $configure_ac >/dev/null; then
200
 
        want_intltool=true
201
 
    fi
202
 
    if grep "^PKG_CHECK_MODULES" $configure_ac >/dev/null; then
203
 
        want_pkg_config=true
204
 
    fi
205
 
done
206
 
 
207
 
DIE=0
208
 
 
209
 
#tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13
210
 
WANT_AUTOCONF_2_5=1
211
 
export WANT_AUTOCONF_2_5
212
 
version_check autoconf AUTOCONF 'autoconf2.50 autoconf autoconf-2.53' $REQUIRED_AUTOCONF_VERSION \
213
 
    "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTOCONF_VERSION.tar.gz" || DIE=1
214
 
AUTOHEADER=`echo $AUTOCONF | sed s/autoconf/autoheader/`
215
 
 
216
 
case $REQUIRED_AUTOMAKE_VERSION in
217
 
    1.4*) automake_progs="automake-1.4" ;;
218
 
    1.5*) automake_progs="automake-1.7 automake-1.6 automake-1.5" ;;
219
 
    1.6*) automake_progs="automake-1.8 automake-1.7 automake-1.6" ;;
220
 
    1.7*) automake_progs="automake-1.8 automake-1.7" ;;
221
 
    1.8*) automake_progs="automake-1.8" ;;
222
 
esac
223
 
version_check automake AUTOMAKE "$automake_progs" $REQUIRED_AUTOMAKE_VERSION \
224
 
    "http://ftp.gnu.org/pub/gnu/automake/automake-$REQUIRED_AUTOMAKE_VERSION.tar.gz" || DIE=1
225
 
ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
226
 
 
227
 
if $want_libtool; then
228
 
    version_check libtool LIBTOOLIZE libtoolize $REQUIRED_LIBTOOL_VERSION \
229
 
        "http://ftp.gnu.org/pub/gnu/libtool/libtool-$REQUIRED_LIBTOOL_VERSION.tar.gz" || DIE=1
230
 
    require_m4macro libtool.m4
231
 
fi
232
 
 
233
 
if $want_gettext; then
234
 
    version_check gettext GETTEXTIZE gettextize $REQUIRED_GETTEXT_VERSION \
235
 
        "http://ftp.gnu.org/pub/gnu/gettext/gettext-$REQUIRED_GETTEXT_VERSION.tar.gz" || DIE=1
236
 
    require_m4macro gettext.m4
237
 
fi
238
 
 
239
 
if $want_pkg_config; then
240
 
    version_check pkg-config PKG_CONFIG pkg-config $REQUIRED_PKG_CONFIG_VERSION \
241
 
        "'http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-$REQUIRED_PKG_CONFIG_VERSION.tar.gz" || DIE=1
242
 
    require_m4macro pkg.m4
243
 
fi
244
 
 
245
 
 
246
 
check_m4macros || DIE=1
247
 
 
248
 
if [ "$DIE" -eq 1 ]; then
249
 
  exit 1
250
 
fi
251
 
 
252
 
if test -z "$*"; then
253
 
  printerr "**Warning**: I am going to run \`configure' with no arguments."
254
 
  printerr "If you wish to pass any to it, please specify them on the"
255
 
  printerr \`$0\'" command line."
256
 
  printerr
257
 
fi
258
 
 
259
 
topdir=`pwd`
260
 
for configure_ac in $configure_files; do 
261
 
    dirname=`dirname $configure_ac`
262
 
    basename=`basename $configure_ac`
263
 
    if test -f $dirname/NO-AUTO-GEN; then
264
 
        echo skipping $dirname -- flagged as no auto-gen
265
 
    else
266
 
        printbold "Processing $configure_ac"
267
 
 
268
 
        aclocalinclude="$ACLOCAL_FLAGS"
269
 
        printbold "Running $ACLOCAL..."
270
 
        $ACLOCAL $aclocalinclude || exit 1
271
 
 
272
 
        if grep "GNOME_AUTOGEN_OBSOLETE" aclocal.m4 >/dev/null; then
273
 
            printerr "*** obsolete gnome macros were used in $configure_ac"
274
 
        fi
275
 
 
276
 
        if grep "^A[CM]_PROG_LIBTOOL" $basename >/dev/null; then
277
 
            printbold "Running $LIBTOOLIZE..."
278
 
            $LIBTOOLIZE --force || exit 1
279
 
        fi
280
 
        if grep "^AM_GLIB_GNU_GETTEXT" $basename >/dev/null; then
281
 
            printbold "Running $GLIB_GETTEXTIZE... Ignore non-fatal messages."
282
 
            echo "no" | $GLIB_GETTEXTIZE --force --copy || exit 1
283
 
        elif grep "^AM_GNU_GETTEXT" $basename >/dev/null; then
284
 
           if grep "^AM_GNU_GETTEXT_VERSION" $basename > /dev/null; then
285
 
                printbold "Running autopoint..."
286
 
                autopoint --force || exit 1
287
 
           else
288
 
                printbold "Running $GETTEXTIZE... Ignore non-fatal messages."
289
 
                echo "no" | $GETTEXTIZE --force --copy || exit 1
290
 
           fi
291
 
        fi
292
 
        if grep "^AC_PROG_INTLTOOL" $basename >/dev/null; then
293
 
            printbold "Running $INTLTOOLIZE..."
294
 
            $INTLTOOLIZE --force --automake || exit 1
295
 
        fi
296
 
        if grep "^GTK_DOC_CHECK" $basename >/dev/null; then
297
 
            printbold "Running $GTKDOCIZE..."
298
 
            $GTKDOCIZE || exit 1
299
 
        fi
300
 
        if grep "^A[CM]_CONFIG_HEADER" $basename >/dev/null; then
301
 
            printbold "Running $AUTOHEADER..."
302
 
            $AUTOHEADER || exit 1
303
 
        fi
304
 
 
305
 
        printbold "Running $AUTOMAKE..."
306
 
        $AUTOMAKE --gnu --add-missing || exit 1
307
 
 
308
 
        printbold "Running $AUTOCONF..."
309
 
        $AUTOCONF || exit 1
310
 
 
311
 
        cd $topdir
312
 
    fi
313
 
done
314
 
 
315
 
conf_flags="--enable-maintainer-mode --enable-compile-warnings"
316
 
 
317
 
if test x$NOCONFIGURE = x; then
318
 
    printbold Running $srcdir/configure $conf_flags "$@" ...
319
 
    $srcdir/configure $conf_flags "$@" \
320
 
        && echo Now type \`make\' to compile $PKG_NAME || exit 1
321
 
else
322
 
    echo Skipping configure process.
323
 
fi