buildconf 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. #!/bin/sh
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2010, 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. die(){
  24. echo "$@"
  25. exit
  26. }
  27. #--------------------------------------------------------------------------
  28. # findtool works as 'which' but we use a different name to make it more
  29. # obvious we aren't using 'which'! ;-)
  30. #
  31. findtool(){
  32. file="$1"
  33. if { echo $file | grep "/" >/dev/null 2>&1; } then
  34. # we only check for the explicit file name if the file is given
  35. # including a slash. Use ./ for current dir. Previously this would
  36. # otherwise always cause findtool to search the local dir first, which
  37. # is wrong.
  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/main.c ||
  78. test ! -f lib/urldata.h ||
  79. test ! -f include/curl/curl.h; then
  80. echo "Can not run buildconf from outside of curl's source subdirectory!"
  81. echo "Change to the subdirectory where buildconf is found, and try again."
  82. exit 1
  83. fi
  84. #--------------------------------------------------------------------------
  85. # autoconf 2.57 or newer
  86. #
  87. need_autoconf="2.57"
  88. ac_version=`${AUTOCONF:-autoconf} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  89. if test -z "$ac_version"; then
  90. echo "buildconf: autoconf not found."
  91. echo " You need autoconf version $need_autoconf or newer installed."
  92. exit 1
  93. fi
  94. old_IFS=$IFS; IFS='.'; set $ac_version; IFS=$old_IFS
  95. if test "$1" = "2" -a "$2" -lt "57" || test "$1" -lt "2"; then
  96. echo "buildconf: autoconf version $ac_version found."
  97. echo " You need autoconf version $need_autoconf or newer installed."
  98. echo " If you have a sufficient autoconf installed, but it"
  99. echo " is not named 'autoconf', then try setting the"
  100. echo " AUTOCONF environment variable."
  101. exit 1
  102. fi
  103. echo "buildconf: autoconf version $ac_version (ok)"
  104. am4te_version=`${AUTOM4TE:-autom4te} --version 2>/dev/null|head -n 1| sed -e 's/autom4te\(.*\)/\1/' -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  105. if test -z "$am4te_version"; then
  106. echo "buildconf: autom4te not found. Weird autoconf installation!"
  107. exit 1
  108. fi
  109. if test "$am4te_version" = "$ac_version"; then
  110. echo "buildconf: autom4te version $am4te_version (ok)"
  111. else
  112. echo "buildconf: autom4te version $am4te_version (ERROR: does not match autoconf version)"
  113. exit 1
  114. fi
  115. #--------------------------------------------------------------------------
  116. # autoheader 2.50 or newer
  117. #
  118. ah_version=`${AUTOHEADER:-autoheader} --version 2>/dev/null|head -n 1| sed -e 's/^[^0-9]*//' -e 's/[a-z]* *$//'`
  119. if test -z "$ah_version"; then
  120. echo "buildconf: autoheader not found."
  121. echo " You need autoheader version 2.50 or newer installed."
  122. exit 1
  123. fi
  124. old_IFS=$IFS; IFS='.'; set $ah_version; IFS=$old_IFS
  125. if test "$1" = "2" -a "$2" -lt "50" || test "$1" -lt "2"; then
  126. echo "buildconf: autoheader version $ah_version found."
  127. echo " You need autoheader version 2.50 or newer installed."
  128. echo " If you have a sufficient autoheader installed, but it"
  129. echo " is not named 'autoheader', then try setting the"
  130. echo " AUTOHEADER environment variable."
  131. exit 1
  132. fi
  133. echo "buildconf: autoheader version $ah_version (ok)"
  134. #--------------------------------------------------------------------------
  135. # automake 1.7 or newer
  136. #
  137. need_automake="1.7"
  138. 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/'`
  139. if test -z "$am_version"; then
  140. echo "buildconf: automake not found."
  141. echo " You need automake version $need_automake or newer installed."
  142. exit 1
  143. fi
  144. old_IFS=$IFS; IFS='.'; set $am_version; IFS=$old_IFS
  145. if test "$1" = "1" -a "$2" -lt "7" || test "$1" -lt "1"; then
  146. echo "buildconf: automake version $am_version found."
  147. echo " You need automake version $need_automake or newer installed."
  148. echo " If you have a sufficient automake installed, but it"
  149. echo " is not named 'automake', then try setting the"
  150. echo " AUTOMAKE environment variable."
  151. exit 1
  152. fi
  153. echo "buildconf: automake version $am_version (ok)"
  154. 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/'`
  155. if test -z "$acloc_version"; then
  156. echo "buildconf: aclocal not found. Weird automake installation!"
  157. exit 1
  158. fi
  159. if test "$acloc_version" = "$am_version"; then
  160. echo "buildconf: aclocal version $acloc_version (ok)"
  161. else
  162. echo "buildconf: aclocal version $acloc_version (ERROR: does not match automake version)"
  163. exit 1
  164. fi
  165. #--------------------------------------------------------------------------
  166. # libtool check
  167. #
  168. LIBTOOL_WANTED_MAJOR=1
  169. LIBTOOL_WANTED_MINOR=4
  170. LIBTOOL_WANTED_PATCH=2
  171. LIBTOOL_WANTED_VERSION=1.4.2
  172. # this approach that tries 'glibtool' first is some kind of work-around for
  173. # some BSD-systems I believe that use to provide the GNU libtool named
  174. # glibtool, with 'libtool' being something completely different.
  175. libtool=`findtool glibtool 2>/dev/null`
  176. if test ! -x "$libtool"; then
  177. libtool=`findtool ${LIBTOOL:-libtool}`
  178. fi
  179. if test -z "$LIBTOOLIZE"; then
  180. # set the LIBTOOLIZE here so that glibtoolize is used if glibtool was found
  181. # $libtool is already the full path
  182. libtoolize="${libtool}ize"
  183. else
  184. libtoolize=`findtool $LIBTOOLIZE`
  185. fi
  186. lt_pver=`$libtool --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: libtool not found."
  191. echo " You need libtool version $LIBTOOL_WANTED_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. lt_status="good"
  199. if test "$lt_major" = "$LIBTOOL_WANTED_MAJOR"; then
  200. if test "$lt_minor" -lt "$LIBTOOL_WANTED_MINOR"; then
  201. lt_status="bad"
  202. elif test -n "$LIBTOOL_WANTED_PATCH"; then
  203. if test "$lt_minor" -gt "$LIBTOOL_WANTED_MINOR"; then
  204. lt_status="good"
  205. elif test -n "$lt_patch"; then
  206. if test "$lt_patch" -lt "$LIBTOOL_WANTED_PATCH"; then
  207. lt_status="bad"
  208. fi
  209. else
  210. lt_status="bad"
  211. fi
  212. fi
  213. fi
  214. if test $lt_status != "good"; then
  215. echo "buildconf: libtool version $lt_version found."
  216. echo " You need libtool version $LIBTOOL_WANTED_VERSION or newer installed"
  217. exit 1
  218. fi
  219. echo "buildconf: libtool version $lt_version (ok)"
  220. if test -f "$libtoolize"; then
  221. echo "buildconf: libtoolize found"
  222. else
  223. echo "buildconf: libtoolize not found. Weird libtool installation!"
  224. exit 1
  225. fi
  226. #--------------------------------------------------------------------------
  227. # m4 check
  228. #
  229. m4=`(${M4:-m4} --version || ${M4:-gm4} --version) 2>/dev/null | head -n 1`;
  230. m4_version=`echo $m4 | sed -e 's/^.* \([0-9]\)/\1/' -e 's/[a-z]* *$//'`
  231. if { echo $m4 | grep "GNU" >/dev/null 2>&1; } then
  232. echo "buildconf: GNU m4 version $m4_version (ok)"
  233. else
  234. if test -z "$m4"; then
  235. echo "buildconf: m4 version not recognized. You need a GNU m4 installed!"
  236. else
  237. echo "buildconf: m4 version $m4 found. You need a GNU m4 installed!"
  238. fi
  239. exit 1
  240. fi
  241. #--------------------------------------------------------------------------
  242. # perl check
  243. #
  244. PERL=`findtool ${PERL:-perl}`
  245. #--------------------------------------------------------------------------
  246. # Remove files generated on previous buildconf/configure run.
  247. #
  248. for fname in .deps \
  249. .libs \
  250. *.la \
  251. *.lo \
  252. *.a \
  253. *.o \
  254. Makefile \
  255. Makefile.in \
  256. aclocal.m4 \
  257. aclocal.m4.bak \
  258. ares_build.h \
  259. ares_config.h \
  260. ares_config.h.in \
  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. curlbuild.h \
  274. depcomp \
  275. libcares.pc \
  276. libcurl.pc \
  277. libtool \
  278. libtool.m4 \
  279. ltmain.sh \
  280. ltoptions.m4 \
  281. ltsugar.m4 \
  282. ltversion.m4 \
  283. lt~obsolete.m4 \
  284. stamp-h1 \
  285. stamp-h2 \
  286. stamp-h3 ; do
  287. removethis "$fname"
  288. done
  289. #--------------------------------------------------------------------------
  290. # run the correct scripts now
  291. #
  292. echo "buildconf: running libtoolize"
  293. $libtoolize --copy --automake --force || die "The libtoolize command failed"
  294. if test ! -f m4/curl-functions.m4; then
  295. echo "buildconf: cURL m4 macros not found"
  296. exit 1
  297. fi
  298. echo "buildconf: running aclocal"
  299. ${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS || die "The aclocal command line failed"
  300. if test -n "$PERL"; then
  301. echo "buildconf: running aclocal hack to convert all mv to mv -f"
  302. $PERL -i.bak -pe 's/\bmv +([^-\s])/mv -f $1/g' aclocal.m4
  303. else
  304. echo "buildconf: perl not found"
  305. exit 1
  306. fi
  307. echo "buildconf: running autoheader"
  308. ${AUTOHEADER:-autoheader} || die "The autoheader command failed"
  309. echo "buildconf: cp lib/curl_config.h.in src/curl_config.h.in"
  310. cp lib/curl_config.h.in src/curl_config.h.in
  311. echo "buildconf: running autoconf"
  312. ${AUTOCONF:-autoconf} || die "The autoconf command failed"
  313. if test -d ares; then
  314. cd ares
  315. echo "buildconf: running in ares"
  316. ./buildconf
  317. cd ..
  318. fi
  319. echo "buildconf: running automake"
  320. ${AUTOMAKE:-automake} -a -c || die "The automake command failed"
  321. #--------------------------------------------------------------------------
  322. # Depending on the libtool and automake versions being used, config.guess
  323. # might not be installed in the subdirectory until automake has finished.
  324. # So we can not attempt to use it until this very last buildconf stage.
  325. #
  326. if test ! -f ./config.guess; then
  327. echo "buildconf: config.guess not found"
  328. else
  329. buildhost=`./config.guess 2>/dev/null|head -n 1`
  330. case $buildhost in
  331. *-*-darwin*)
  332. need_lt_major=1
  333. need_lt_minor=5
  334. need_lt_patch=26
  335. need_lt_check="yes"
  336. ;;
  337. *-*-hpux*)
  338. need_lt_major=1
  339. need_lt_minor=5
  340. need_lt_patch=24
  341. need_lt_check="yes"
  342. ;;
  343. esac
  344. if test ! -z "$need_lt_check"; then
  345. if test -z "$lt_major"; then
  346. lt_status="bad"
  347. elif test "$lt_major" -gt "$need_lt_major"; then
  348. lt_status="good"
  349. elif test "$lt_major" -lt "$need_lt_major"; then
  350. lt_status="bad"
  351. elif test -z "$lt_minor"; then
  352. lt_status="bad"
  353. elif test "$lt_minor" -gt "$need_lt_minor"; then
  354. lt_status="good"
  355. elif test "$lt_minor" -lt "$need_lt_minor"; then
  356. lt_status="bad"
  357. elif test -z "$lt_patch"; then
  358. lt_status="bad"
  359. elif test "$lt_patch" -gt "$need_lt_patch"; then
  360. lt_status="good"
  361. elif test "$lt_patch" -lt "$need_lt_patch"; then
  362. lt_status="bad"
  363. else
  364. lt_status="good"
  365. fi
  366. if test "$lt_status" != "good"; then
  367. need_lt_version="$need_lt_major.$need_lt_minor.$need_lt_patch"
  368. echo "buildconf: libtool version $lt_version found."
  369. echo " $buildhost requires libtool $need_lt_version or newer installed."
  370. rm -f configure
  371. exit 1
  372. fi
  373. fi
  374. fi
  375. #--------------------------------------------------------------------------
  376. # Finished successfully.
  377. #
  378. echo "buildconf: OK"
  379. exit 0