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