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 14configure_ac="configure.ac" 15 16cvtver () { 17 awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}' 18} 19 20check_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 32DIE=no 33FORCE= 34if test x"$1" = x"--force"; then 35 FORCE=" --force" 36 shift 37fi 38 39# Begin list of optional variables sourced from ~/.gnupg-autogen.rc 40w32_toolprefixes= 41w32_extraoptions= 42w32ce_toolprefixes= 43w32ce_extraoptions= 44amd64_toolprefixes= 45# End list of optional variables sourced from ~/.gnupg-autogen.rc 46# What follows are variables which are sourced but default to 47# environment variables or lacking them hardcoded values. 48#w32root= 49#w32ce_root= 50#amd64root= 51 52if [ -f "$HOME/.gnupg-autogen.rc" ]; then 53 echo "sourcing extra definitions from $HOME/.gnupg-autogen.rc" 54 . "$HOME/.gnupg-autogen.rc" 55fi 56 57# Convenience option to use certain configure options for some hosts. 58myhost="" 59myhostsub="" 60case "$1" in 61 --build-w32) 62 myhost="w32" 63 ;; 64 --build-w32ce) 65 myhost="w32" 66 myhostsub="ce" 67 ;; 68 --build-amd64) 69 myhost="amd64" 70 ;; 71 --build*) 72 echo "**Error**: invalid build option $1" >&2 73 exit 1 74 ;; 75 *) 76 ;; 77esac 78 79 80# ***** W32 build script ******* 81# Used to cross-compile for Windows. 82if [ "$myhost" = "w32" ]; then 83 tmp=`dirname $0` 84 tsdir=`cd "$tmp"; pwd` 85 shift 86 if [ ! -f $tsdir/config.guess ]; then 87 echo "$tsdir/config.guess not found" >&2 88 exit 1 89 fi 90 build=`$tsdir/config.guess` 91 92 case $myhostsub in 93 ce) 94 w32root="$w32ce_root" 95 [ -z "$w32root" ] && w32root="$HOME/w32ce_root" 96 toolprefixes="arm-mingw32ce" 97 ;; 98 *) 99 [ -z "$w32root" ] && w32root="$HOME/w32root" 100 toolprefixes="i586-mingw32msvc i386-mingw32msvc" 101 ;; 102 esac 103 echo "Using $w32root as standard install directory" >&2 104 105 # Locate the cross compiler 106 crossbindir= 107 for host in $toolprefixes; do 108 if ${host}-gcc --version >/dev/null 2>&1 ; then 109 crossbindir=/usr/${host}/bin 110 conf_CC="CC=${host}-gcc" 111 break; 112 fi 113 done 114 if [ -z "$crossbindir" ]; then 115 echo "Cross compiler kit not installed" >&2 116 if [ -z "$sub" ]; then 117 echo "Under Debian GNU/Linux, you may install it using" >&2 118 echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 119 fi 120 echo "Stop." >&2 121 exit 1 122 fi 123 124 if [ -f "$tsdir/config.log" ]; then 125 if ! head $tsdir/config.log | grep "$host" >/dev/null; then 126 echo "Pease run a 'make distclean' first" >&2 127 exit 1 128 fi 129 fi 130 131 $tsdir/configure --enable-maintainer-mode --prefix=${w32root} \ 132 --host=${host} --build=${build} \ 133 --with-gpg-error-prefix=${w32root} 134 exit $? 135fi 136# ***** end W32 build script ******* 137 138 139# ***** AMD64 cross build script ******* 140# Used to cross-compile for AMD64 (for testing) 141if [ "$myhost" = "amd64" ]; then 142 tmp=`dirname $0` 143 tsdir=`cd "$tmp"; pwd` 144 shift 145 if [ ! -f $tsdir/config.guess ]; then 146 echo "$tsdir/config.guess not found" >&2 147 exit 1 148 fi 149 build=`$tsdir/config.guess` 150 151 [ -z "$amd64root" ] && amd64root="$HOME/amd64root" 152 echo "Using $amd64root as standard install directory" >&2 153 154 # Locate the cross compiler 155 crossbindir= 156 for host in x86_64-linux-gnu amd64-linux-gnu; do 157 if ${host}-gcc --version >/dev/null 2>&1 ; then 158 crossbindir=/usr/${host}/bin 159 conf_CC="CC=${host}-gcc" 160 break; 161 fi 162 done 163 if [ -z "$crossbindir" ]; then 164 echo "Cross compiler kit not installed" >&2 165 echo "Stop." >&2 166 exit 1 167 fi 168 169 if [ -f "$tsdir/config.log" ]; then 170 if ! head $tsdir/config.log | grep "$host" >/dev/null; then 171 echo "Please run a 'make distclean' first" >&2 172 exit 1 173 fi 174 fi 175 176 $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ 177 --host=${host} --build=${build} \ 178 --with-gpg-error-prefix=${amd64root} 179 180 rc=$? 181 exit $rc 182fi 183# ***** end AMD64 cross build script ******* 184 185# Grep the required versions from configure.ac 186autoconf_vers=`sed -n '/^AC_PREREQ(/ { 187s/^.*(\(.*\))/\1/p 188q 189}' ${configure_ac}` 190autoconf_vers_num=`echo "$autoconf_vers" | cvtver` 191 192automake_vers=`sed -n '/^min_automake_version=/ { 193s/^.*="\(.*\)"/\1/p 194q 195}' ${configure_ac}` 196automake_vers_num=`echo "$automake_vers" | cvtver` 197 198#gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { 199#s/^.*(\(.*\))/\1/p 200#q 201#}' ${configure_ac}` 202#gettext_vers_num=`echo "$gettext_vers" | cvtver` 203 204 205if [ -z "$autoconf_vers" -o -z "$automake_vers" ] 206then 207 echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 208 exit 1 209fi 210 211# Allow to override the default tool names 212AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} 213AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} 214 215AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} 216ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} 217 218#GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} 219#MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} 220 221 222if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then 223 check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf 224fi 225if check_version $AUTOMAKE $automake_vers_num $automake_vers; then 226 check_version $ACLOCAL $automake_vers_num $autoconf_vers automake 227fi 228#if check_version $GETTEXT $gettext_vers_num $gettext_vers; then 229# check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext 230#fi 231 232if test "$DIE" = "yes"; then 233 cat <<EOF 234 235Note that you may use alternative versions of the tools by setting 236the corresponding environment variables; see README.SVN for details. 237 238EOF 239 exit 1 240fi 241 242# Check the git setup. 243if [ -d .git ]; then 244 if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then 245 cat <<EOF >&2 246*** Activating trailing whitespace git pre-commit hook. *** 247 For more information see this thread: 248 http://mail.gnome.org/archives/desktop-devel-list/2009-May/msg00084html 249 To deactivate this pre-commit hook again move .git/hooks/pre-commit 250 and .git/hooks/pre-commit.sample out of the way. 251EOF 252 cp -av .git/hooks/pre-commit.sample .git/hooks/pre-commit 253 chmod -c +x .git/hooks/pre-commit 254 fi 255fi 256 257 258echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..." 259$ACLOCAL -I m4 $ACLOCAL_FLAGS 260echo "Running autoheader..." 261$AUTOHEADER 262echo "Running automake --gnu ..." 263$AUTOMAKE --gnu; 264echo "Running autoconf${FORCE} ..." 265$AUTOCONF${FORCE} 266 267echo "You may now run: 268 ./configure --enable-maintainer-mode && make 269" 270