buildconf 14 KB

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