automake-1.10 fixes (SF#1791361: https://sourceforge.net/tracker/index.php?func=detai...
[platform/upstream/flac.git] / autogen.sh
1 #!/bin/sh
2 # Run this to set up the build system: configure, makefiles, etc.
3 # (based on the version in enlightenment's cvs)
4
5 # Some notes:
6 #
7 # You may need to specify -I /SOME_PATH/share/aclocal in ACLOCAL_FLAGS
8 # if any packages FLAC relies on (autotools, libogg, libiconv) are
9 # installed in non-standard places.
10 #
11 # If you don't have XMMS installed at all, you should comment out
12 # AM_PATH_XMMS in configure.in.
13 #
14 # FLAC uses iconv but not gettext.  iconv requires config.rpath which
15 # is supplied by gettext, which is copied in by gettextize.  But we
16 # can't run gettextize since we do not fulfill all it's requirements
17 # (because we don't use it).  So you may have to:
18 #
19 #   cp /usr/share/gettext/config.rpath .
20 #
21 # before running autogen.sh
22 #
23 # Also watchout, if you replace ltmain.sh, there is a bug in some
24 # versions of libtool (or maybe autoconf) on some platforms where the
25 # configure-generated libtool does not have $SED defined.  See also:
26 #
27 #   http://lists.gnu.org/archive/html/libtool/2003-11/msg00131.html
28
29 package="flac"
30
31 olddir=`pwd`
32 srcdir=`dirname $0`
33 test -z "$srcdir" && srcdir=.
34
35 cd "$srcdir"
36 DIE=0
37
38 ACLOCAL_FLAGS="-I m4 $ACLOCAL_FLAGS"
39
40 echo "checking for autoconf... "
41 (autoconf --version) < /dev/null > /dev/null 2>&1 || {
42         echo
43         echo "You must have autoconf installed to compile $package."
44         echo "Download the appropriate package for your distribution,"
45         echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
46         DIE=1
47 }
48
49 VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/"
50 VERSIONMKMAJ="sed -e s/\([0-9][0-9]*\)[^0-9].*/\\1/"
51 VERSIONMKMIN="sed -e s/.*[0-9][0-9]*\.//"
52                                                                                 
53 # do we need automake?
54 if test -r Makefile.am; then
55   AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am`
56   AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP`
57   if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then
58     AM_NEEDED=""
59   fi
60   if test -z $AM_NEEDED; then
61     echo -n "checking for automake... "
62     AUTOMAKE=automake
63     ACLOCAL=aclocal
64     if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
65       echo "yes"
66     else
67       echo "no"
68       AUTOMAKE=
69     fi
70   else
71     echo -n "checking for automake $AM_NEEDED or later... "
72     majneeded=`echo $AM_NEEDED | $VERSIONMKMAJ`
73     minneeded=`echo $AM_NEEDED | $VERSIONMKMIN`
74     for am in automake-$AM_NEEDED automake$AM_NEEDED \
75         automake automake-1.7 automake-1.8 automake-1.9 automake-1.10; do
76       ($am --version < /dev/null > /dev/null 2>&1) || continue
77       ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP`
78       maj=`echo $ver | $VERSIONMKMAJ`
79       min=`echo $ver | $VERSIONMKMIN`
80       if test $maj -eq $majneeded -a $min -ge $minneeded; then
81         AUTOMAKE=$am
82         echo $AUTOMAKE
83         break
84       fi
85     done
86     test -z $AUTOMAKE &&  echo "no"
87     echo -n "checking for aclocal $AM_NEEDED or later... "
88     for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED \
89         aclocal aclocal-1.7 aclocal-1.8 aclocal-1.9 aclocal-1.10; do
90       ($ac --version < /dev/null > /dev/null 2>&1) || continue
91       ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP`
92       maj=`echo $ver | $VERSIONMKMAJ`
93       min=`echo $ver | $VERSIONMKMIN`
94       if test $maj -eq $majneeded -a $min -ge $minneeded; then
95         ACLOCAL=$ac
96         echo $ACLOCAL
97         break
98       fi
99     done
100     test -z $ACLOCAL && echo "no"
101   fi
102   test -z $AUTOMAKE || test -z $ACLOCAL && {
103         echo
104         echo "You must have automake installed to compile $package."
105         echo "Download the appropriate package for your distribution,"
106         echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
107         exit 1
108   }
109 fi
110
111 echo -n "checking for libtool... "
112 for LIBTOOLIZE in libtoolize glibtoolize nope; do
113   ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break
114 done
115 if test x$LIBTOOLIZE = xnope; then
116   echo "nope."
117   LIBTOOLIZE=libtoolize
118 else
119   echo $LIBTOOLIZE
120 fi
121 ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
122         echo
123         echo "You must have libtool installed to compile $package."
124         echo "Download the appropriate package for your system,"
125         echo "or get the source from one of the GNU ftp sites"
126         echo "listed in http://www.gnu.org/order/ftp.html"
127         DIE=1
128 }
129
130 if test "$DIE" -eq 1; then
131         exit 1
132 fi
133
134 if test -z "$*"; then
135         echo "I am going to run ./configure with no arguments - if you wish "
136         echo "to pass any to it, please specify them on the $0 command line."
137 fi
138
139 echo "Generating configuration files for $package, please wait...."
140
141 echo "  $ACLOCAL $ACLOCAL_FLAGS"
142 $ACLOCAL $ACLOCAL_FLAGS || exit 1
143 echo "  $LIBTOOLIZE --automake"
144 $LIBTOOLIZE --automake || exit 1
145 echo "  autoheader"
146 autoheader || exit 1
147 echo "  $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
148 $AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1
149 echo "  autoconf"
150 autoconf || exit 1
151
152 cd $olddir
153 $srcdir/configure --enable-maintainer-mode "$@" && echo