| 1 | #! /bin/sh |
| 2 | # Run this to generate all the initial makefiles, etc. |
| 3 | # |
| 4 | # Copyright (C) 2003, 2007 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 | DIE=no |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | # ***** AMD64 cross build script ******* |
| 37 | # Used to cross-compile for AMD64 (for testing) |
| 38 | if test "$1" = "--build-amd64"; then |
| 39 | tmp=`dirname $0` |
| 40 | tsdir=`cd "$tmp"; pwd` |
| 41 | shift |
| 42 | if [ ! -f $tsdir/config.guess ]; then |
| 43 | echo "$tsdir/config.guess not found" >&2 |
| 44 | exit 1 |
| 45 | fi |
| 46 | build=`$tsdir/config.guess` |
| 47 | |
| 48 | [ -z "$amd64root" ] && amd64root="$HOME/amd64root" |
| 49 | echo "Using $amd64root as standard install directory" >&2 |
| 50 | |
| 51 | # Locate the cross compiler |
| 52 | crossbindir= |
| 53 | for host in x86_64-linux-gnu amd64-linux-gnu; do |
| 54 | if ${host}-gcc --version >/dev/null 2>&1 ; then |
| 55 | crossbindir=/usr/${host}/bin |
| 56 | conf_CC="CC=${host}-gcc" |
| 57 | break; |
| 58 | fi |
| 59 | done |
| 60 | if [ -z "$crossbindir" ]; then |
| 61 | echo "Cross compiler kit not installed" >&2 |
| 62 | echo "Stop." >&2 |
| 63 | exit 1 |
| 64 | fi |
| 65 | |
| 66 | if [ -f "$tsdir/config.log" ]; then |
| 67 | if ! head $tsdir/config.log | grep "$host" >/dev/null; then |
| 68 | echo "Please run a 'make distclean' first" >&2 |
| 69 | exit 1 |
| 70 | fi |
| 71 | fi |
| 72 | |
| 73 | $tsdir/configure --enable-maintainer-mode --prefix=${amd64root} \ |
| 74 | --host=${host} --build=${build} \ |
| 75 | --with-gpg-error-prefix=${amd64root} |
| 76 | |
| 77 | rc=$? |
| 78 | exit $rc |
| 79 | fi |
| 80 | # ***** end AMD64 cross build script ******* |
| 81 | |
| 82 | |
| 83 | |
| 84 | |
| 85 | # Grep the required versions from configure.ac |
| 86 | autoconf_vers=`sed -n '/^AC_PREREQ(/ { |
| 87 | s/^.*(\(.*\))/\1/p |
| 88 | q |
| 89 | }' ${configure_ac}` |
| 90 | autoconf_vers_num=`echo "$autoconf_vers" | cvtver` |
| 91 | |
| 92 | automake_vers=`sed -n '/^min_automake_version=/ { |
| 93 | s/^.*="\(.*\)"/\1/p |
| 94 | q |
| 95 | }' ${configure_ac}` |
| 96 | automake_vers_num=`echo "$automake_vers" | cvtver` |
| 97 | |
| 98 | #gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ { |
| 99 | #s/^.*(\(.*\))/\1/p |
| 100 | #q |
| 101 | #}' ${configure_ac}` |
| 102 | #gettext_vers_num=`echo "$gettext_vers" | cvtver` |
| 103 | |
| 104 | |
| 105 | if [ -z "$autoconf_vers" -o -z "$automake_vers" ] |
| 106 | then |
| 107 | echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2 |
| 108 | exit 1 |
| 109 | fi |
| 110 | |
| 111 | # Allow to override the default tool names |
| 112 | AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX} |
| 113 | AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX} |
| 114 | |
| 115 | AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX} |
| 116 | ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX} |
| 117 | |
| 118 | #GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX} |
| 119 | #MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX} |
| 120 | |
| 121 | DIE=no |
| 122 | |
| 123 | |
| 124 | if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then |
| 125 | check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf |
| 126 | fi |
| 127 | if check_version $AUTOMAKE $automake_vers_num $automake_vers; then |
| 128 | check_version $ACLOCAL $automake_vers_num $autoconf_vers automake |
| 129 | fi |
| 130 | #if check_version $GETTEXT $gettext_vers_num $gettext_vers; then |
| 131 | # check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext |
| 132 | #fi |
| 133 | |
| 134 | if test "$DIE" = "yes"; then |
| 135 | cat <<EOF |
| 136 | |
| 137 | Note that you may use alternative versions of the tools by setting |
| 138 | the corresponding environment variables; see README.CVS for details. |
| 139 | |
| 140 | EOF |
| 141 | exit 1 |
| 142 | fi |
| 143 | |
| 144 | echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..." |
| 145 | $ACLOCAL -I m4 $ACLOCAL_FLAGS |
| 146 | echo "Running autoheader..." |
| 147 | $AUTOHEADER |
| 148 | echo "Running automake --gnu --add-missing..." |
| 149 | $AUTOMAKE --gnu --add-missing |
| 150 | echo "Running autoconf..." |
| 151 | $AUTOCONF |
| 152 | |
| 153 | echo "You may now run \"./configure --enable-maintainer-mode && make\"." |