2005-10-08 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / autogen.sh
blobaaf0d0ea402b9cb46b785d78c695de4e5d4e3c53
1 #! /bin/sh
2 # Run this to generate all the initial makefiles, etc.
4 # Copyright (C) 2003 g10 Code GmbH
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.
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.
14 configure_ac="configure.ac"
16 cvtver () {
17 awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}'
20 check_version () {
21 if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then
22 return 0
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
31 # Allow to override the default tool names
32 AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX}
33 AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX}
35 AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX}
36 ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX}
38 GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
39 MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
41 DIE=no
43 # ***** W32 build script *******
44 # Used to cross-compile for Windows.
45 if test "$1" = "--build-w32"; then
46 tmp=`dirname $0`
47 tsdir=`cd "$tmp"; pwd`
48 shift
49 if [ ! -f $tsdir/scripts/config.guess ]; then
50 echo "$tsdir/scripts/config.guess not found" >&2
51 exit 1
53 build=`$tsdir/scripts/config.guess`
55 [ -z "$w32root" ] && w32root="$HOME/w32root"
56 echo "Using $w32root as standard install directory" >&2
58 # See whether we have the Debian cross compiler package or the
59 # old mingw32/cpd system
60 if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then
61 host=i586-mingw32msvc
62 crossbindir=/usr/$host/bin
63 else
64 host=i386--mingw32
65 if ! mingw32 --version >/dev/null; then
66 echo "We need at least version 0.3 of MingW32/CPD" >&2
67 exit 1
69 crossbindir=`mingw32 --install-dir`/bin
70 # Old autoconf version required us to setup the environment
71 # with the proper tool names.
72 CC=`mingw32 --get-path gcc`
73 CPP=`mingw32 --get-path cpp`
74 AR=`mingw32 --get-path ar`
75 RANLIB=`mingw32 --get-path ranlib`
76 export CC CPP AR RANLIB
79 if [ -f "$tsdir/config.log" ]; then
80 if ! head $tsdir/config.log | grep "$host" >/dev/null; then
81 echo "Pease run a 'make distclean' first" >&2
82 exit 1
86 ./configure --enable-maintainer-mode --prefix=${w32root} \
87 --host=i586-mingw32msvc --build=${build} \
88 --with-gpg-error-prefix=${w32root} \
89 --with-ksba-prefix=${w32root} \
90 --with-libgcrypt-prefix=${w32root} \
91 --with-libassuan-prefix=${w32root} \
92 --with-zlib=${w32root} \
93 --with-pth-prefix=${w32root} \
94 --disable-gpg
95 rc=$?
96 # Ugly hack to overcome a gettext problem. Someone should look into
97 # gettext to figure out why the po directory is not ignored as it used
98 # to be.
99 [ $rc = 0 ] && touch $tsdir/po/all
100 exit $rc
102 # ***** end W32 build script *******
107 # Grep the required versions from configure.ac
108 autoconf_vers=`sed -n '/^AC_PREREQ(/ {
109 s/^.*(\(.*\))/\1/p
111 }' ${configure_ac}`
112 autoconf_vers_num=`echo "$autoconf_vers" | cvtver`
114 automake_vers=`sed -n '/^min_automake_version=/ {
115 s/^.*="\(.*\)"/\1/p
117 }' ${configure_ac}`
118 automake_vers_num=`echo "$automake_vers" | cvtver`
120 gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ {
121 s/^.*(\(.*\))/\1/p
123 }' ${configure_ac}`
124 gettext_vers_num=`echo "$gettext_vers" | cvtver`
127 if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ]
128 then
129 echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2
130 exit 1
134 if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
135 check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
137 if check_version $AUTOMAKE $automake_vers_num $automake_vers; then
138 check_version $ACLOCAL $automake_vers_num $autoconf_vers automake
140 if check_version $GETTEXT $gettext_vers_num $gettext_vers; then
141 check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext
144 if test "$DIE" = "yes"; then
145 cat <<EOF
147 Note that you may use alternative versions of the tools by setting
148 the corresponding environment variables; see README.CVS for details.
151 exit 1
155 echo "Running aclocal -I m4 -I gl/m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..."
156 $ACLOCAL -I m4 -I gl/m4 $ACLOCAL_FLAGS
157 echo "Running autoheader..."
158 $AUTOHEADER
159 echo "Running automake --gnu ..."
160 $AUTOMAKE --gnu;
161 echo "Running autoconf..."
162 $AUTOCONF
164 echo "You may now run \"./configure --enable-maintainer-mode && make\"."