You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

buildconf 14KB

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