source: trunk/bootstrap @ 673

Last change on this file since 673 was 621, checked in by sam, 10 years ago

Some versions of m4 do not honour M4PATH even if claiming to. Manually
add its contents to the aclocal commandline flags.

  • Property svn:executable set to *
File size: 4.0 KB
Line 
1#! /bin/sh
2
3# bootstrap: generic bootstrap/autogen.sh script for autotools projects
4#
5# Copyright (c) 2002-2010 Sam Hocevar <sam@hocevar.net>
6#
7#    This program is free software. It comes without any warranty, to
8#    the extent permitted by applicable law. You can redistribute it
9#    and/or modify it under the terms of the Do What The Fuck You Want
10#    To Public License, Version 2, as published by Sam Hocevar. See
11#    http://sam.zoy.org/wtfpl/COPYING for more details.
12#
13# The latest version of this script can be found at the following place:
14#    http://caca.zoy.org/wiki/build
15
16# Die if an error occurs
17set -e
18
19# Guess whether we are using configure.ac or configure.in
20if test -f configure.ac; then
21  conffile="configure.ac"
22elif test -f configure.in; then
23  conffile="configure.in"
24else
25  echo "$0: could not find configure.ac or configure.in"
26  exit 1
27fi
28
29# Check for needed features
30auxdir="`sed -ne 's/^[ \t]*A._CONFIG_AUX_DIR *([[ ]*\([^] )]*\).*/\1/p' $conffile`"
31pkgconfig="`grep '^[ \t]*PKG_PROG_PKG_CONFIG' $conffile >/dev/null 2>&1 && echo yes || echo no`"
32libtool="`grep '^[ \t]*A._PROG_LIBTOOL' $conffile >/dev/null 2>&1 && echo yes || echo no`"
33header="`grep '^[ \t]*A._CONFIG_HEADER' $conffile >/dev/null 2>&1 && echo yes || echo no`"
34makefile="`[ -f Makefile.am ] && echo yes || echo no`"
35aclocalflags="`sed -ne 's/^[ \t]*ACLOCAL_AMFLAGS[ \t]*=//p' Makefile.am 2>/dev/null || :`"
36
37# Check for automake
38amvers="no"
39for v in 11 10 9 8 7 6 5; do
40  if automake-1.${v} --version >/dev/null 2>&1; then
41    amvers="-1.${v}"
42    break
43  elif automake1.${v} --version >/dev/null 2>&1; then
44    amvers="1.${v}"
45    break
46  fi
47done
48
49if test "${amvers}" = "no" && automake --version > /dev/null 2>&1; then
50  amvers="`automake --version | sed -e '1s/[^0-9]*//' -e q`"
51  if expr "$amvers" "<" "1.5" > /dev/null 2>&1; then
52    amvers="no"
53  else
54    amvers=""
55  fi
56fi
57
58if test "$amvers" = "no"; then
59  echo "$0: you need automake version 1.5 or later"
60  exit 1
61fi
62
63# Check for autoconf
64acvers="no"
65for v in "" "259" "253"; do
66  if autoconf${v} --version >/dev/null 2>&1; then
67    acvers="${v}"
68    break
69  fi
70done
71
72if test "$acvers" = "no"; then
73  echo "$0: you need autoconf"
74  exit 1
75fi
76
77# Check for libtool
78if test "$libtool" = "yes"; then
79  libtoolize="no"
80  if glibtoolize --version >/dev/null 2>&1; then
81    libtoolize="glibtoolize"
82  else
83    for v in "16" "15" "" "14"; do
84      if libtoolize${v} --version >/dev/null 2>&1; then
85        libtoolize="libtoolize${v}"
86        break
87      fi
88    done
89  fi
90
91  if test "$libtoolize" = "no"; then
92    echo "$0: you need libtool"
93    exit 1
94  fi
95fi
96
97# Check for pkg-config
98if test "$pkgconfig" = "yes"; then
99  if ! pkg-config --version >/dev/null 2>&1; then
100    echo "$0: you need pkg-config"
101    exit 1
102  fi
103fi
104
105# Remove old cruft
106for x in aclocal.m4 configure config.guess config.log config.sub config.cache config.h.in config.h compile libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 ltmain.sh libtool ltconfig missing mkinstalldirs depcomp install-sh; do rm -f $x autotools/$x; if test -n "$auxdir"; then rm -f "$auxdir/$x"; fi; done
107rm -Rf autom4te.cache
108if test -n "$auxdir"; then
109  if test ! -d "$auxdir"; then
110    mkdir "$auxdir"
111  fi
112  aclocalflags="${aclocalflags} -I $auxdir -I ."
113fi
114
115# Honour M4PATH because sometimes M4 doesn't
116save_IFS=$IFS
117IFS=:
118tmp="$M4PATH"
119for x in "$tmp"; do
120  if test -n "$x"; then
121    aclocalflags="${aclocalflags} -I $x"
122  fi
123done
124IFS=$save_IFS
125
126# Explain what we are doing from now
127set -x
128
129# Bootstrap package
130if test "$libtool" = "yes"; then
131  ${libtoolize} --copy --force
132  if test -n "$auxdir" -a ! "$auxdir" = "." -a -f "ltmain.sh"; then
133    echo "$0: working around a minor libtool issue"
134    mv ltmain.sh "$auxdir/"
135  fi
136fi
137
138aclocal${amvers} ${aclocalflags}
139autoconf${acvers}
140if test "$header" = "yes"; then
141  autoheader${acvers}
142fi
143if test "$makefile" = "yes"; then
144  #add --include-deps if you want to bootstrap with any other compiler than gcc
145  #automake${amvers} --add-missing --copy --include-deps
146  automake${amvers} --foreign --add-missing --copy
147fi
148
149# Remove cruft that we no longer want
150rm -Rf autom4te.cache
151
Note: See TracBrowser for help on using the repository browser.