buildconf 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. #!/bin/sh
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at http://curl.haxx.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. # $Id$
  23. ###########################################################################
  24. die(){
  25. echo "$@"
  26. exit
  27. }
  28. # this works as 'which' but we use a different name to make it more obvious we
  29. # aren't using 'which'! ;-)
  30. findtool(){
  31. file="$1"
  32. IFS=":"
  33. for path in $PATH
  34. do
  35. # echo "checks for $file in $path" >&2
  36. if test -f "$path/$file"; then
  37. echo "$path/$file"
  38. return
  39. fi
  40. done
  41. }
  42. #--------------------------------------------------------------------------
  43. # autoconf 2.57 or newer
  44. #
  45. need_autoconf="2.57"
  46. ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  47. if test -z "$ac_version"; then
  48. echo "buildconf: autoconf not found."
  49. echo " You need autoconf version $need_autoconf or newer installed."
  50. exit 1
  51. fi
  52. IFS=.; set $ac_version; IFS=' '
  53. if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
  54. echo "buildconf: autoconf version $ac_version found."
  55. echo " You need autoconf version $need_autoconf or newer installed."
  56. echo " If you have a sufficient autoconf installed, but it"
  57. echo " is not named 'autoconf', then try setting the"
  58. echo " AUTOCONF environment variable."
  59. exit 1
  60. fi
  61. echo "buildconf: autoconf version $ac_version (ok)"
  62. #--------------------------------------------------------------------------
  63. # autoheader 2.50 or newer
  64. #
  65. ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  66. if test -z "$ah_version"; then
  67. echo "buildconf: autoheader not found."
  68. echo " You need autoheader version 2.50 or newer installed."
  69. exit 1
  70. fi
  71. IFS=.; set $ah_version; IFS=' '
  72. if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
  73. echo "buildconf: autoheader version $ah_version found."
  74. echo " You need autoheader version 2.50 or newer installed."
  75. echo " If you have a sufficient autoheader installed, but it"
  76. echo " is not named 'autoheader', then try setting the"
  77. echo " AUTOHEADER environment variable."
  78. exit 1
  79. fi
  80. echo "buildconf: autoheader version $ah_version (ok)"
  81. #--------------------------------------------------------------------------
  82. # automake 1.7 or newer
  83. #
  84. need_automake="1.7"
  85. am_version=`${AUTOMAKE:-automake} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
  86. if test -z "$am_version"; then
  87. echo "buildconf: automake not found."
  88. echo " You need automake version $need_automake or newer installed."
  89. exit 1
  90. fi
  91. IFS=.; set $am_version; IFS=' '
  92. if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
  93. echo "buildconf: automake version $am_version found."
  94. echo " You need automake version $need_automake or newer installed."
  95. echo " If you have a sufficient automake installed, but it"
  96. echo " is not named 'automake', then try setting the"
  97. echo " AUTOMAKE environment variable."
  98. exit 1
  99. fi
  100. echo "buildconf: automake version $am_version (ok)"
  101. ac=`findtool ${ACLOCAL:-aclocal}`
  102. if test -z "$ac"; then
  103. echo "buildconf: aclocal not found. Weird automake installation!"
  104. exit 1
  105. else
  106. echo "buildconf: aclocal found"
  107. fi
  108. #--------------------------------------------------------------------------
  109. # libtool check
  110. #
  111. LIBTOOL_WANTED_MAJOR=1
  112. LIBTOOL_WANTED_MINOR=4
  113. LIBTOOL_WANTED_PATCH=2
  114. LIBTOOL_WANTED_VERSION=1.4.2
  115. # this approach that tries 'glibtool' first is some kind of work-around for
  116. # some BSD-systems I believe that use to provide the GNU libtool named
  117. # glibtool, with 'libtool' being something completely different.
  118. libtool=`findtool glibtool 2>/dev/null`
  119. if test ! -x "$libtool"; then
  120. libtool=`findtool ${LIBTOOL:-libtool}`
  121. fi
  122. if test -z "$LIBTOOLIZE"; then
  123. # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
  124. # $libtool is already the full path
  125. libtoolize="${libtool}ize"
  126. else
  127. libtoolize=`findtool $LIBTOOLIZE`
  128. fi
  129. lt_pversion=`$libtool --version 2>/dev/null|head -n 2|sed -e 's/^[^0-9]*//g' -e 's/[- ].*//'`
  130. if test -z "$lt_pversion"; then
  131. echo "buildconf: libtool not found."
  132. echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
  133. exit 1
  134. fi
  135. lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$//'`
  136. IFS=.; set $lt_version; IFS=' '
  137. lt_status="good"
  138. major=$1
  139. minor=$2
  140. patch=$3
  141. if test "$major" = "$LIBTOOL_WANTED_MAJOR"; then
  142. if test "$minor" -lt "$LIBTOOL_WANTED_MINOR"; then
  143. lt_status="bad"
  144. elif test -n "$LIBTOOL_WANTED_PATCH"; then
  145. if test "$minor" -gt "$LIBTOOL_WANTED_MINOR"; then
  146. lt_status="good"
  147. elif test -n "$patch"; then
  148. if test "$patch" -lt "$LIBTOOL_WANTED_PATCH"; then
  149. lt_status="bad"
  150. fi
  151. else
  152. lt_status="bad"
  153. fi
  154. fi
  155. fi
  156. if test $lt_status != "good"; then
  157. echo "buildconf: libtool version $lt_pversion found."
  158. echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
  159. exit 1
  160. fi
  161. echo "buildconf: libtool version $lt_version (ok)"
  162. if test -f "$libtoolize"; then
  163. echo "buildconf: libtoolize found"
  164. else
  165. echo "buildconf: libtoolize not found. Weird libtool installation!"
  166. exit 1
  167. fi
  168. #--------------------------------------------------------------------------
  169. # m4 check
  170. #
  171. m4=`${M4:-m4} --version 2>/dev/null|head -n 1`;
  172. m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
  173. if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
  174. echo "buildconf: GNU m4 version $m4_version (ok)"
  175. else
  176. echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
  177. exit 1
  178. fi
  179. #--------------------------------------------------------------------------
  180. # perl check
  181. #
  182. PERL=`findtool ${PERL:-perl}`
  183. # ------------------------------------------------------------
  184. # run the correct scripts now
  185. echo "buildconf: running libtoolize"
  186. $libtoolize --copy --automake --force || die "The libtoolize command failed"
  187. echo "buildconf: running aclocal"
  188. ${ACLOCAL:-aclocal} $ACLOCAL_FLAGS || die "The aclocal command line failed"
  189. if test -n "$PERL"; then
  190. echo "buildconf: running aclocal hack to convert all mv to mv -f"
  191. $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
  192. else
  193. echo "buildconf: perl not found"
  194. exit 1
  195. fi
  196. echo "buildconf: running autoheader"
  197. ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
  198. echo "buildconf: cp lib/config.h.in src/config.h.in"
  199. cp lib/config.h.in src/config.h.in
  200. echo "buildconf: running autoconf"
  201. ${AUTOCONF:-autoconf} || die "The autoconf command failed"
  202. if test -d ares; then
  203. cd ares
  204. echo "buildconf: running in ares"
  205. ./buildconf
  206. cd ..
  207. fi
  208. echo "buildconf: running automake"
  209. ${AUTOMAKE:-automake} -a -c || die "The automake command failed"
  210. echo "buildconf: OK"
  211. exit 0