Imported Upstream version 2.0.26
[platform/upstream/gpg2.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 # Allow to override the default tool names
32 AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX}
33 AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX}
34
35 AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX}
36 ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX}
37
38 GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
39 MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
40
41 DIE=no
42 FORCE=
43 if test x"$1" = x"--force"; then
44   FORCE=" --force"
45   shift
46 fi
47
48 # ***** W32 build script *******
49 # Used to cross-compile for Windows.
50 if test "$1" = "--build-w32"; then
51     tmp=`dirname $0`
52     tsdir=`cd "$tmp"; pwd`
53     shift
54     if [ ! -f $tsdir/scripts/config.guess ]; then
55         echo "$tsdir/scripts/config.guess not found" >&2
56         exit 1
57     fi
58     build=`$tsdir/scripts/config.guess`
59
60     [ -z "$w32root" ] && w32root="$HOME/w32root"
61     echo "Using $w32root as standard install directory" >&2
62
63     # Locate the cross compiler
64     crossbindir=
65     for host in i686-w64-mingw32 i586-mingw32msvc i386-mingw32msvc mingw32; do
66         if ${host}-gcc --version >/dev/null 2>&1 ; then
67             crossbindir=/usr/${host}/bin
68             conf_CC="CC=${host}-gcc"
69             break;
70         fi
71     done
72     if [ -z "$crossbindir" ]; then
73         echo "Cross compiler kit not installed" >&2
74         echo "Under Debian GNU/Linux, you may install it using" >&2
75         echo "  apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2
76         echo "Stop." >&2
77         exit 1
78     fi
79
80     if [ -f "$tsdir/config.log" ]; then
81         if ! head $tsdir/config.log | grep "$host" >/dev/null; then
82             echo "Please run a 'make distclean' first" >&2
83             exit 1
84         fi
85     fi
86
87     $tsdir/configure --enable-maintainer-mode --prefix=${w32root}  \
88              --host=${host} --build=${build} \
89              --enable-gpgtar \
90              --with-gpg-error-prefix=${w32root} \
91              --with-ksba-prefix=${w32root} \
92              --with-libgcrypt-prefix=${w32root} \
93              --with-libassuan-prefix=${w32root} \
94              --with-zlib=${w32root} \
95              --with-regex=${w32root} \
96              --with-pth-prefix=${w32root} \
97              --with-libiconv-prefix=${w32root} \
98              --with-adns=${w32root} "$@"
99     rc=$?
100     exit $rc
101 fi
102 # ***** end W32 build script *******
103
104 # ***** AMD64 cross build script *******
105 # Used to cross-compile for AMD64 (for testing)
106 if test "$1" = "--build-amd64"; then
107     tmp=`dirname $0`
108     tsdir=`cd "$tmp"; pwd`
109     shift
110     if [ ! -f $tsdir/scripts/config.guess ]; then
111         echo "$tsdir/scripts/config.guess not found" >&2
112         exit 1
113     fi
114     build=`$tsdir/scripts/config.guess`
115
116     [ -z "$amd64root" ] && amd64root="$HOME/amd64root"
117     echo "Using $amd64root as standard install directory" >&2
118
119     # Locate the cross compiler
120     crossbindir=
121     for host in x86_64-linux-gnu amd64-linux-gnu; do
122         if ${host}-gcc --version >/dev/null 2>&1 ; then
123             crossbindir=/usr/${host}/bin
124             conf_CC="CC=${host}-gcc"
125             break;
126         fi
127     done
128     if [ -z "$crossbindir" ]; then
129         echo "Cross compiler kit not installed" >&2
130         echo "Stop." >&2
131         exit 1
132     fi
133
134     if [ -f "$tsdir/config.log" ]; then
135         if ! head $tsdir/config.log | grep "$host" >/dev/null; then
136             echo "Please run a 'make distclean' first" >&2
137             exit 1
138         fi
139     fi
140
141     $tsdir/configure --enable-maintainer-mode --prefix=${amd64root}  \
142              --host=${host} --build=${build} \
143              --with-gpg-error-prefix=${amd64root} \
144              --with-ksba-prefix=${amd64root} \
145              --with-libgcrypt-prefix=${amd64root} \
146              --with-libassuan-prefix=${amd64root} \
147              --with-zlib=/usr/x86_64-linux-gnu/usr \
148              --with-pth-prefix=/usr/x86_64-linux-gnu/usr
149     rc=$?
150     exit $rc
151 fi
152 # ***** end AMD64 cross build script *******
153
154
155 # Grep the required versions from configure.ac
156 autoconf_vers=`sed -n '/^AC_PREREQ(/ {
157 s/^.*(\(.*\))/\1/p
158 q
159 }' ${configure_ac}`
160 autoconf_vers_num=`echo "$autoconf_vers" | cvtver`
161
162 automake_vers=`sed -n '/^min_automake_version=/ {
163 s/^.*="\(.*\)"/\1/p
164 q
165 }' ${configure_ac}`
166 automake_vers_num=`echo "$automake_vers" | cvtver`
167
168 gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ {
169 s/^.*\[\(.*\)])/\1/p
170 q
171 }' ${configure_ac}`
172 gettext_vers_num=`echo "$gettext_vers" | cvtver`
173
174
175 if [ -z "$autoconf_vers" -o -z "$automake_vers" -o -z "$gettext_vers" ]
176 then
177   echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2
178   exit 1
179 fi
180
181
182 if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
183     check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
184 fi
185 if check_version $AUTOMAKE $automake_vers_num $automake_vers; then
186   check_version $ACLOCAL $automake_vers_num $autoconf_vers automake
187 fi
188 if check_version $GETTEXT $gettext_vers_num $gettext_vers; then
189   check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext
190 fi
191
192 if test "$DIE" = "yes"; then
193     cat <<EOF
194
195 Note that you may use alternative versions of the tools by setting
196 the corresponding environment variables; see README.CVS for details.
197
198 EOF
199     exit 1
200 fi
201
202
203 # Update the git setup.
204 if [ -d .git ]; then
205   if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then
206     cat <<EOF >&2
207 *** Activating trailing whitespace git pre-commit hook. ***
208     For more information see this thread:
209       http://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084html
210     To deactivate this pre-commit hook again move .git/hooks/pre-commit
211     and .git/hooks/pre-commit.sample out of the way.
212 EOF
213       cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
214       chmod -c +x  .git/hooks/pre-commit
215   fi
216   tmp=$(git config --get filter.cleanpo.clean)
217   if [ "$tmp" != "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" ]
218   then
219     echo "*** Adding GIT filter.cleanpo.clean configuration." >&2
220     git config --add filter.cleanpo.clean \
221         "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'"
222   fi
223   if [ -f scripts/git-hooks/commit-msg -a ! -f .git/hooks/commit-msg ] ; then
224     cat <<EOF >&2
225 *** Activating commit log message check hook. ***
226 EOF
227       cp scripts/git-hooks/commit-msg .git/hooks/commit-msg
228       chmod -c +x  .git/hooks/commit-msg
229   fi
230 fi
231
232
233 echo "Running aclocal -I m4 -I gl/m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..."
234 $ACLOCAL -I m4 -I gl/m4 $ACLOCAL_FLAGS
235 echo "Running autoheader..."
236 $AUTOHEADER
237 echo "Running automake --gnu ..."
238 $AUTOMAKE --gnu;
239 echo "Running autoconf${FORCE} ..."
240 $AUTOCONF${FORCE}
241
242 echo "You may now run:
243   ./configure --sysconfdir=/etc --enable-maintainer-mode --enable-symcryptrun --enable-mailto --enable-gpgtar && make
244 "