buildconf 14 KB

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