autogen.sh 5.7 KB

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