autogen.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. configure_ac="configure.ac"
  14. cvtver () {
  15. awk 'NR==1 {split($NF,A,".");X=1000000*A[1]+1000*A[2]+A[3];print X;exit 0}'
  16. }
  17. check_version () {
  18. if [ `("$1" --version || echo "0") | cvtver` -ge "$2" ]; then
  19. return 0
  20. fi
  21. echo "**Error**: "\`$1\'" not installed or too old." >&2
  22. echo ' Version '$3' or newer is required.' >&2
  23. [ -n "$4" ] && echo ' Note that this is part of '\`$4\''.' >&2
  24. DIE="yes"
  25. return 1
  26. }
  27. DIE=no
  28. # Used to cross-compile for Windows.
  29. if test "$1" = "--build-w32"; then
  30. tmp=`dirname $0`
  31. tsdir=`cd "$tmp"; pwd`
  32. shift
  33. if [ ! -f $tsdir/config.guess ]; then
  34. echo "$tsdir/config.guess not found" >&2
  35. exit 1
  36. fi
  37. build=`$tsdir/config.guess`
  38. [ -z "$w32root" ] && w32root="$HOME/w32root"
  39. echo "Using $w32root as standard install directory" >&2
  40. # See whether we have the Debian cross compiler package or the
  41. # old mingw32/cpd system
  42. if i586-mingw32msvc-gcc --version >/dev/null 2>&1 ; then
  43. host=i586-mingw32msvc
  44. crossbindir=/usr/$host/bin
  45. else
  46. host=i386--mingw32
  47. if ! mingw32 --version >/dev/null; then
  48. echo "We need at least version 0.3 of MingW32/CPD" >&2
  49. exit 1
  50. fi
  51. crossbindir=`mingw32 --install-dir`/bin
  52. # Old autoconf version required us to setup the environment
  53. # with the proper tool names.
  54. CC=`mingw32 --get-path gcc`
  55. CPP=`mingw32 --get-path cpp`
  56. AR=`mingw32 --get-path ar`
  57. RANLIB=`mingw32 --get-path ranlib`
  58. export CC CPP AR RANLIB
  59. fi
  60. if [ -f "$tsdir/config.log" ]; then
  61. if ! head $tsdir/config.log | grep "$host" >/dev/null; then
  62. echo "Pease run a 'make distclean' first" >&2
  63. exit 1
  64. fi
  65. fi
  66. ./configure --enable-maintainer-mode --prefix=${w32root} \
  67. --host=i586-mingw32msvc --build=${build} \
  68. --with-gpg-error-prefix=${w32root} --without-gpgsm \
  69. --enable-shared --enable-static --enable-w32-glib \
  70. PKG_CONFIG_LIBDIR="$w32root/lib/pkgconfig"
  71. exit $?
  72. fi
  73. # Grep the required versions from configure.ac
  74. autoconf_vers=`sed -n '/^AC_PREREQ(/ {
  75. s/^.*(\(.*\))/\1/p
  76. q
  77. }' ${configure_ac}`
  78. autoconf_vers_num=`echo "$autoconf_vers" | cvtver`
  79. automake_vers=`sed -n '/^min_automake_version=/ {
  80. s/^.*="\(.*\)"/\1/p
  81. q
  82. }' ${configure_ac}`
  83. automake_vers_num=`echo "$automake_vers" | cvtver`
  84. #gettext_vers=`sed -n '/^AM_GNU_GETTEXT_VERSION(/ {
  85. #s/^.*(\(.*\))/\1/p
  86. #q
  87. #}' ${configure_ac}`
  88. #gettext_vers_num=`echo "$gettext_vers" | cvtver`
  89. if [ -z "$autoconf_vers" -o -z "$automake_vers" ]
  90. then
  91. echo "**Error**: version information not found in "\`${configure_ac}\'"." >&2
  92. exit 1
  93. fi
  94. # Allow to override the default tool names
  95. AUTOCONF=${AUTOCONF_PREFIX}${AUTOCONF:-autoconf}${AUTOCONF_SUFFIX}
  96. AUTOHEADER=${AUTOCONF_PREFIX}${AUTOHEADER:-autoheader}${AUTOCONF_SUFFIX}
  97. AUTOMAKE=${AUTOMAKE_PREFIX}${AUTOMAKE:-automake}${AUTOMAKE_SUFFIX}
  98. ACLOCAL=${AUTOMAKE_PREFIX}${ACLOCAL:-aclocal}${AUTOMAKE_SUFFIX}
  99. #GETTEXT=${GETTEXT_PREFIX}${GETTEXT:-gettext}${GETTEXT_SUFFIX}
  100. #MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
  101. DIE=no
  102. if check_version $AUTOCONF $autoconf_vers_num $autoconf_vers ; then
  103. check_version $AUTOHEADER $autoconf_vers_num $autoconf_vers autoconf
  104. fi
  105. if check_version $AUTOMAKE $automake_vers_num $automake_vers; then
  106. check_version $ACLOCAL $automake_vers_num $autoconf_vers automake
  107. fi
  108. #if check_version $GETTEXT $gettext_vers_num $gettext_vers; then
  109. # check_version $MSGMERGE $gettext_vers_num $gettext_vers gettext
  110. #fi
  111. if test "$DIE" = "yes"; then
  112. cat <<EOF
  113. Note that you may use alternative versions of the tools by setting
  114. the corresponding environment variables; see README.CVS for details.
  115. EOF
  116. exit 1
  117. fi
  118. echo "Running aclocal -I m4 ${ACLOCAL_FLAGS:+$ACLOCAL_FLAGS }..."
  119. $ACLOCAL -I m4 $ACLOCAL_FLAGS
  120. echo "Running autoheader..."
  121. $AUTOHEADER
  122. echo "Running automake --gnu ..."
  123. $AUTOMAKE --gnu;
  124. echo "Running autoconf..."
  125. $AUTOCONF
  126. echo "You may now run \"./configure --enable-maintainer-mode && make\"."