2
0

buildconf 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. #!/bin/sh
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2012, 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. ###########################################################################
  23. #--------------------------------------------------------------------------
  24. # die prints argument string to stdout and exits this shell script.
  25. #
  26. die(){
  27. echo "buildconf: $@"
  28. exit 1
  29. }
  30. #--------------------------------------------------------------------------
  31. # findtool works as 'which' but we use a different name to make it more
  32. # obvious we aren't using 'which'! ;-)
  33. #
  34. findtool(){
  35. file="$1"
  36. if { echo "$file" | grep "/" >/dev/null 2>&1; } then
  37. # when file is given with a path check it first
  38. if test -f "$file"; then
  39. echo "$file"
  40. return
  41. fi
  42. fi
  43. old_IFS=$IFS; IFS=':'
  44. for path in $PATH
  45. do
  46. IFS=$old_IFS
  47. # echo "checks for $file in $path" >&2
  48. if test -f "$path/$file"; then
  49. echo "$path/$file"
  50. return
  51. fi
  52. done
  53. IFS=$old_IFS
  54. }
  55. #--------------------------------------------------------------------------
  56. # removethis() removes all files and subdirectories with the given name,
  57. # inside and below the current subdirectory at invocation time.
  58. #
  59. removethis(){
  60. if test "$#" = "1"; then
  61. find . -depth -name $1 -print > buildconf.tmp.$$
  62. while read fdname
  63. do
  64. if test -f "$fdname"; then
  65. rm -f "$fdname"
  66. elif test -d "$fdname"; then
  67. rm -f -r "$fdname"
  68. fi
  69. done < buildconf.tmp.$$
  70. rm -f buildconf.tmp.$$
  71. fi
  72. }
  73. #--------------------------------------------------------------------------
  74. # Ensure that buildconf runs from the subdirectory where configure.ac lives
  75. #
  76. if test ! -f configure.ac ||
  77. test ! -f src/tool_main.c ||
  78. test ! -f lib/urldata.h ||
  79. test ! -f include/curl/curl.h ||
  80. test ! -f m4/curl-functions.m4; then
  81. echo "Can not run buildconf from outside of curl's source subdirectory!"
  82. echo "Change to the subdirectory where buildconf is found, and try again."
  83. exit 1
  84. fi
  85. #--------------------------------------------------------------------------
  86. # autoconf 2.57 or newer. Unpatched version 2.67 does not generate proper
  87. # configure script. Unpatched version 2.68 is simply unusable, we should
  88. # disallow 2.68 usage.
  89. #
  90. need_autoconf="2.57"
  91. ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  92. if test -z "$ac_version"; then
  93. echo "buildconf: autoconf not found."
  94. echo " You need autoconf version $need_autoconf or newer installed."
  95. exit 1
  96. fi
  97. old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
  98. if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
  99. echo "buildconf: autoconf version $ac_version found."
  100. echo " You need autoconf version $need_autoconf or newer installed."
  101. echo " If you have a sufficient autoconf installed, but it"
  102. echo " is not named 'autoconf', then try setting the"
  103. echo " AUTOCONF environment variable."
  104. exit 1
  105. fi
  106. if test "$1" = "2" -a "$2" -eq "67"; then
  107. echo "buildconf: autoconf version $ac_version (BAD)"
  108. echo " Unpatched version generates broken configure script."
  109. elif test "$1" = "2" -a "$2" -eq "68"; then
  110. echo "buildconf: autoconf version $ac_version (BAD)"
  111. echo " Unpatched version generates unusable configure script."
  112. else
  113. echo "buildconf: autoconf version $ac_version (ok)"
  114. fi
  115. am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  116. if test -z "$am4te_version"; then
  117. echo "buildconf: autom4te not found. Weird autoconf installation!"
  118. exit 1
  119. fi
  120. if test "$am4te_version" = "$ac_version"; then
  121. echo "buildconf: autom4te version $am4te_version (ok)"
  122. else
  123. echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
  124. exit 1
  125. fi
  126. #--------------------------------------------------------------------------
  127. # autoheader 2.50 or newer
  128. #
  129. ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  130. if test -z "$ah_version"; then
  131. echo "buildconf: autoheader not found."
  132. echo " You need autoheader version 2.50 or newer installed."
  133. exit 1
  134. fi
  135. old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
  136. if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
  137. echo "buildconf: autoheader version $ah_version found."
  138. echo " You need autoheader version 2.50 or newer installed."
  139. echo " If you have a sufficient autoheader installed, but it"
  140. echo " is not named 'autoheader', then try setting the"
  141. echo " AUTOHEADER environment variable."
  142. exit 1
  143. fi
  144. echo "buildconf: autoheader version $ah_version (ok)"
  145. #--------------------------------------------------------------------------
  146. # automake 1.7 or newer
  147. #
  148. need_automake="1.7"
  149. 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/'`
  150. if test -z "$am_version"; then
  151. echo "buildconf: automake not found."
  152. echo " You need automake version $need_automake or newer installed."
  153. exit 1
  154. fi
  155. old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
  156. if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
  157. echo "buildconf: automake version $am_version found."
  158. echo " You need automake version $need_automake or newer installed."
  159. echo " If you have a sufficient automake installed, but it"
  160. echo " is not named 'automake', then try setting the"
  161. echo " AUTOMAKE environment variable."
  162. exit 1
  163. fi
  164. echo "buildconf: automake version $am_version (ok)"
  165. 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/'`
  166. if test -z "$acloc_version"; then
  167. echo "buildconf: aclocal not found. Weird automake installation!"
  168. exit 1
  169. fi
  170. if test "$acloc_version" = "$am_version"; then
  171. echo "buildconf: aclocal version $acloc_version (ok)"
  172. else
  173. echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
  174. exit 1
  175. fi
  176. #--------------------------------------------------------------------------
  177. # GNU libtool preliminary check
  178. #
  179. want_lt_major=1
  180. want_lt_minor=4
  181. want_lt_patch=2
  182. want_lt_version=1.4.2
  183. # This approach that tries 'glibtool' first is intended for systems that
  184. # have GNU libtool named as 'glibtool' and libtool not being GNU's.
  185. libtool=`findtool glibtool 2>/dev/null`
  186. if test ! -x "$libtool"; then
  187. libtool=`findtool ${LIBTOOL:-libtool}`
  188. fi
  189. if test -z "$libtool"; then
  190. echo "buildconf: libtool not found."
  191. echo " You need GNU libtool $want_lt_version or newer installed."
  192. exit 1
  193. fi
  194. lt_pver=`$libtool --version 2>/dev/null|head -n 1`
  195. lt_qver=`echo $lt_pver|sed -e "s/([^)]*)//g" -e "s/^[^0-9]*//g"`
  196. lt_version=`echo $lt_qver|sed -e "s/[- ].*//" -e "s/\([a-z]*\)$//"`
  197. if test -z "$lt_version"; then
  198. echo "buildconf: libtool not found."
  199. echo " You need GNU libtool $want_lt_version or newer installed."
  200. exit 1
  201. fi
  202. old_IFS=$IFS; IFS='.'; set $lt_version; IFS=$old_IFS
  203. lt_major=$1
  204. lt_minor=$2
  205. lt_patch=$3
  206. if test -z "$lt_major"; then
  207. lt_status="bad"
  208. elif test "$lt_major" -gt "$want_lt_major"; then
  209. lt_status="good"
  210. elif test "$lt_major" -lt "$want_lt_major"; then
  211. lt_status="bad"
  212. elif test -z "$lt_minor"; then
  213. lt_status="bad"
  214. elif test "$lt_minor" -gt "$want_lt_minor"; then
  215. lt_status="good"
  216. elif test "$lt_minor" -lt "$want_lt_minor"; then
  217. lt_status="bad"
  218. elif test -z "$lt_patch"; then
  219. lt_status="bad"
  220. elif test "$lt_patch" -gt "$want_lt_patch"; then
  221. lt_status="good"
  222. elif test "$lt_patch" -lt "$want_lt_patch"; then
  223. lt_status="bad"
  224. else
  225. lt_status="good"
  226. fi
  227. if test "$lt_status" != "good"; then
  228. echo "buildconf: libtool version $lt_version found."
  229. echo " You need GNU libtool $want_lt_version or newer installed."
  230. exit 1
  231. fi
  232. echo "buildconf: libtool version $lt_version (ok)"
  233. #--------------------------------------------------------------------------
  234. # GNU libtoolize check
  235. #
  236. if test -z "$LIBTOOLIZE"; then
  237. # use (g)libtoolize from same location as (g)libtool
  238. libtoolize="${libtool}ize"
  239. else
  240. libtoolize=`findtool $LIBTOOLIZE`
  241. fi
  242. if test ! -f "$libtoolize"; then
  243. echo "buildconf: libtoolize not found."
  244. echo " You need GNU libtoolize $want_lt_version or newer installed."
  245. exit 1
  246. fi
  247. #--------------------------------------------------------------------------
  248. # m4 check
  249. #
  250. m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`;
  251. m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
  252. if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
  253. echo "buildconf: GNU m4 version $m4_version (ok)"
  254. else
  255. if test -z "$m4"; then
  256. echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
  257. else
  258. echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
  259. fi
  260. exit 1
  261. fi
  262. #--------------------------------------------------------------------------
  263. # perl check
  264. #
  265. PERL=`findtool ${PERL:-perl}`
  266. if test -z "$PERL"; then
  267. echo "buildconf: perl not found"
  268. exit 1
  269. fi
  270. #--------------------------------------------------------------------------
  271. # Remove files generated on previous buildconf/configure run.
  272. #
  273. for fname in .deps \
  274. .libs \
  275. *.la \
  276. *.lo \
  277. *.a \
  278. *.o \
  279. Makefile \
  280. Makefile.in \
  281. aclocal.m4 \
  282. aclocal.m4.bak \
  283. ares_build.h \
  284. ares_config.h \
  285. ares_config.h.in \
  286. autom4te.cache \
  287. compile \
  288. config.guess \
  289. curl_config.h \
  290. curl_config.h.in \
  291. config.log \
  292. config.lt \
  293. config.status \
  294. config.sub \
  295. configure \
  296. configurehelp.pm \
  297. curl-config \
  298. curlbuild.h \
  299. depcomp \
  300. libcares.pc \
  301. libcurl.pc \
  302. libtool \
  303. libtool.m4 \
  304. libtool.m4.tmp \
  305. ltmain.sh \
  306. ltoptions.m4 \
  307. ltsugar.m4 \
  308. ltversion.m4 \
  309. lt~obsolete.m4 \
  310. stamp-h1 \
  311. stamp-h2 \
  312. stamp-h3 ; do
  313. removethis "$fname"
  314. done
  315. #--------------------------------------------------------------------------
  316. # run the correct scripts now
  317. #
  318. echo "buildconf: running libtoolize"
  319. ${libtoolize} --copy --automake --force || die "libtoolize command failed"
  320. # When using libtool 1.5.X (X < 26) we copy libtool.m4 to our local m4
  321. # subdirectory and this local copy is patched to fix some warnings that
  322. # are triggered when running aclocal and using autoconf 2.62 or later.
  323. if test "$lt_major" = "1" && test "$lt_minor" = "5"; then
  324. if test -z "$lt_patch" || test "$lt_patch" -lt "26"; then
  325. echo "buildconf: copying libtool.m4 to local m4 subdir"
  326. ac_dir=`${ACLOCAL:-aclocal} --print-ac-dir`
  327. if test -f $ac_dir/libtool.m4; then
  328. cp -f $ac_dir/libtool.m4 m4/libtool.m4
  329. else
  330. echo "buildconf: $ac_dir/libtool.m4 not found"
  331. fi
  332. if test -f m4/libtool.m4; then
  333. echo "buildconf: renaming some variables in local m4/libtool.m4"
  334. $PERL -i.tmp -pe \
  335. 's/lt_prog_compiler_pic_works/lt_cv_prog_compiler_pic_works/g; \
  336. s/lt_prog_compiler_static_works/lt_cv_prog_compiler_static_works/g;' \
  337. m4/libtool.m4
  338. rm -f m4/libtool.m4.tmp
  339. fi
  340. fi
  341. fi
  342. if test -f m4/libtool.m4; then
  343. echo "buildconf: converting all mv to mv -f in local m4/libtool.m4"
  344. $PERL -i.tmp -pe 's/\bmv +([^-\s])/mv -f $1/g' m4/libtool.m4
  345. rm -f m4/libtool.m4.tmp
  346. fi
  347. echo "buildconf: running aclocal"
  348. ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "aclocal command failed"
  349. echo "buildconf: converting all mv to mv -f in local aclocal.m4"
  350. $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
  351. echo "buildconf: running autoheader"
  352. ${AUTOHEADER:-autoheader} || die "autoheader command failed"
  353. echo "buildconf: running autoconf"
  354. ${AUTOCONF:-autoconf} || die "autoconf command failed"
  355. if test -d ares; then
  356. cd ares
  357. echo "buildconf: running in ares"
  358. ./buildconf
  359. cd ..
  360. fi
  361. echo "buildconf: running automake"
  362. ${AUTOMAKE:-automake} --add-missing --copy || die "automake command failed"
  363. #--------------------------------------------------------------------------
  364. # GNU libtool complementary check
  365. #
  366. # Depending on the libtool and automake versions being used, config.guess
  367. # might not be installed in the subdirectory until automake has finished.
  368. # So we can not attempt to use it until this very last buildconf stage.
  369. #
  370. if test ! -f ./config.guess; then
  371. echo "buildconf: config.guess not found"
  372. else
  373. buildhost=`./config.guess 2>/dev/null|head -n 1`
  374. case $buildhost in
  375. *-*-darwin*)
  376. need_lt_major=1
  377. need_lt_minor=5
  378. need_lt_patch=26
  379. need_lt_check="yes"
  380. ;;
  381. *-*-hpux*)
  382. need_lt_major=1
  383. need_lt_minor=5
  384. need_lt_patch=24
  385. need_lt_check="yes"
  386. ;;
  387. esac
  388. if test ! -z "$need_lt_check"; then
  389. if test -z "$lt_major"; then
  390. lt_status="bad"
  391. elif test "$lt_major" -gt "$need_lt_major"; then
  392. lt_status="good"
  393. elif test "$lt_major" -lt "$need_lt_major"; then
  394. lt_status="bad"
  395. elif test -z "$lt_minor"; then
  396. lt_status="bad"
  397. elif test "$lt_minor" -gt "$need_lt_minor"; then
  398. lt_status="good"
  399. elif test "$lt_minor" -lt "$need_lt_minor"; then
  400. lt_status="bad"
  401. elif test -z "$lt_patch"; then
  402. lt_status="bad"
  403. elif test "$lt_patch" -gt "$need_lt_patch"; then
  404. lt_status="good"
  405. elif test "$lt_patch" -lt "$need_lt_patch"; then
  406. lt_status="bad"
  407. else
  408. lt_status="good"
  409. fi
  410. if test "$lt_status" != "good"; then
  411. need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
  412. echo "buildconf: libtool version $lt_version found."
  413. echo " $buildhost requires GNU libtool $need_lt_version or newer installed."
  414. rm -f configure
  415. exit 1
  416. fi
  417. fi
  418. fi
  419. #--------------------------------------------------------------------------
  420. # Finished successfully.
  421. #
  422. echo "buildconf: OK"
  423. exit 0