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"
17 awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}'
21 if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then
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
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}
40 if test x"$1" = x"--force"; then
45 # Reject unsafe characters in $HOME, $tsdir and cwd. We consider spaces
46 # as unsafe because it is too easy to get scripts wrong in this regard.
50 *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*)
51 echo "unsafe working directory name"; DIE=yes;;
54 *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*)
55 echo "unsafe source directory: \`$tsdir'"; DIE=yes;;
58 *[\;\\\"\#\$\&\'\`$am_lf\ \ ]*)
59 echo "unsafe home directory: \`$HOME'"; DIE=yes;;
61 if test "$DIE" = "yes"; then
65 # Begin list of optional variables sourced from ~/.gnupg-autogen.rc
70 if [ -f "$HOME/.gnupg-autogen.rc" ]; then
71 echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc"
72 . "$HOME/.gnupg-autogen.rc"
76 # Convenience option to use certain configure options for some hosts.
86 echo "**Error**: invalid build option $1" >&2
95 # ***** W32 build script *******
96 # Used to cross-compile for Windows.
97 if [ "$myhost" = "w32" ]; then
99 tsdir=`cd "$tmp"; pwd`
100 if [ ! -f $tsdir/config.guess ]; then
101 echo "$tsdir/config.guess not found" >&2
104 build=`$tsdir/config.guess`
108 [ -z "$w32root" ] && w32root="$HOME/w32root"
109 toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc"
110 toolprefixes="$toolprefixes i386-mingw32msvc mingw32"
111 extraoptions="$w32_extraoptions"
112 extratoolprefixes="$w64_toolprefixes x86_64-w64-mingw32"
115 [ -z "$w32root" ] && w32root="$HOME/w32root"
116 toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc"
117 toolprefixes="$toolprefixes i386-mingw32msvc mingw32"
118 extraoptions="$w32_extraoptions"
121 echo "Using $w32root as standard install directory" >&2
123 # Locate the cross compiler
125 for host in $toolprefixes; do
126 if ${host}-gcc --version >/dev/null 2>&1 ; then
127 crossbindir=/usr/${host}/bin
128 conf_CC="CC=${host}-gcc"
134 for extra_host in $extratoolprefixes; do
135 if ${extra_host}-gcc --version >/dev/null 2>&1 ; then
136 w64_crossbindir=/usr/${extra_host}/bin
137 extraoptions="$extraoptions --with-additional-gpgex-host=${extra_host} "
142 if [ -z "$crossbindir" ]; then
143 echo "Cross compiler kit not installed" >&2
144 echo "Under Debian GNU/Linux, you may install it using" >&2
145 echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2
150 if [ "$myhostsub" = "w64" -a -z "$w64_crossbindir" ]; then
151 echo "Cross compiler for x64 architecture not installed" >&2
152 echo "Under Debian GNU/Linux, you may install it using" >&2
153 echo " apt-get install mingw-w64" >&2
158 if [ -f "$tsdir/config.log" ]; then
159 if ! head $tsdir/config.log | grep "$host" >/dev/null; then
160 echo "Pease run a 'make distclean' first" >&2
165 $tsdir/configure --host=${host} --build=${build} --enable-maintainer-mode \
171 # ***** end W32 build script *******
176 # Grep the required versions from configure.ac
177 autoconf_vers=`sed -n '/^AC_PREREQ(/ {
181 autoconf_vers_num=`echo "$autoconf_vers" | cvtver`
183 automake_vers=`sed -n '/^min_automake_version=/ {
187 automake_vers_num=`echo "$automake_vers" | cvtver`
190 if [ -z "$autoconf_vers" -o -z "$automake_vers" ]
192 echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2
197 if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
198 check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
200 if check_version $AUTOMAKE $automake_vers_num $automake_vers; then
201 check_version $ACLOCAL $automake_vers_num $autoconf_vers automake
204 if test "$DIE" = "yes"; then
207 Note that you may use alternative versions of the tools by setting
208 the corresponding environment variables; see README.GIT for details.
214 # Check the git setup.
216 if [ -f build-aux/git-hooks/pre-commit -a ! -x .git/hooks/pre-commit ];then
218 *** Activating trailing whitespace git pre-commit hook. ***
219 For more information see this thread:
220 http://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084html
221 To deactivate this pre-commit hook again move .git/hooks/pre-commit
222 and .git/hooks/pre-commit.sample out of the way.
224 cp -av build-aux/git-hooks/pre-commit .git/hooks/pre-commit
225 chmod -c +x .git/hooks/pre-commit
227 tmp=$(git config --get filter.cleanpo.clean)
228 if [ "$tmp" != "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'" ]
230 echo "*** Adding GIT filter.cleanpo.clean configuration." >&2
231 git config --add filter.cleanpo.clean \
232 "awk '/^\"POT-Creation-Date:/&&!s{s=1;next};!/^#: /{print}'"
234 if [ -f build-aux/git-hooks/commit-msg -a ! -x .git/hooks/commit-msg ];then
236 *** Activating commit log message check hook. ***
238 cp -av build-aux/git-hooks/commit-msg .git/hooks/commit-msg
239 chmod -c +x .git/hooks/commit-msg
244 echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..."
245 $ACLOCAL -I m4 $ACLOCAL_FLAGS
246 echo "Running autoheader..."
248 echo "Running automake --gnu ..."
249 $AUTOMAKE --gnu -Wno-portability;
250 echo "Running autoconf${FORCE} ..."
253 #echo "You may now run \"./configure --host=i586-mingw32msvc && make\"."
254 echo "You may now run \"./autogen.sh --build-w32 && make\"."