buildconf 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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. old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_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. old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_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. old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_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_pver=`$libtool --version 2>/dev/null|head -n 1`
  178. lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
  179. lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
  180. if test -z "$lt_version"; then
  181. echo "buildconf: libtool not found."
  182. echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
  183. exit 1
  184. fi
  185. old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
  186. lt_major=$1
  187. lt_minor=$2
  188. lt_patch=$3
  189. lt_status="good"
  190. if test "$lt_major" = "$LIBTOOL_WANTED_MAJOR"; then
  191. if test "$lt_minor" -lt "$LIBTOOL_WANTED_MINOR"; then
  192. lt_status="bad"
  193. elif test -n "$LIBTOOL_WANTED_PATCH"; then
  194. if test "$lt_minor" -gt "$LIBTOOL_WANTED_MINOR"; then
  195. lt_status="good"
  196. elif test -n "$lt_patch"; then
  197. if test "$lt_patch" -lt "$LIBTOOL_WANTED_PATCH"; then
  198. lt_status="bad"
  199. fi
  200. else
  201. lt_status="bad"
  202. fi
  203. fi
  204. fi
  205. if test $lt_status != "good"; then
  206. echo "buildconf: libtool version $lt_version found."
  207. echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
  208. exit 1
  209. fi
  210. echo "buildconf: libtool version $lt_version (ok)"
  211. if test -f "$libtoolize"; then
  212. echo "buildconf: libtoolize found"
  213. else
  214. echo "buildconf: libtoolize not found. Weird libtool installation!"
  215. exit 1
  216. fi
  217. #--------------------------------------------------------------------------
  218. # m4 check
  219. #
  220. m4=`${M4:-m4} --version 2>/dev/null|head -n 1`;
  221. m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
  222. if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
  223. echo "buildconf: GNU m4 version $m4_version (ok)"
  224. else
  225. echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
  226. exit 1
  227. fi
  228. #--------------------------------------------------------------------------
  229. # perl check
  230. #
  231. PERL=`findtool ${PERL:-perl}`
  232. #--------------------------------------------------------------------------
  233. # Remove files generated on previous buildconf/configure run.
  234. #
  235. for fname in .deps \
  236. .libs \
  237. *.la \
  238. *.lo \
  239. *.a \
  240. *.o \
  241. Makefile \
  242. Makefile.in \
  243. aclocal.m4 \
  244. aclocal.m4.bak \
  245. ares_build.h \
  246. ares_config.h \
  247. ares_config.h.in \
  248. autom4te.cache \
  249. compile \
  250. config.guess \
  251. curl_config.h \
  252. curl_config.h.in \
  253. config.log \
  254. config.lt \
  255. config.status \
  256. config.sub \
  257. configure \
  258. curl-config \
  259. curlbuild.h \
  260. depcomp \
  261. libcares.pc \
  262. libcurl.pc \
  263. libtool \
  264. libtool.m4 \
  265. ltmain.sh \
  266. ltoptions.m4 \
  267. ltsugar.m4 \
  268. ltversion.m4 \
  269. lt~obsolete.m4 \
  270. stamp-h1 \
  271. stamp-h2 \
  272. stamp-h3 ; do
  273. removethis "$fname"
  274. done
  275. #--------------------------------------------------------------------------
  276. # run the correct scripts now
  277. #
  278. echo "buildconf: running libtoolize"
  279. $libtoolize --copy --automake --force || die "The libtoolize command failed"
  280. if test ! -f m4/curl-functions.m4; then
  281. echo "buildconf: cURL m4 macros not found"
  282. exit 1
  283. fi
  284. echo "buildconf: running aclocal"
  285. ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "The aclocal command line failed"
  286. if test -n "$PERL"; then
  287. echo "buildconf: running aclocal hack to convert all mv to mv -f"
  288. $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
  289. else
  290. echo "buildconf: perl not found"
  291. exit 1
  292. fi
  293. echo "buildconf: running autoheader"
  294. ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
  295. echo "buildconf: cp lib/curl_config.h.in src/curl_config.h.in"
  296. cp lib/curl_config.h.in src/curl_config.h.in
  297. echo "buildconf: running autoconf"
  298. ${AUTOCONF:-autoconf} || die "The autoconf command failed"
  299. if test -d ares; then
  300. cd ares
  301. echo "buildconf: running in ares"
  302. ./buildconf
  303. cd ..
  304. fi
  305. echo "buildconf: running automake"
  306. ${AUTOMAKE:-automake} -a -c || die "The automake command failed"
  307. #--------------------------------------------------------------------------
  308. # Depending on the libtool and automake versions being used, config.guess
  309. # might not be installed in the subdirectory until automake has finished.
  310. # So we can not attempt to use it until this very last buildconf stage.
  311. #
  312. if test ! -f ./config.guess; then
  313. echo "buildconf: config.guess not found"
  314. else
  315. buildhost=`./config.guess 2>/dev/null|head -n 1`
  316. case $buildhost in
  317. *-*-hpux*)
  318. need_lt_major=1
  319. need_lt_minor=5
  320. need_lt_patch=24
  321. need_lt_check="yes"
  322. ;;
  323. esac
  324. if test ! -z "$need_lt_check"; then
  325. if test -z "$lt_major"; then
  326. lt_status="bad"
  327. elif test "$lt_major" -gt "$need_lt_major"; then
  328. lt_status="good"
  329. elif test "$lt_major" -lt "$need_lt_major"; then
  330. lt_status="bad"
  331. elif test -z "$lt_minor"; then
  332. lt_status="bad"
  333. elif test "$lt_minor" -gt "$need_lt_minor"; then
  334. lt_status="good"
  335. elif test "$lt_minor" -lt "$need_lt_minor"; then
  336. lt_status="bad"
  337. elif test -z "$lt_patch"; then
  338. lt_status="bad"
  339. elif test "$lt_patch" -gt "$need_lt_patch"; then
  340. lt_status="good"
  341. elif test "$lt_patch" -lt "$need_lt_patch"; then
  342. lt_status="bad"
  343. else
  344. lt_status="good"
  345. fi
  346. if test "$lt_status" != "good"; then
  347. need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
  348. echo "buildconf: libtool version $lt_version found."
  349. echo " $buildhost requires libtool $need_lt_version or newer installed."
  350. rm -f configure
  351. exit 1
  352. fi
  353. fi
  354. fi
  355. #--------------------------------------------------------------------------
  356. # Finished succesfully.
  357. #
  358. echo "buildconf: OK"
  359. exit 0