Updated
[gpgme.git] / autogen.sh
1 #! /bin/sh
2 # Run this to generate all the initial makefiles, etc. 
3 #
4 # Copyright (C) 2003 g10 Code GmbH
5 #
6 # This file is free software; as a special exception the author gives
7 # unlimited permission to copy and/or distribute it, with or without
8 # modifications, as long as this notice is preserved.
9 #
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
12 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
14 configure_ac="configure.ac"
15
16 cvtver () {
17   awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}'
18 }
19
20 check_version () {
21     if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then
22        return 0
23     fi
24     echo "**Error**: "\`$1\'" not installed or too old." >&2
25     echo '           Version '$3' or newer is required.' >&2
26     [ -n "$4" ] && echo '           Note that this is part of '\`$4\''.' >&2
27     DIE="yes"
28     return 1
29 }
30
31
32 # Grep the required versions from configure.ac
33 autoconf_vers=`sed -n '/^AC_PREREQ(/ { 
34 s/^.*(\(.*\))/\1/p
35 q
36 }' ${configure_ac}`
37 autoconf_vers_num=`echo "$autoconf_vers" | cvtver`
38
39 automake_vers=`sed -n '/^min_automake_version=/ { 
40 s/^.*="\(.*\)"/\1/p
41 q
42 }' ${configure_ac}`
43 automake_vers_num=`echo "$automake_vers" | cvtver`
44
45 #gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { 
46 #s/^.*(\(.*\))/\1/p
47 #q
48 #}' ${configure_ac}`
49 #gettext_vers_num=`echo "$gettext_vers" | cvtver`
50
51
52 if [ -z "$autoconf_vers" -o -z "$automake_vers" ]
53 then
54   echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2
55   exit 1
56 fi
57
58 # Allow to override the default tool names
59 AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX}
60 AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX}
61
62 AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX}
63 ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX}
64
65 #GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
66 #MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
67
68 DIE=no
69
70
71 if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
72     check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
73 fi
74 if check_version $AUTOMAKE $automake_vers_num $automake_vers; then
75   check_version $ACLOCAL $automake_vers_num $autoconf_vers automake
76 fi
77 #if check_version $GETTEXT $gettext_vers_num $gettext_vers; then
78 #  check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext
79 #fi
80
81 if test "$DIE" = "yes"; then
82     cat <<EOF
83
84 Note that you may use alternative versions of the tools by setting 
85 the corresponding environment variables; see README.CVS for details.
86                    
87 EOF
88     exit 1
89 fi
90
91 echo "Running aclocal -I m4 ..."
92 $ACLOCAL -I m4
93 echo "Running autoheader..."
94 $AUTOHEADER
95 echo "Running automake --gnu ..."
96 $AUTOMAKE --gnu;
97 echo "Running autoconf..."
98 $AUTOCONF
99
100 echo "You may now run \"./configure --enable-maintainer-mode && make\"."