buildconf 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. #!/bin/sh
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2009, 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. #--------------------------------------------------------------------------
  29. # findtool works as 'which' but we use a different name to make it more
  30. # obvious we aren't using 'which'! ;-)
  31. #
  32. findtool(){
  33. file="$1"
  34. old_IFS=$IFS; IFS=':'
  35. for path in $PATH
  36. do
  37. IFS=$old_IFS
  38. # echo "checks for $file in $path" >&2
  39. if test -f "$path/$file"; then
  40. echo "$path/$file"
  41. return
  42. fi
  43. done
  44. IFS=$old_IFS
  45. }
  46. #--------------------------------------------------------------------------
  47. # removethis() removes all files and subdirectories with the given name,
  48. # inside and below the current subdirectory at invocation time.
  49. #
  50. removethis(){
  51. if test "$#" = "1"; then
  52. find . -depth -name $1 -print > buildconf.tmp.$$
  53. while read fdname
  54. do
  55. if test -f "$fdname"; then
  56. rm -f "$fdname"
  57. elif test -d "$fdname"; then
  58. rm -f -r "$fdname"
  59. fi
  60. done < buildconf.tmp.$$
  61. rm -f buildconf.tmp.$$
  62. fi
  63. }
  64. #--------------------------------------------------------------------------
  65. # Ensure that buildconf runs from the subdirectory where configure.ac lives
  66. #
  67. if test ! -f configure.ac ||
  68. test ! -f src/main.c ||
  69. test ! -f lib/urldata.h ||
  70. test ! -f include/curl/curl.h; then
  71. echo "Can not run buildconf from outside of curl's source subdirectory!"
  72. echo "Change to the subdirectory where buildconf is found, and try again."
  73. exit 1
  74. fi
  75. #--------------------------------------------------------------------------
  76. # autoconf 2.57 or newer
  77. #
  78. need_autoconf="2.57"
  79. ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  80. if test -z "$ac_version"; then
  81. echo "buildconf: autoconf not found."
  82. echo " You need autoconf version $need_autoconf or newer installed."
  83. exit 1
  84. fi
  85. IFS=.; set $ac_version; IFS=' '
  86. if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
  87. echo "buildconf: autoconf version $ac_version found."
  88. echo " You need autoconf version $need_autoconf or newer installed."
  89. echo " If you have a sufficient autoconf installed, but it"
  90. echo " is not named 'autoconf', then try setting the"
  91. echo " AUTOCONF environment variable."
  92. exit 1
  93. fi
  94. echo "buildconf: autoconf version $ac_version (ok)"
  95. am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  96. if test -z "$am4te_version"; then
  97. echo "buildconf: autom4te not found. Weird autoconf installation!"
  98. exit 1
  99. fi
  100. if test "$am4te_version" = "$ac_version"; then
  101. echo "buildconf: autom4te version $am4te_version (ok)"
  102. else
  103. echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
  104. exit 1
  105. fi
  106. #--------------------------------------------------------------------------
  107. # autoheader 2.50 or newer
  108. #
  109. ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  110. if test -z "$ah_version"; then
  111. echo "buildconf: autoheader not found."
  112. echo " You need autoheader version 2.50 or newer installed."
  113. exit 1
  114. fi
  115. IFS=.; set $ah_version; IFS=' '
  116. if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
  117. echo "buildconf: autoheader version $ah_version found."
  118. echo " You need autoheader version 2.50 or newer installed."
  119. echo " If you have a sufficient autoheader installed, but it"
  120. echo " is not named 'autoheader', then try setting the"
  121. echo " AUTOHEADER environment variable."
  122. exit 1
  123. fi
  124. echo "buildconf: autoheader version $ah_version (ok)"
  125. #--------------------------------------------------------------------------
  126. # automake 1.7 or newer
  127. #
  128. need_automake="1.7"
  129. 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/'`
  130. if test -z "$am_version"; then
  131. echo "buildconf: automake not found."
  132. echo " You need automake version $need_automake or newer installed."
  133. exit 1
  134. fi
  135. IFS=.; set $am_version; IFS=' '
  136. if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
  137. echo "buildconf: automake version $am_version found."
  138. echo " You need automake version $need_automake or newer installed."
  139. echo " If you have a sufficient automake installed, but it"
  140. echo " is not named 'automake', then try setting the"
  141. echo " AUTOMAKE environment variable."
  142. exit 1
  143. fi
  144. echo "buildconf: automake version $am_version (ok)"
  145. acloc_version=`${ACLOCAL:-aclocal} --version 2>/dev/null|head -n 1| sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//' -e 's/\(.*\)\(-p.*\)/\1/'`
  146. if test -z "$acloc_version"; then
  147. echo "buildconf: aclocal not found. Weird automake installation!"
  148. exit 1
  149. fi
  150. if test "$acloc_version" = "$am_version"; then
  151. echo "buildconf: aclocal version $acloc_version (ok)"
  152. else
  153. echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
  154. exit 1
  155. fi
  156. #--------------------------------------------------------------------------
  157. # libtool check
  158. #
  159. LIBTOOL_WANTED_MAJOR=1
  160. LIBTOOL_WANTED_MINOR=4
  161. LIBTOOL_WANTED_PATCH=2
  162. LIBTOOL_WANTED_VERSION=1.4.2
  163. # this approach that tries 'glibtool' first is some kind of work-around for
  164. # some BSD-systems I believe that use to provide the GNU libtool named
  165. # glibtool, with 'libtool' being something completely different.
  166. libtool=`findtool glibtool 2>/dev/null`
  167. if test ! -x "$libtool"; then
  168. libtool=`findtool ${LIBTOOL:-libtool}`
  169. fi
  170. if test -z "$LIBTOOLIZE"; then
  171. # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
  172. # $libtool is already the full path
  173. libtoolize="${libtool}ize"
  174. else
  175. libtoolize=`findtool $LIBTOOLIZE`
  176. fi
  177. lt_pversion=`$libtool --version 2>/dev/null|head -n 1|sed -e 's/^[^0-9]*//g' -e 's/[- ].*//'`
  178. if test -z "$lt_pversion"; then
  179. echo "buildconf: libtool not found."
  180. echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
  181. exit 1
  182. fi
  183. lt_version=`echo $lt_pversion|sed -e 's/\([a-z]*\)$//'`
  184. IFS=.; set $lt_version; IFS=' '
  185. lt_status="good"
  186. major=$1
  187. minor=$2
  188. patch=$3
  189. if test "$major" = "$LIBTOOL_WANTED_MAJOR"; then
  190. if test "$minor" -lt "$LIBTOOL_WANTED_MINOR"; then
  191. lt_status="bad"
  192. elif test -n "$LIBTOOL_WANTED_PATCH"; then
  193. if test "$minor" -gt "$LIBTOOL_WANTED_MINOR"; then
  194. lt_status="good"
  195. elif test -n "$patch"; then
  196. if test "$patch" -lt "$LIBTOOL_WANTED_PATCH"; then
  197. lt_status="bad"
  198. fi
  199. else
  200. lt_status="bad"
  201. fi
  202. fi
  203. fi
  204. if test $lt_status != "good"; then
  205. echo "buildconf: libtool version $lt_pversion found."
  206. echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
  207. exit 1
  208. fi
  209. echo "buildconf: libtool version $lt_version (ok)"
  210. if test -f "$libtoolize"; then
  211. echo "buildconf: libtoolize found"
  212. else
  213. echo "buildconf: libtoolize not found. Weird libtool installation!"
  214. exit 1
  215. fi
  216. #--------------------------------------------------------------------------
  217. # m4 check
  218. #
  219. m4=`${M4:-m4} --version 2>/dev/null|head -n 1`;
  220. m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
  221. if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
  222. echo "buildconf: GNU m4 version $m4_version (ok)"
  223. else
  224. echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
  225. exit 1
  226. fi
  227. #--------------------------------------------------------------------------
  228. # perl check
  229. #
  230. PERL=`findtool ${PERL:-perl}`
  231. #--------------------------------------------------------------------------
  232. # Remove files generated on previous buildconf/configure run.
  233. #
  234. for fname in .deps \
  235. Makefile.in \
  236. aclocal.m4 \
  237. aclocal.m4.bak \
  238. autom4te.cache \
  239. compile \
  240. config.guess \
  241. config.h \
  242. config.h.in \
  243. config.log \
  244. config.status \
  245. config.sub \
  246. configure \
  247. curl-config \
  248. curlbuild.h \
  249. depcomp \
  250. libcares.pc \
  251. libcurl.pc \
  252. libtool \
  253. libtool.m4 \
  254. ltmain.sh \
  255. ltoptions.m4 \
  256. ltsugar.m4 \
  257. ltversion.m4 \
  258. lt~obsolete.m4 \
  259. stamp-h1 \
  260. stamp-h2 \
  261. stamp-h3 ; do
  262. removethis "$fname"
  263. done
  264. #--------------------------------------------------------------------------
  265. # run the correct scripts now
  266. #
  267. echo "buildconf: running libtoolize"
  268. $libtoolize --copy --automake --force || die "The libtoolize command failed"
  269. if test ! -f m4/curl-functions.m4; then
  270. echo "buildconf: cURL m4 macros not found"
  271. exit 1
  272. fi
  273. echo "buildconf: running aclocal"
  274. ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "The aclocal command line failed"
  275. if test -n "$PERL"; then
  276. echo "buildconf: running aclocal hack to convert all mv to mv -f"
  277. $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
  278. else
  279. echo "buildconf: perl not found"
  280. exit 1
  281. fi
  282. echo "buildconf: running autoheader"
  283. ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
  284. echo "buildconf: cp lib/config.h.in src/config.h.in"
  285. cp lib/config.h.in src/config.h.in
  286. echo "buildconf: running autoconf"
  287. ${AUTOCONF:-autoconf} || die "The autoconf command failed"
  288. if test -d ares; then
  289. cd ares
  290. echo "buildconf: running in ares"
  291. ./buildconf
  292. cd ..
  293. fi
  294. echo "buildconf: running automake"
  295. ${AUTOMAKE:-automake} -a -c || die "The automake command failed"
  296. echo "buildconf: OK"
  297. exit 0