First take on the low-level assuan interface.
[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 DIE=no
33 FORCE=
34 if test "$1" = "--force"; then
35   FORCE=" --force"
36   shift
37 fi
38
39 # Used to cross-compile for Windows.
40 if test "$1" = "--build-w32"; then
41     tmp=`dirname $0`
42     tsdir=`cd "$tmp"; pwd`
43     shift
44     if [ ! -f $tsdir/config.guess ]; then
45         echo "$tsdir/config.guess not found" >&2
46         exit 1
47     fi
48     build=`$tsdir/config.guess`
49
50     [ -z "$w32root" ] && w32root="$HOME/w32root"
51     echo "Using $w32root as standard install directory" >&2
52     
53     # See whether we have the Debian cross compiler package or the
54     # old mingw32/cpd system
55     if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then
56         host=i586-mingw32msvc
57         crossbindir=/usr/$host/bin
58     else
59        host=i386--mingw32
60        if ! mingw32 --version >/dev/null; then
61           echo "We need at least version 0.3 of MingW32/CPD" >&2
62           exit 1
63        fi
64        crossbindir=`mingw32 --install-dir`/bin
65        # Old autoconf version required us to setup the environment
66        # with the proper tool names.
67        CC=`mingw32 --get-path gcc`
68        CPP=`mingw32 --get-path cpp`
69        AR=`mingw32 --get-path ar`
70        RANLIB=`mingw32 --get-path ranlib`
71        export CC CPP AR RANLIB 
72     fi
73    
74     if [ -f "$tsdir/config.log" ]; then
75         if ! head $tsdir/config.log | grep "$host" >/dev/null; then
76             echo "Pease run a 'make distclean' first" >&2
77             exit 1
78         fi
79     fi
80
81     ./configure --enable-maintainer-mode  --prefix=${w32root}  \
82             --host=i586-mingw32msvc --build=${build} \
83             --with-gpg-error-prefix=${w32root} \
84             --enable-shared --enable-static --enable-w32-glib \
85             PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig"
86
87     exit $?
88 fi
89
90
91
92
93
94 # Grep the required versions from configure.ac
95 autoconf_vers=`sed -n '/^AC_PREREQ(/ { 
96 s/^.*(\(.*\))/\1/p
97 q
98 }' ${configure_ac}`
99 autoconf_vers_num=`echo "$autoconf_vers" | cvtver`
100
101 automake_vers=`sed -n '/^min_automake_version=/ { 
102 s/^.*="\(.*\)"/\1/p
103 q
104 }' ${configure_ac}`
105 automake_vers_num=`echo "$automake_vers" | cvtver`
106
107 #gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { 
108 #s/^.*(\(.*\))/\1/p
109 #q
110 #}' ${configure_ac}`
111 #gettext_vers_num=`echo "$gettext_vers" | cvtver`
112
113
114 if [ -z "$autoconf_vers" -o -z "$automake_vers" ]
115 then
116   echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2
117   exit 1
118 fi
119
120 # Allow to override the default tool names
121 AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX}
122 AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX}
123
124 AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX}
125 ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX}
126
127 #GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
128 #MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
129
130 DIE=no
131
132
133 if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
134     check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
135 fi
136 if check_version $AUTOMAKE $automake_vers_num $automake_vers; then
137     check_version $ACLOCAL $automake_vers_num $automake_vers automake
138 fi
139 #if check_version $GETTEXT $gettext_vers_num $gettext_vers; then
140 #  check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext
141 #fi
142
143 if test "$DIE" = "yes"; then
144     cat <<EOF
145
146 Note that you may use alternative versions of the tools by setting 
147 the corresponding environment variables; see README.CVS for details.
148                    
149 EOF
150     exit 1
151 fi
152
153 echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..."
154 $ACLOCAL -I m4 $ACLOCAL_FLAGS
155 echo "Running autoheader..."
156 $AUTOHEADER
157 echo "Running automake --gnu ..."
158 $AUTOMAKE --gnu;
159 echo "Running autoconf${FORCE} ..."
160 $AUTOCONF${FORCE}
161
162 echo "You may now run:
163   ./configure --enable-maintainer-mode && make
164 "