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# Allow to override the default tool names 32AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} 33AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} 34 35AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} 36ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} 37 38GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} 39MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} 40 41DIE=no 42FORCE= 43if test x"$1" = x"--force"; then 44 FORCE=" --force" 45 shift 46fi 47 48 49# ***** W32 build script ******* 50# Used to cross-compile for Windows. 51if test "$1" = "--build-w32"; then 52 tmp=`dirname $0` 53 tsdir=`cd "$tmp"; pwd` 54 shift 55 if [ ! -f $tsdir/config.guess ]; then 56 echo "$tsdir/config.guess not found" >&2 57 exit 1 58 fi 59 build=`$tsdir/config.guess` 60 61 [ -z "$w32root" ] && w32root="$HOME/w32root" 62 echo "Using $w32root as standard install directory" >&2 63 64 # Locate the cross compiler 65 crossbindir= 66 for host in i586-mingw32msvc i386-mingw32msvc mingw32; do 67 if ${host}-gcc --version >/dev/null 2>&1 ; then 68 crossbindir=/usr/${host}/bin 69 conf_CC="CC=${host}-gcc" 70 break; 71 fi 72 done 73 if [ -z "$crossbindir" ]; then 74 echo "Cross compiler kit not installed" >&2 75 echo "Under Debian GNU/Linux, you may install it using" >&2 76 echo " apt-get install mingw32 mingw32-runtime mingw32-binutils" >&2 77 echo "Stop." >&2 78 exit 1 79 fi 80 81 if [ -f "$tsdir/config.log" ]; then 82 if ! head $tsdir/config.log | grep "$host" >/dev/null; then 83 echo "Please run a 'make distclean' first" >&2 84 exit 1 85 fi 86 fi 87 88 89 ./configure --enable-maintainer-mode --prefix=${w32root} \ 90 --host=${host} --build=${build} \ 91 --with-gpg-error-prefix=${w32root} \ 92 --with-ksba-prefix=${w32root} \ 93 --with-libgcrypt-prefix=${w32root} \ 94 --with-libassuan-prefix=${w32root} \ 95 --with-pth-prefix=${w32root} 96 rc=$? 97 exit $rc 98fi 99# ***** end W32 build script ******* 100 101 102# ***** AMD64 cross build script ******* 103# Used to cross-compile for AMD64 (for testing) 104if test "$1" = "--build-amd64"; then 105 tmp=`dirname $0` 106 tsdir=`cd "$tmp"; pwd` 107 shift 108 if [ ! -f $tsdir/config.guess ]; then 109 echo "$tsdir/config.guess not found" >&2 110 exit 1 111 fi 112 build=`$tsdir/config.guess` 113 114 [ -z "$amd64root" ] && amd64root="$HOME/amd64root" 115 echo "Using $amd64root as standard install directory" >&2 116 117 # Locate the cross compiler 118 crossbindir= 119 for host in x86_64-linux-gnu amd64-linux-gnu; do 120 if ${host}-gcc --version >/dev/null 2>&1 ; then 121 crossbindir=/usr/${host}/bin 122 conf_CC="CC=${host}-gcc" 123 break; 124 fi 125 done 126 if [ -z "$crossbindir" ]; then 127 echo "Cross compiler kit not installed" >&2 128 echo "Stop." >&2 129 exit 1 130 fi 131 132 if [ -f "$tsdir/config.log" ]; then 133 if ! head $tsdir/config.log | grep "$host" >/dev/null; then 134 echo "Please run a 'make distclean' first" >&2 135 exit 1 136 fi 137 fi 138 139 $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ 140 --host=${host} --build=${build} \ 141 --with-gpg-error-prefix=${amd64root} \ 142 --with-ksba-prefix=${amd64root} \ 143 --with-libgcrypt-prefix=${amd64root} \ 144 --with-libassuan-prefix=${amd64root} \ 145 --with-pth-prefix=/usr/x86_64-linux-gnu/usr 146 147 rc=$? 148 exit $rc 149fi 150# ***** end AMD64 cross build script ******* 151 152 153# Grep the required versions from configure.ac 154autoconf_vers=`sed -n '/^AC_PREREQ(/ { 155s/^.*(\(.*\))/\1/p 156q 157}' ${configure_ac}` 158autoconf_vers_num=`echo "$autoconf_vers" | cvtver` 159 160automake_vers=`sed -n '/^min_automake_version=/ { 161s/^.*="\(.*\)"/\1/p 162q 163}' ${configure_ac}` 164automake_vers_num=`echo "$automake_vers" | cvtver` 165 166gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { 167s/^.*(\(.*\))/\1/p 168q 169}' ${configure_ac}` 170gettext_vers_num=`echo "$gettext_vers" | cvtver` 171 172 173if [ -z "$autoconf_vers" -o -z "$automake_vers" ] 174then 175 echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 176 exit 1 177fi 178 179 180if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then 181 check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf 182fi 183if check_version $AUTOMAKE $automake_vers_num $automake_vers; then 184 check_version $ACLOCAL $automake_vers_num $autoconf_vers automake 185fi 186if check_version $GETTEXT $gettext_vers_num $gettext_vers; then 187 check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext 188fi 189 190if test "$DIE" = "yes"; then 191 cat <<EOF 192 193Note that you may use alternative versions of the tools by setting 194the corresponding environment variables; see README.CVS for details. 195 196EOF 197 exit 1 198fi 199 200echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..." 201$ACLOCAL -I m4 $ACLOCAL_FLAGS 202echo "Running autoheader..." 203$AUTOHEADER 204echo "Running automake --gnu ..." 205$AUTOMAKE --gnu; 206echo "Running autoconf${FORCE} ..." 207$AUTOCONF${FORCE} 208 209echo "You may now run: 210 ./configure --enable-maintainer-mode --sysconfdir=/etc && make" 211echo "(gcc users may want to add the option \"--enable-gcc-warnings\")" 212