PageRenderTime 1441ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 1ms

/autogen.sh

http://github.com/highpower/xiva
Shell | 1491 lines | 992 code | 172 blank | 327 comment | 190 complexity | a7e2b02d8763ed2eb7090df24bb2ab55 MD5 | raw file
Possible License(s): LGPL-2.1
  1. #!/bin/sh
  2. # a u t o g e n . s h
  3. #
  4. # Copyright (c) 2005-2007 United States Government as represented by
  5. # the U.S. Army Research Laboratory.
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions
  9. # are met:
  10. #
  11. # 1. Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. #
  14. # 2. Redistributions in binary form must reproduce the above
  15. # copyright notice, this list of conditions and the following
  16. # disclaimer in the documentation and/or other materials provided
  17. # with the distribution.
  18. #
  19. # 3. The name of the author may not be used to endorse or promote
  20. # products derived from this software without specific prior written
  21. # permission.
  22. #
  23. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  24. # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26. # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  27. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  29. # GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  30. # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  32. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. #
  35. ###
  36. #
  37. # Script for automatically preparing the sources for compilation by
  38. # performing the myrid of necessary steps. The script attempts to
  39. # detect proper version support, and outputs warnings about particular
  40. # systems that have autotool peculiarities.
  41. #
  42. # Basically, if everything is set up and installed correctly, the
  43. # script will validate that minimum versions of the GNU Build System
  44. # tools are installed, account for several common configuration
  45. # issues, and then simply run autoreconf for you.
  46. #
  47. # If autoreconf fails, which can happen for many valid configurations,
  48. # this script proceeds to run manual preparation steps effectively
  49. # providing a POSIX shell script (mostly complete) reimplementation of
  50. # autoreconf.
  51. #
  52. # The AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER
  53. # environment variables and corresponding _OPTIONS variables (e.g.
  54. # AUTORECONF_OPTIONS) may be used to override the default automatic
  55. # detection behaviors. Similarly the _VERSION variables will override
  56. # the minimum required version numbers.
  57. #
  58. # Examples:
  59. #
  60. # To obtain help on usage:
  61. # ./autogen.sh --help
  62. #
  63. # To obtain verbose output:
  64. # ./autogen.sh --verbose
  65. #
  66. # To skip autoreconf and prepare manually:
  67. # AUTORECONF=false ./autogen.sh
  68. #
  69. # To verbosely try running with an older (unsupported) autoconf:
  70. # AUTOCONF_VERSION=2.50 ./autogen.sh --verbose
  71. #
  72. # Author: Christopher Sean Morrison <morrison@brlcad.org>
  73. #
  74. ######################################################################
  75. # set to minimum acceptible version of autoconf
  76. if [ "x$AUTOCONF_VERSION" = "x" ] ; then
  77. AUTOCONF_VERSION=2.52
  78. fi
  79. # set to minimum acceptible version of automake
  80. if [ "x$AUTOMAKE_VERSION" = "x" ] ; then
  81. AUTOMAKE_VERSION=1.6.0
  82. fi
  83. # set to minimum acceptible version of libtool
  84. if [ "x$LIBTOOL_VERSION" = "x" ] ; then
  85. LIBTOOL_VERSION=1.4.2
  86. fi
  87. ##################
  88. # ident function #
  89. ##################
  90. ident ( ) {
  91. # extract copyright from header
  92. __copyright="`grep Copyright $AUTOGEN_SH | head -${HEAD_N}1 | awk '{print $4}'`"
  93. if [ "x$__copyright" = "x" ] ; then
  94. __copyright="`date +%Y`"
  95. fi
  96. # extract version from CVS Id string
  97. __id="$Id: autogen.sh,v 14.97 2007/06/18 22:25:02 brlcad Exp $"
  98. __version="`echo $__id | sed 's/.*\([0-9][0-9][0-9][0-9]\)[-\/]\([0-9][0-9]\)[-\/]\([0-9][0-9]\).*/\1\2\3/'`"
  99. if [ "x$__version" = "x" ] ; then
  100. __version=""
  101. fi
  102. echo "autogen.sh build preparation script by Christopher Sean Morrison"
  103. echo "revised 3-clause BSD-style license, copyright (c) $__copyright"
  104. echo "script version $__version, ISO/IEC 9945 POSIX shell script"
  105. }
  106. ##################
  107. # USAGE FUNCTION #
  108. ##################
  109. usage ( ) {
  110. echo "Usage: $AUTOGEN_SH [-h|--help] [-v|--verbose] [-q|--quiet] [--version]"
  111. echo " --help Help on $NAME_OF_AUTOGEN usage"
  112. echo " --verbose Verbose progress output"
  113. echo " --quiet Quiet suppressed progress output"
  114. echo " --version Only perform GNU Build System version checks"
  115. echo
  116. echo "Description: This script will validate that minimum versions of the"
  117. echo "GNU Build System tools are installed and then run autoreconf for you."
  118. echo "Should autoreconf fail, manual preparation steps will be run"
  119. echo "potentially accounting for several common preparation issues. The"
  120. echo "AUTORECONF, AUTOCONF, AUTOMAKE, LIBTOOLIZE, ACLOCAL, AUTOHEADER,"
  121. echo "PROJECT, & CONFIGURE environment variables and corresponding _OPTIONS"
  122. echo "variables (e.g. AUTORECONF_OPTIONS) may be used to override the"
  123. echo "default automatic detection behavior."
  124. echo
  125. ident
  126. return 0
  127. }
  128. ##########################
  129. # VERSION_ERROR FUNCTION #
  130. ##########################
  131. version_error ( ) {
  132. if [ "x$1" = "x" ] ; then
  133. echo "INTERNAL ERROR: version_error was not provided a version"
  134. exit 1
  135. fi
  136. if [ "x$2" = "x" ] ; then
  137. echo "INTERNAL ERROR: version_error was not provided an application name"
  138. exit 1
  139. fi
  140. $ECHO
  141. $ECHO "ERROR: To prepare the ${PROJECT} build system from scratch,"
  142. $ECHO " at least version $1 of $2 must be installed."
  143. $ECHO
  144. $ECHO "$NAME_OF_AUTOGEN does not need to be run on the same machine that will"
  145. $ECHO "run configure or make. Either the GNU Autotools will need to be installed"
  146. $ECHO "or upgraded on this system, or $NAME_OF_AUTOGEN must be run on the source"
  147. $ECHO "code on another system and then transferred to here. -- Cheers!"
  148. $ECHO
  149. }
  150. ##########################
  151. # VERSION_CHECK FUNCTION #
  152. ##########################
  153. version_check ( ) {
  154. if [ "x$1" = "x" ] ; then
  155. echo "INTERNAL ERROR: version_check was not provided a minimum version"
  156. exit 1
  157. fi
  158. _min="$1"
  159. if [ "x$2" = "x" ] ; then
  160. echo "INTERNAL ERROR: version check was not provided a comparison version"
  161. exit 1
  162. fi
  163. _cur="$2"
  164. # needed to handle versions like 1.10 and 1.4-p6
  165. _min="`echo ${_min}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
  166. _cur="`echo ${_cur}. | sed 's/[^0-9]/./g' | sed 's/\.\././g'`"
  167. _min_major="`echo $_min | cut -d. -f1`"
  168. _min_minor="`echo $_min | cut -d. -f2`"
  169. _min_patch="`echo $_min | cut -d. -f3`"
  170. _cur_major="`echo $_cur | cut -d. -f1`"
  171. _cur_minor="`echo $_cur | cut -d. -f2`"
  172. _cur_patch="`echo $_cur | cut -d. -f3`"
  173. if [ "x$_min_major" = "x" ] ; then
  174. _min_major=0
  175. fi
  176. if [ "x$_min_minor" = "x" ] ; then
  177. _min_minor=0
  178. fi
  179. if [ "x$_min_patch" = "x" ] ; then
  180. _min_patch=0
  181. fi
  182. if [ "x$_cur_minor" = "x" ] ; then
  183. _cur_major=0
  184. fi
  185. if [ "x$_cur_minor" = "x" ] ; then
  186. _cur_minor=0
  187. fi
  188. if [ "x$_cur_patch" = "x" ] ; then
  189. _cur_patch=0
  190. fi
  191. $VERBOSE_ECHO "Checking if ${_cur_major}.${_cur_minor}.${_cur_patch} is greater than ${_min_major}.${_min_minor}.${_min_patch}"
  192. if [ $_min_major -lt $_cur_major ] ; then
  193. return 0
  194. elif [ $_min_major -eq $_cur_major ] ; then
  195. if [ $_min_minor -lt $_cur_minor ] ; then
  196. return 0
  197. elif [ $_min_minor -eq $_cur_minor ] ; then
  198. if [ $_min_patch -lt $_cur_patch ] ; then
  199. return 0
  200. elif [ $_min_patch -eq $_cur_patch ] ; then
  201. return 0
  202. fi
  203. fi
  204. fi
  205. return 1
  206. }
  207. ######################################
  208. # LOCATE_CONFIGURE_TEMPLATE FUNCTION #
  209. ######################################
  210. locate_configure_template ( ) {
  211. _pwd="`pwd`"
  212. if test -f "./configure.ac" ; then
  213. echo "./configure.ac"
  214. elif test -f "./configure.in" ; then
  215. echo "./configure.in"
  216. elif test -f "$_pwd/configure.ac" ; then
  217. echo "$_pwd/configure.ac"
  218. elif test -f "$_pwd/configure.in" ; then
  219. echo "$_pwd/configure.in"
  220. elif test -f "$PATH_TO_AUTOGEN/configure.ac" ; then
  221. echo "$PATH_TO_AUTOGEN/configure.ac"
  222. elif test -f "$PATH_TO_AUTOGEN/configure.in" ; then
  223. echo "$PATH_TO_AUTOGEN/configure.in"
  224. fi
  225. }
  226. ##################
  227. # argument check #
  228. ##################
  229. ARGS="$*"
  230. PATH_TO_AUTOGEN="`dirname $0`"
  231. NAME_OF_AUTOGEN="`basename $0`"
  232. AUTOGEN_SH="$PATH_TO_AUTOGEN/$NAME_OF_AUTOGEN"
  233. LIBTOOL_M4="${PATH_TO_AUTOGEN}/misc/libtool.m4"
  234. if [ "x$HELP" = "x" ] ; then
  235. HELP=no
  236. fi
  237. if [ "x$QUIET" = "x" ] ; then
  238. QUIET=no
  239. fi
  240. if [ "x$VERBOSE" = "x" ] ; then
  241. VERBOSE=no
  242. fi
  243. if [ "x$VERSION_ONLY" = "x" ] ; then
  244. VERSION_ONLY=no
  245. fi
  246. if [ "x$AUTORECONF_OPTIONS" = "x" ] ; then
  247. AUTORECONF_OPTIONS="-i -f"
  248. fi
  249. if [ "x$AUTOCONF_OPTIONS" = "x" ] ; then
  250. AUTOCONF_OPTIONS="-f"
  251. fi
  252. if [ "x$AUTOMAKE_OPTIONS" = "x" ] ; then
  253. AUTOMAKE_OPTIONS="-a -c -f"
  254. fi
  255. ALT_AUTOMAKE_OPTIONS="-a -c"
  256. if [ "x$LIBTOOLIZE_OPTIONS" = "x" ] ; then
  257. LIBTOOLIZE_OPTIONS="--automake -c -f"
  258. fi
  259. ALT_LIBTOOLIZE_OPTIONS="--automake --copy --force"
  260. if [ "x$ACLOCAL_OPTIONS" = "x" ] ; then
  261. ACLOCAL_OPTIONS=""
  262. fi
  263. if [ "x$AUTOHEADER_OPTIONS" = "x" ] ; then
  264. AUTOHEADER_OPTIONS=""
  265. fi
  266. for arg in $ARGS ; do
  267. case "x$arg" in
  268. x--help) HELP=yes ;;
  269. x-[hH]) HELP=yes ;;
  270. x--quiet) QUIET=yes ;;
  271. x-[qQ]) QUIET=yes ;;
  272. x--verbose) VERBOSE=yes ;;
  273. x-[vV]) VERBOSE=yes ;;
  274. x--version) VERSION_ONLY=yes ;;
  275. *)
  276. echo "Unknown option: $arg"
  277. echo
  278. usage
  279. exit 1
  280. ;;
  281. esac
  282. done
  283. #####################
  284. # environment check #
  285. #####################
  286. # sanity check before recursions potentially begin
  287. if [ ! -f "$AUTOGEN_SH" ] ; then
  288. echo "INTERNAL ERROR: $AUTOGEN_SH does not exist"
  289. if [ ! "x$0" = "x$AUTOGEN_SH" ] ; then
  290. echo "INTERNAL ERROR: dirname/basename inconsistency: $0 != $AUTOGEN_SH"
  291. fi
  292. exit 1
  293. fi
  294. # force locale setting to C so things like date output as expected
  295. LC_ALL=C
  296. # commands that this script expects
  297. for __cmd in echo head tail pwd ; do
  298. echo "test" | $__cmd > /dev/null 2>&1
  299. if [ $? != 0 ] ; then
  300. echo "INTERNAL ERROR: '${__cmd}' command is required"
  301. exit 2
  302. fi
  303. done
  304. echo "test" | grep "test" > /dev/null 2>&1
  305. if test ! x$? = x0 ; then
  306. echo "INTERNAL ERROR: grep command is required"
  307. exit 1
  308. fi
  309. echo "test" | sed "s/test/test/" > /dev/null 2>&1
  310. if test ! x$? = x0 ; then
  311. echo "INTERNAL ERROR: sed command is required"
  312. exit 1
  313. fi
  314. # determine the behavior of echo
  315. case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
  316. *c*,-n*) ECHO_N= ECHO_C='
  317. ' ECHO_T=' ' ;;
  318. *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
  319. *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
  320. esac
  321. # determine the behavior of head
  322. case "x`echo 'head' | head -n 1 2>&1`" in
  323. *xhead*) HEAD_N="n " ;;
  324. *) HEAD_N="" ;;
  325. esac
  326. # determine the behavior of tail
  327. case "x`echo 'tail' | tail -n 1 2>&1`" in
  328. *xtail*) TAIL_N="n " ;;
  329. *) TAIL_N="" ;;
  330. esac
  331. VERBOSE_ECHO=:
  332. ECHO=:
  333. if [ "x$QUIET" = "xyes" ] ; then
  334. if [ "x$VERBOSE" = "xyes" ] ; then
  335. echo "Verbose output quelled by quiet option. Further output disabled."
  336. fi
  337. else
  338. ECHO=echo
  339. if [ "x$VERBOSE" = "xyes" ] ; then
  340. echo "Verbose output enabled"
  341. VERBOSE_ECHO=echo
  342. fi
  343. fi
  344. # allow a recursive run to disable further recursions
  345. if [ "x$RUN_RECURSIVE" = "x" ] ; then
  346. RUN_RECURSIVE=yes
  347. fi
  348. ################################################
  349. # check for help arg and bypass version checks #
  350. ################################################
  351. if [ "x`echo $ARGS | sed 's/.*[hH][eE][lL][pP].*/help/'`" = "xhelp" ] ; then
  352. HELP=yes
  353. fi
  354. if [ "x$HELP" = "xyes" ] ; then
  355. usage
  356. $ECHO "---"
  357. $ECHO "Help was requested. No preparation or configuration will be performed."
  358. exit 0
  359. fi
  360. #######################
  361. # set up signal traps #
  362. #######################
  363. untrap_abnormal ( ) {
  364. for sig in 1 2 13 15; do
  365. trap - $sig
  366. done
  367. }
  368. # do this cleanup whenever we exit.
  369. trap '
  370. # start from the root
  371. if test -d "$START_PATH" ; then
  372. cd "$START_PATH"
  373. fi
  374. # restore/delete backup files
  375. if test "x$PFC_INIT" = "x1" ; then
  376. recursive_restore
  377. fi
  378. ' 0
  379. # trap SIGHUP (1), SIGINT (2), SIGPIPE (13), SIGTERM (15)
  380. for sig in 1 2 13 15; do
  381. trap '
  382. $ECHO ""
  383. $ECHO "Aborting $NAME_OF_AUTOGEN: caught signal '$sig'"
  384. # start from the root
  385. if test -d "$START_PATH" ; then
  386. cd "$START_PATH"
  387. fi
  388. # clean up on abnormal exit
  389. $VERBOSE_ECHO "rm -rf autom4te.cache"
  390. rm -rf autom4te.cache
  391. if test -f "acinclude.m4.$$.backup" ; then
  392. $VERBOSE_ECHO "cat acinclude.m4.$$.backup > acinclude.m4"
  393. chmod u+w acinclude.m4
  394. cat acinclude.m4.$$.backup > acinclude.m4
  395. $VERBOSE_ECHO "rm -f acinclude.m4.$$.backup"
  396. rm -f acinclude.m4.$$.backup
  397. fi
  398. { (exit 1); exit 1; }
  399. ' $sig
  400. done
  401. #############################
  402. # look for a configure file #
  403. #############################
  404. if [ "x$CONFIGURE" = "x" ] ; then
  405. CONFIGURE="`locate_configure_template`"
  406. if [ ! "x$CONFIGURE" = "x" ] ; then
  407. $VERBOSE_ECHO "Found a configure template: $CONFIGURE"
  408. fi
  409. else
  410. $ECHO "Using CONFIGURE environment variable override: $CONFIGURE"
  411. fi
  412. if [ "x$CONFIGURE" = "x" ] ; then
  413. if [ "x$VERSION_ONLY" = "xyes" ] ; then
  414. CONFIGURE=/dev/null
  415. else
  416. $ECHO
  417. $ECHO "A configure.ac or configure.in file could not be located implying"
  418. $ECHO "that the GNU Build System is at least not used in this directory. In"
  419. $ECHO "any case, there is nothing to do here without one of those files."
  420. $ECHO
  421. $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
  422. exit 1
  423. fi
  424. fi
  425. ####################
  426. # get project name #
  427. ####################
  428. if [ "x$PROJECT" = "x" ] ; then
  429. PROJECT="`grep AC_INIT $CONFIGURE | grep -v '.*#.*AC_INIT' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_INIT(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
  430. if [ "x$PROJECT" = "xAC_INIT" ] ; then
  431. # projects might be using the older/deprecated arg-less AC_INIT .. look for AM_INIT_AUTOMAKE instead
  432. PROJECT="`grep AM_INIT_AUTOMAKE $CONFIGURE | grep -v '.*#.*AM_INIT_AUTOMAKE' | tail -${TAIL_N}1 | sed 's/^[ ]*AM_INIT_AUTOMAKE(\([^,)]*\).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
  433. fi
  434. if [ "x$PROJECT" = "xAM_INIT_AUTOMAKE" ] ; then
  435. PROJECT="project"
  436. fi
  437. if [ "x$PROJECT" = "x" ] ; then
  438. PROJECT="project"
  439. fi
  440. else
  441. $ECHO "Using PROJECT environment variable override: $PROJECT"
  442. fi
  443. $ECHO "Preparing the $PROJECT build system...please wait"
  444. $ECHO
  445. ########################
  446. # check for autoreconf #
  447. ########################
  448. HAVE_AUTORECONF=no
  449. if [ "x$AUTORECONF" = "x" ] ; then
  450. for AUTORECONF in autoreconf ; do
  451. $VERBOSE_ECHO "Checking autoreconf version: $AUTORECONF --version"
  452. $AUTORECONF --version > /dev/null 2>&1
  453. if [ $? = 0 ] ; then
  454. HAVE_AUTORECONF=yes
  455. break
  456. fi
  457. done
  458. else
  459. HAVE_AUTORECONF=yes
  460. $ECHO "Using AUTORECONF environment variable override: $AUTORECONF"
  461. fi
  462. ##########################
  463. # autoconf version check #
  464. ##########################
  465. _acfound=no
  466. if [ "x$AUTOCONF" = "x" ] ; then
  467. for AUTOCONF in autoconf ; do
  468. $VERBOSE_ECHO "Checking autoconf version: $AUTOCONF --version"
  469. $AUTOCONF --version > /dev/null 2>&1
  470. if [ $? = 0 ] ; then
  471. _acfound=yes
  472. break
  473. fi
  474. done
  475. else
  476. _acfound=yes
  477. $ECHO "Using AUTOCONF environment variable override: $AUTOCONF"
  478. fi
  479. _report_error=no
  480. if [ ! "x$_acfound" = "xyes" ] ; then
  481. $ECHO "ERROR: Unable to locate GNU Autoconf."
  482. _report_error=yes
  483. else
  484. _version="`$AUTOCONF --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
  485. if [ "x$_version" = "x" ] ; then
  486. _version="0.0.0"
  487. fi
  488. $ECHO "Found GNU Autoconf version $_version"
  489. version_check "$AUTOCONF_VERSION" "$_version"
  490. if [ $? -ne 0 ] ; then
  491. _report_error=yes
  492. fi
  493. fi
  494. if [ "x$_report_error" = "xyes" ] ; then
  495. version_error "$AUTOCONF_VERSION" "GNU Autoconf"
  496. exit 1
  497. fi
  498. ##########################
  499. # automake version check #
  500. ##########################
  501. _amfound=no
  502. if [ "x$AUTOMAKE" = "x" ] ; then
  503. for AUTOMAKE in automake ; do
  504. $VERBOSE_ECHO "Checking automake version: $AUTOMAKE --version"
  505. $AUTOMAKE --version > /dev/null 2>&1
  506. if [ $? = 0 ] ; then
  507. _amfound=yes
  508. break
  509. fi
  510. done
  511. else
  512. _amfound=yes
  513. $ECHO "Using AUTOMAKE environment variable override: $AUTOMAKE"
  514. fi
  515. _report_error=no
  516. if [ ! "x$_amfound" = "xyes" ] ; then
  517. $ECHO
  518. $ECHO "ERROR: Unable to locate GNU Automake."
  519. _report_error=yes
  520. else
  521. _version="`$AUTOMAKE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
  522. if [ "x$_version" = "x" ] ; then
  523. _version="0.0.0"
  524. fi
  525. $ECHO "Found GNU Automake version $_version"
  526. version_check "$AUTOMAKE_VERSION" "$_version"
  527. if [ $? -ne 0 ] ; then
  528. _report_error=yes
  529. fi
  530. fi
  531. if [ "x$_report_error" = "xyes" ] ; then
  532. version_error "$AUTOMAKE_VERSION" "GNU Automake"
  533. exit 1
  534. fi
  535. ########################
  536. # check for libtoolize #
  537. ########################
  538. HAVE_LIBTOOLIZE=yes
  539. HAVE_ALT_LIBTOOLIZE=no
  540. _ltfound=no
  541. if [ "x$LIBTOOLIZE" = "x" ] ; then
  542. LIBTOOLIZE=libtoolize
  543. $VERBOSE_ECHO "Checking libtoolize version: $LIBTOOLIZE --version"
  544. $LIBTOOLIZE --version > /dev/null 2>&1
  545. if [ ! $? = 0 ] ; then
  546. HAVE_LIBTOOLIZE=no
  547. $ECHO
  548. if [ "x$HAVE_AUTORECONF" = "xno" ] ; then
  549. $ECHO "Warning: libtoolize does not appear to be available."
  550. else
  551. $ECHO "Warning: libtoolize does not appear to be available. This means that"
  552. $ECHO "the automatic build preparation via autoreconf will probably not work."
  553. $ECHO "Preparing the build by running each step individually, however, should"
  554. $ECHO "work and will be done automatically for you if autoreconf fails."
  555. fi
  556. # look for some alternates
  557. for tool in glibtoolize libtoolize15 libtoolize14 libtoolize13 ; do
  558. $VERBOSE_ECHO "Checking libtoolize alternate: $tool --version"
  559. _glibtoolize="`$tool --version > /dev/null 2>&1`"
  560. if [ $? = 0 ] ; then
  561. $VERBOSE_ECHO "Found $tool --version"
  562. _glti="`which $tool`"
  563. if [ "x$_glti" = "x" ] ; then
  564. $VERBOSE_ECHO "Cannot find $tool with which"
  565. continue;
  566. fi
  567. if test ! -f "$_glti" ; then
  568. $VERBOSE_ECHO "Cannot use $tool, $_glti is not a file"
  569. continue;
  570. fi
  571. _gltidir="`dirname $_glti`"
  572. if [ "x$_gltidir" = "x" ] ; then
  573. $VERBOSE_ECHO "Cannot find $tool path with dirname of $_glti"
  574. continue;
  575. fi
  576. if test ! -d "$_gltidir" ; then
  577. $VERBOSE_ECHO "Cannot use $tool, $_gltidir is not a directory"
  578. continue;
  579. fi
  580. HAVE_ALT_LIBTOOLIZE=yes
  581. LIBTOOLIZE="$tool"
  582. $ECHO
  583. $ECHO "Fortunately, $tool was found which means that your system may simply"
  584. $ECHO "have a non-standard or incomplete GNU Autotools install. If you have"
  585. $ECHO "sufficient system access, it may be possible to quell this warning by"
  586. $ECHO "running:"
  587. $ECHO
  588. sudo -V > /dev/null 2>&1
  589. if [ $? = 0 ] ; then
  590. $ECHO " sudo ln -s $_glti $_gltidir/libtoolize"
  591. $ECHO
  592. else
  593. $ECHO " ln -s $_glti $_gltidir/libtoolize"
  594. $ECHO
  595. $ECHO "Run that as root or with proper permissions to the $_gltidir directory"
  596. $ECHO
  597. fi
  598. _ltfound=yes
  599. break
  600. fi
  601. done
  602. else
  603. _ltfound=yes
  604. fi
  605. else
  606. _ltfound=yes
  607. $ECHO "Using LIBTOOLIZE environment variable override: $LIBTOOLIZE"
  608. fi
  609. ############################
  610. # libtoolize version check #
  611. ############################
  612. _report_error=no
  613. if [ ! "x$_ltfound" = "xyes" ] ; then
  614. $ECHO
  615. $ECHO "ERROR: Unable to locate GNU Libtool."
  616. _report_error=yes
  617. else
  618. _version="`$LIBTOOLIZE --version | head -${HEAD_N}1 | sed 's/[^0-9]*\([0-9\.][0-9\.]*\)/\1/'`"
  619. if [ "x$_version" = "x" ] ; then
  620. _version="0.0.0"
  621. fi
  622. $ECHO "Found GNU Libtool version $_version"
  623. version_check "$LIBTOOL_VERSION" "$_version"
  624. if [ $? -ne 0 ] ; then
  625. _report_error=yes
  626. fi
  627. fi
  628. if [ "x$_report_error" = "xyes" ] ; then
  629. version_error "$LIBTOOL_VERSION" "GNU Libtool"
  630. exit 1
  631. fi
  632. #####################
  633. # check for aclocal #
  634. #####################
  635. if [ "x$ACLOCAL" = "x" ] ; then
  636. for ACLOCAL in aclocal ; do
  637. $VERBOSE_ECHO "Checking aclocal version: $ACLOCAL --version"
  638. $ACLOCAL --version > /dev/null 2>&1
  639. if [ $? = 0 ] ; then
  640. break
  641. fi
  642. done
  643. else
  644. $ECHO "Using ACLOCAL environment variable override: $ACLOCAL"
  645. fi
  646. ########################
  647. # check for autoheader #
  648. ########################
  649. if [ "x$AUTOHEADER" = "x" ] ; then
  650. for AUTOHEADER in autoheader ; do
  651. $VERBOSE_ECHO "Checking autoheader version: $AUTOHEADER --version"
  652. $AUTOHEADER --version > /dev/null 2>&1
  653. if [ $? = 0 ] ; then
  654. break
  655. fi
  656. done
  657. else
  658. $ECHO "Using AUTOHEADER environment variable override: $AUTOHEADER"
  659. fi
  660. #########################
  661. # check if version only #
  662. #########################
  663. $VERBOSE_ECHO "Checking whether to only output version information"
  664. if [ "x$VERSION_ONLY" = "xyes" ] ; then
  665. $ECHO
  666. ident
  667. $ECHO "---"
  668. $ECHO "Version requested. No preparation or configuration will be performed."
  669. exit 0
  670. fi
  671. #################################
  672. # PROTECT_FROM_CLOBBER FUNCTION #
  673. #################################
  674. protect_from_clobber ( ) {
  675. PFC_INIT=1
  676. # protect COPYING & INSTALL from overwrite by automake. the
  677. # automake force option will (inappropriately) ignore the existing
  678. # contents of a COPYING and/or INSTALL files (depending on the
  679. # version) instead of just forcing *missing* files like it does
  680. # for AUTHORS, NEWS, and README. this is broken but extremely
  681. # prevalent behavior, so we protect against it by keeping a backup
  682. # of the file that can later be restored.
  683. if test -f COPYING ; then
  684. if test -f COPYING.$$.protect_from_automake.backup ; then
  685. $VERBOSE_ECHO "Already backed up COPYING in `pwd`"
  686. else
  687. $VERBOSE_ECHO "Backing up COPYING in `pwd`"
  688. $VERBOSE_ECHO "cp -p COPYING COPYING.$$.protect_from_automake.backup"
  689. cp -p COPYING COPYING.$$.protect_from_automake.backup
  690. fi
  691. fi
  692. if test -f INSTALL ; then
  693. if test -f INSTALL.$$.protect_from_automake.backup ; then
  694. $VERBOSE_ECHO "Already backed up INSTALL in `pwd`"
  695. else
  696. $VERBOSE_ECHO "Backing up INSTALL in `pwd`"
  697. $VERBOSE_ECHO "cp -p INSTALL INSTALL.$$.protect_from_automake.backup"
  698. cp -p INSTALL INSTALL.$$.protect_from_automake.backup
  699. fi
  700. fi
  701. }
  702. ##############################
  703. # RECURSIVE_PROTECT FUNCTION #
  704. ##############################
  705. recursive_protect ( ) {
  706. # for projects using recursive configure, run the build
  707. # preparation steps for the subdirectories. this function assumes
  708. # START_PATH was set to pwd before recursion begins so that
  709. # relative paths work.
  710. # git 'r done, protect COPYING and INSTALL from being clobbered
  711. protect_from_clobber
  712. if test -d autom4te.cache ; then
  713. $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
  714. $VERBOSE_ECHO "rm -rf autom4te.cache"
  715. rm -rf autom4te.cache
  716. fi
  717. # find configure template
  718. _configure="`locate_configure_template`"
  719. if [ "x$_configure" = "x" ] ; then
  720. return
  721. fi
  722. # $VERBOSE_ECHO "Looking for configure template found `pwd`/$_configure"
  723. # look for subdirs
  724. # $VERBOSE_ECHO "Looking for subdirs in `pwd`"
  725. _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
  726. CHECK_DIRS=""
  727. for dir in $_det_config_subdirs ; do
  728. if test -d "`pwd`/$dir" ; then
  729. CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
  730. fi
  731. done
  732. # process subdirs
  733. if [ ! "x$CHECK_DIRS" = "x" ] ; then
  734. $VERBOSE_ECHO "Recursively scanning the following directories:"
  735. $VERBOSE_ECHO " $CHECK_DIRS"
  736. for dir in $CHECK_DIRS ; do
  737. $VERBOSE_ECHO "Protecting files from automake in $dir"
  738. cd "$START_PATH"
  739. eval "cd $dir"
  740. # recursively git 'r done
  741. recursive_protect
  742. done
  743. fi
  744. } # end of recursive_protect
  745. #############################
  746. # RESTORE_CLOBBERED FUNCION #
  747. #############################
  748. restore_clobbered ( ) {
  749. # The automake (and autoreconf by extension) -f/--force-missing
  750. # option may overwrite COPYING and INSTALL even if they do exist.
  751. # Here we restore the files if necessary.
  752. spacer=no
  753. # COPYING
  754. if test -f COPYING.$$.protect_from_automake.backup ; then
  755. if test -f COPYING ; then
  756. # compare entire content, restore if needed
  757. if test "x`cat COPYING`" != "x`cat COPYING.$$.protect_from_automake.backup`" ; then
  758. if test "x$spacer" = "xno" ; then
  759. $VERBOSE_ECHO
  760. spacer=yes
  761. fi
  762. # restore the backup
  763. $VERBOSE_ECHO "Restoring COPYING from backup (automake -f likely clobbered it)"
  764. $VERBOSE_ECHO "rm -f COPYING"
  765. rm -f COPYING
  766. $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
  767. mv COPYING.$$.protect_from_automake.backup COPYING
  768. fi # check contents
  769. elif test -f COPYING.$$.protect_from_automake.backup ; then
  770. $VERBOSE_ECHO "mv COPYING.$$.protect_from_automake.backup COPYING"
  771. mv COPYING.$$.protect_from_automake.backup COPYING
  772. fi # -f COPYING
  773. # just in case
  774. $VERBOSE_ECHO "rm -f COPYING.$$.protect_from_automake.backup"
  775. rm -f COPYING.$$.protect_from_automake.backup
  776. fi # -f COPYING.$$.protect_from_automake.backup
  777. # INSTALL
  778. if test -f INSTALL.$$.protect_from_automake.backup ; then
  779. if test -f INSTALL ; then
  780. # compare entire content, restore if needed
  781. if test "x`cat INSTALL`" != "x`cat INSTALL.$$.protect_from_automake.backup`" ; then
  782. if test "x$spacer" = "xno" ; then
  783. $VERBOSE_ECHO
  784. spacer=yes
  785. fi
  786. # restore the backup
  787. $VERBOSE_ECHO "Restoring INSTALL from backup (automake -f likely clobbered it)"
  788. $VERBOSE_ECHO "rm -f INSTALL"
  789. rm -f INSTALL
  790. $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
  791. mv INSTALL.$$.protect_from_automake.backup INSTALL
  792. fi # check contents
  793. elif test -f INSTALL.$$.protect_from_automake.backup ; then
  794. $VERBOSE_ECHO "mv INSTALL.$$.protect_from_automake.backup INSTALL"
  795. mv INSTALL.$$.protect_from_automake.backup INSTALL
  796. fi # -f INSTALL
  797. # just in case
  798. $VERBOSE_ECHO "rm -f INSTALL.$$.protect_from_automake.backup"
  799. rm -f INSTALL.$$.protect_from_automake.backup
  800. fi # -f INSTALL.$$.protect_from_automake.backup
  801. CONFIGURE="`locate_configure_template`"
  802. if [ "x$CONFIGURE" = "x" ] ; then
  803. return
  804. fi
  805. _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
  806. if test ! -d "$_aux_dir" ; then
  807. _aux_dir=.
  808. fi
  809. for file in config.guess config.sub ltmain.sh ; do
  810. if test -f "${_aux_dir}/${file}" ; then
  811. $VERBOSE_ECHO "rm -f \"${_aux_dir}/${file}.backup\""
  812. rm -f "${_aux_dir}/${file}.backup"
  813. fi
  814. done
  815. } # end of restore_clobbered
  816. ##############################
  817. # RECURSIVE_RESTORE FUNCTION #
  818. ##############################
  819. recursive_restore ( ) {
  820. # restore COPYING and INSTALL from backup if they were clobbered
  821. # for each directory recursively.
  822. # git 'r undone
  823. restore_clobbered
  824. # find configure template
  825. _configure="`locate_configure_template`"
  826. if [ "x$_configure" = "x" ] ; then
  827. return
  828. fi
  829. # look for subdirs
  830. _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $_configure | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
  831. CHECK_DIRS=""
  832. for dir in $_det_config_subdirs ; do
  833. if test -d "`pwd`/$dir" ; then
  834. CHECK_DIRS="$CHECK_DIRS \"`pwd`/$dir\""
  835. fi
  836. done
  837. # process subdirs
  838. if [ ! "x$CHECK_DIRS" = "x" ] ; then
  839. $VERBOSE_ECHO "Recursively scanning the following directories:"
  840. $VERBOSE_ECHO " $CHECK_DIRS"
  841. for dir in $CHECK_DIRS ; do
  842. $VERBOSE_ECHO "Checking files for automake damage in $dir"
  843. cd "$START_PATH"
  844. eval "cd $dir"
  845. # recursively git 'r undone
  846. recursive_restore
  847. done
  848. fi
  849. } # end of recursive_restore
  850. #######################
  851. # INITIALIZE FUNCTION #
  852. #######################
  853. initialize ( ) {
  854. # this routine performs a variety of directory-specific
  855. # initializations. some are sanity checks, some are preventive,
  856. # and some are necessary setup detection.
  857. #
  858. # this function sets:
  859. # CONFIGURE
  860. # SEARCH_DIRS
  861. # CONFIG_SUBDIRS
  862. ##################################
  863. # check for a configure template #
  864. ##################################
  865. CONFIGURE="`locate_configure_template`"
  866. if [ "x$CONFIGURE" = "x" ] ; then
  867. $ECHO
  868. $ECHO "A configure.ac or configure.in file could not be located implying"
  869. $ECHO "that the GNU Build System is at least not used in this directory. In"
  870. $ECHO "any case, there is nothing to do here without one of those files."
  871. $ECHO
  872. $ECHO "ERROR: No configure.in or configure.ac file found in `pwd`"
  873. exit 1
  874. fi
  875. #####################
  876. # detect an aux dir #
  877. #####################
  878. _aux_dir="`grep AC_CONFIG_AUX_DIR $CONFIGURE | grep -v '.*#.*AC_CONFIG_AUX_DIR' | tail -${TAIL_N}1 | sed 's/^[ ]*AC_CONFIG_AUX_DIR(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
  879. if test ! -d "$_aux_dir" ; then
  880. _aux_dir=.
  881. else
  882. $VERBOSE_ECHO "Detected auxillary directory: $_aux_dir"
  883. fi
  884. ################################
  885. # detect a recursive configure #
  886. ################################
  887. CONFIG_SUBDIRS=""
  888. _det_config_subdirs="`grep AC_CONFIG_SUBDIRS $CONFIGURE | grep -v '.*#.*AC_CONFIG_SUBDIRS' | sed 's/^[ ]*AC_CONFIG_SUBDIRS(\(.*\)).*/\1/' | sed 's/.*\[\(.*\)\].*/\1/'`"
  889. for dir in $_det_config_subdirs ; do
  890. if test -d "`pwd`/$dir" ; then
  891. $VERBOSE_ECHO "Detected recursive configure directory: `pwd`/$dir"
  892. CONFIG_SUBDIRS="$CONFIG_SUBDIRS `pwd`/$dir"
  893. fi
  894. done
  895. ##########################################
  896. # make sure certain required files exist #
  897. ##########################################
  898. for file in AUTHORS COPYING ChangeLog INSTALL NEWS README ; do
  899. if test ! -f $file ; then
  900. $VERBOSE_ECHO "Touching ${file} since it does not exist"
  901. touch $file
  902. fi
  903. done
  904. ##################################################
  905. # make sure certain generated files do not exist #
  906. ##################################################
  907. for file in config.guess config.sub ltmain.sh ; do
  908. if test -f "${_aux_dir}/${file}" ; then
  909. $VERBOSE_ECHO "mv -f \"${_aux_dir}/${file}\" \"${_aux_dir}/${file}.backup\""
  910. mv -f "${_aux_dir}/${file}" "${_aux_dir}/${file}.backup"
  911. fi
  912. done
  913. ############################
  914. # search alternate m4 dirs #
  915. ############################
  916. SEARCH_DIRS=""
  917. for dir in m4 ; do
  918. if [ -d $dir ] ; then
  919. $VERBOSE_ECHO "Found extra aclocal search directory: $dir"
  920. SEARCH_DIRS="$SEARCH_DIRS -I $dir"
  921. fi
  922. done
  923. ######################################
  924. # remove any previous build products #
  925. ######################################
  926. if test -d autom4te.cache ; then
  927. $VERBOSE_ECHO "Found an autom4te.cache directory, deleting it"
  928. $VERBOSE_ECHO "rm -rf autom4te.cache"
  929. rm -rf autom4te.cache
  930. fi
  931. # tcl/tk (and probably others) have a customized aclocal.m4, so can't delete it
  932. # if test -f aclocal.m4 ; then
  933. # $VERBOSE_ECHO "Found an aclocal.m4 file, deleting it"
  934. # $VERBOSE_ECHO "rm -f aclocal.m4"
  935. # rm -f aclocal.m4
  936. # fi
  937. } # end of initialize()
  938. ##############
  939. # initialize #
  940. ##############
  941. # stash path
  942. START_PATH="`pwd`"
  943. # Before running autoreconf or manual steps, some prep detection work
  944. # is necessary or useful. Only needs to occur once per directory, but
  945. # does need to traverse the entire subconfigure hierarchy to protect
  946. # files from being clobbered even by autoreconf.
  947. recursive_protect
  948. # start from where we started
  949. cd "$START_PATH"
  950. # get ready to process
  951. initialize
  952. ############################################
  953. # prepare build via autoreconf or manually #
  954. ############################################
  955. reconfigure_manually=no
  956. if [ "x$HAVE_AUTORECONF" = "xyes" ] ; then
  957. $ECHO
  958. $ECHO $ECHO_N "Automatically preparing build ... $ECHO_C"
  959. $VERBOSE_ECHO "$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS"
  960. autoreconf_output="`$AUTORECONF $SEARCH_DIRS $AUTORECONF_OPTIONS 2>&1`"
  961. ret=$?
  962. $VERBOSE_ECHO "$autoreconf_output"
  963. if [ ! $ret = 0 ] ; then
  964. if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
  965. if [ ! "x`echo \"$autoreconf_output\" | grep libtoolize | grep \"No such file or directory\"`" = "x" ] ; then
  966. $ECHO
  967. $ECHO "Warning: autoreconf failed but due to what is usually a common libtool"
  968. $ECHO "misconfiguration issue. This problem is encountered on systems that"
  969. $ECHO "have installed libtoolize under a different name without providing a"
  970. $ECHO "symbolic link or without setting the LIBTOOLIZE environment variable."
  971. $ECHO
  972. $ECHO "Restarting the preparation steps with LIBTOOLIZE set to $LIBTOOLIZE"
  973. export LIBTOOLIZE
  974. RUN_RECURSIVE=no
  975. export RUN_RECURSIVE
  976. untrap_abnormal
  977. $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
  978. sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
  979. exit $?
  980. fi
  981. fi
  982. $ECHO "Warning: $AUTORECONF failed"
  983. if test -f ltmain.sh ; then
  984. $ECHO "libtoolize being run by autoreconf is not creating ltmain.sh in the auxillary directory like it should"
  985. fi
  986. $ECHO "Attempting to run the preparation steps individually"
  987. reconfigure_manually=yes
  988. fi
  989. else
  990. reconfigure_manually=yes
  991. fi
  992. ############################
  993. # LIBTOOL_FAILURE FUNCTION #
  994. ############################
  995. libtool_failure ( ) {
  996. # libtool is rather error-prone in comparison to the other
  997. # autotools and this routine attempts to compensate for some
  998. # common failures. the output after a libtoolize failure is
  999. # parsed for an error related to AC_PROG_LIBTOOL and if found, we
  1000. # attempt to inject a project-provided libtool.m4 file.
  1001. _autoconf_output="$1"
  1002. if [ "x$RUN_RECURSIVE" = "xno" ] ; then
  1003. # we already tried the libtool.m4, don't try again
  1004. return 1
  1005. fi
  1006. if test -f "$LIBTOOL_M4" ; then
  1007. found_libtool="`$ECHO $_autoconf_output | grep AC_PROG_LIBTOOL`"
  1008. if test ! "x$found_libtool" = "x" ; then
  1009. if test -f acinclude.m4 ; then
  1010. rm -f acinclude.m4.$$.backup
  1011. $VERBOSE_ECHO "cat acinclude.m4 > acinclude.m4.$$.backup"
  1012. cat acinclude.m4 > acinclude.m4.$$.backup
  1013. fi
  1014. $VERBOSE_ECHO "cat \"$LIBTOOL_M4\" >> acinclude.m4"
  1015. chmod u+w acinclude.m4
  1016. cat "$LIBTOOL_M4" >> acinclude.m4
  1017. # don't keep doing this
  1018. RUN_RECURSIVE=no
  1019. export RUN_RECURSIVE
  1020. untrap_abnormal
  1021. $ECHO
  1022. $ECHO "Restarting the preparation steps with libtool macros in acinclude.m4"
  1023. $VERBOSE_ECHO sh $AUTOGEN_SH "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
  1024. sh "$AUTOGEN_SH" "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$8" "$9"
  1025. exit $?
  1026. fi
  1027. fi
  1028. }
  1029. ###########################
  1030. # MANUAL_AUTOGEN FUNCTION #
  1031. ###########################
  1032. manual_autogen ( ) {
  1033. ##################################################
  1034. # Manual preparation steps taken are as follows: #
  1035. # aclocal [-I m4] #
  1036. # libtoolize --automake -c -f #
  1037. # aclocal [-I m4] #
  1038. # autoconf -f #
  1039. # autoheader #
  1040. # automake -a -c -f #
  1041. ##################################################
  1042. ###########
  1043. # aclocal #
  1044. ###########
  1045. $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
  1046. aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
  1047. ret=$?
  1048. $VERBOSE_ECHO "$aclocal_output"
  1049. if [ ! $ret = 0 ] ; then $ECHO "ERROR: $ACLOCAL failed" && exit 2 ; fi
  1050. ##############
  1051. # libtoolize #
  1052. ##############
  1053. need_libtoolize=no
  1054. for feature in AC_PROG_LIBTOOL LT_INIT ; do
  1055. $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
  1056. found="`grep \"^$feature.*\" $CONFIGURE`"
  1057. if [ ! "x$found" = "x" ] ; then
  1058. need_libtoolize=yes
  1059. break
  1060. fi
  1061. done
  1062. if [ "x$need_libtoolize" = "xyes" ] ; then
  1063. if [ "x$HAVE_LIBTOOLIZE" = "xyes" ] ; then
  1064. $VERBOSE_ECHO "$LIBTOOLIZE $LIBTOOLIZE_OPTIONS"
  1065. libtoolize_output="`$LIBTOOLIZE $LIBTOOLIZE_OPTIONS 2>&1`"
  1066. ret=$?
  1067. $VERBOSE_ECHO "$libtoolize_output"
  1068. if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
  1069. else
  1070. if [ "x$HAVE_ALT_LIBTOOLIZE" = "xyes" ] ; then
  1071. $VERBOSE_ECHO "$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS"
  1072. libtoolize_output="`$LIBTOOLIZE $ALT_LIBTOOLIZE_OPTIONS 2>&1`"
  1073. ret=$?
  1074. $VERBOSE_ECHO "$libtoolize_output"
  1075. if [ ! $ret = 0 ] ; then $ECHO "ERROR: $LIBTOOLIZE failed" && exit 2 ; fi
  1076. fi
  1077. fi
  1078. ###########
  1079. # aclocal #
  1080. ###########
  1081. # re-run again as instructed by libtoolize
  1082. $VERBOSE_ECHO "$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS"
  1083. aclocal_output="`$ACLOCAL $SEARCH_DIRS $ACLOCAL_OPTIONS 2>&1`"
  1084. ret=$?
  1085. $VERBOSE_ECHO "$aclocal_output"
  1086. # libtoolize might put ltmain.sh in the wrong place
  1087. if test -f ltmain.sh ; then
  1088. if test ! -f "${_aux_dir}/ltmain.sh" ; then
  1089. $ECHO
  1090. $ECHO "Warning: $LIBTOOLIZE is creating ltmain.sh in the wrong directory"
  1091. $ECHO
  1092. $ECHO "Fortunately, the problem can be worked around by simply copying the"
  1093. $ECHO "file to the appropriate location (${_aux_dir}/). This has been done for you."
  1094. $ECHO
  1095. $VERBOSE_ECHO "cp -p ltmain.sh \"${_aux_dir}/ltmain.sh\""
  1096. cp -p ltmain.sh "${_aux_dir}/ltmain.sh"
  1097. $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
  1098. fi
  1099. fi # ltmain.sh
  1100. fi # need_libtoolize
  1101. ############
  1102. # autoconf #
  1103. ############
  1104. $VERBOSE_ECHO
  1105. $VERBOSE_ECHO "$AUTOCONF $AUTOCONF_OPTIONS"
  1106. autoconf_output="`$AUTOCONF $AUTOCONF_OPTIONS 2>&1`"
  1107. ret=$?
  1108. $VERBOSE_ECHO "$autoconf_output"
  1109. if [ ! $ret = 0 ] ; then
  1110. # retry without the -f and check for usage of macros that are too new
  1111. ac2_59_macros="AC_C_RESTRICT AC_INCLUDES_DEFAULT AC_LANG_ASSERT AC_LANG_WERROR AS_SET_CATFILE"
  1112. ac2_55_macros="AC_COMPILER_IFELSE AC_FUNC_MBRTOWC AC_HEADER_STDBOOL AC_LANG_CONFTEST AC_LANG_SOURCE AC_LANG_PROGRAM AC_LANG_CALL AC_LANG_FUNC_TRY_LINK AC_MSG_FAILURE AC_PREPROC_IFELSE"
  1113. ac2_54_macros="AC_C_BACKSLASH_A AC_CONFIG_LIBOBJ_DIR AC_GNU_SOURCE AC_PROG_EGREP AC_PROG_FGREP AC_REPLACE_FNMATCH AC_FUNC_FNMATCH_GNU AC_FUNC_REALLOC AC_TYPE_MBSTATE_T"
  1114. macros_to_search=""
  1115. ac_major="`echo ${AUTOCONF_VERSION}. | cut -d. -f1 | sed 's/[^0-9]//g'`"
  1116. ac_minor="`echo ${AUTOCONF_VERSION}. | cut -d. -f2 | sed 's/[^0-9]//g'`"
  1117. if [ $ac_major -lt 2 ] ; then
  1118. macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
  1119. else
  1120. if [ $ac_minor -lt 54 ] ; then
  1121. macros_to_search="$ac2_59_macros $ac2_55_macros $ac2_54_macros"
  1122. elif [ $ac_minor -lt 55 ] ; then
  1123. macros_to_search="$ac2_59_macros $ac2_55_macros"
  1124. elif [ $ac_minor -lt 59 ] ; then
  1125. macros_to_search="$ac2_59_macros"
  1126. fi
  1127. fi
  1128. configure_ac_macros=__none__
  1129. for feature in $macros_to_search ; do
  1130. $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
  1131. found="`grep \"^$feature.*\" $CONFIGURE`"
  1132. if [ ! "x$found" = "x" ] ; then
  1133. if [ "x$configure_ac_macros" = "x__none__" ] ; then
  1134. configure_ac_macros="$feature"
  1135. else
  1136. configure_ac_macros="$feature $configure_ac_macros"
  1137. fi
  1138. fi
  1139. done
  1140. if [ ! "x$configure_ac_macros" = "x__none__" ] ; then
  1141. $ECHO
  1142. $ECHO "Warning: Unsupported macros were found in $CONFIGURE"
  1143. $ECHO
  1144. $ECHO "The `echo $CONFIGURE | basename` file was scanned in order to determine if any"
  1145. $ECHO "unsupported macros are used that exceed the minimum version"
  1146. $ECHO "settings specified within this file. As such, the following macros"
  1147. $ECHO "should be removed from configure.ac or the version numbers in this"
  1148. $ECHO "file should be increased:"
  1149. $ECHO
  1150. $ECHO "$configure_ac_macros"
  1151. $ECHO
  1152. $ECHO $ECHO_N "Ignorantly continuing build preparation ... $ECHO_C"
  1153. fi
  1154. ###################
  1155. # autoconf, retry #
  1156. ###################
  1157. $VERBOSE_ECHO
  1158. $VERBOSE_ECHO "$AUTOCONF"
  1159. autoconf_output="`$AUTOCONF 2>&1`"
  1160. ret=$?
  1161. $VERBOSE_ECHO "$autoconf_output"
  1162. if [ ! $ret = 0 ] ; then
  1163. # test if libtool is busted
  1164. libtool_failure "$autoconf_output"
  1165. # let the user know what went wrong
  1166. cat <<EOF
  1167. $autoconf_output
  1168. EOF
  1169. $ECHO "ERROR: $AUTOCONF failed"
  1170. exit 2
  1171. else
  1172. # autoconf sans -f and possibly sans unsupported options succeed so warn verbosely
  1173. $ECHO
  1174. $ECHO "Warning: autoconf seems to have succeeded by removing the following options:"
  1175. $ECHO " AUTOCONF_OPTIONS=\"$AUTOCONF_OPTIONS\""
  1176. $ECHO
  1177. $ECHO "Removing those options should not be necessary and indicate some other"
  1178. $ECHO "problem with the build system. The build preparation is highly suspect"
  1179. $ECHO "and may result in configuration or compilation errors. Consider"
  1180. if [ "x$VERBOSE_ECHO" = "x:" ] ; then
  1181. $ECHO "rerunning the build preparation with verbose output enabled."
  1182. $ECHO " $AUTOGEN_SH --verbose"
  1183. else
  1184. $ECHO "reviewing the minimum GNU Autotools version settings contained in"
  1185. $ECHO "this script along with the macros being used in your `echo $CONFIGURE | basename` file."
  1186. fi
  1187. $ECHO
  1188. $ECHO $ECHO_N "Continuing build preparation ... $ECHO_C"
  1189. fi # autoconf ret = 0
  1190. fi # autoconf ret = 0
  1191. ##############
  1192. # autoheader #
  1193. ##############
  1194. need_autoheader=no
  1195. for feature in AM_CONFIG_HEADER AC_CONFIG_HEADER ; do
  1196. $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
  1197. found="`grep \"^$feature.*\" $CONFIGURE`"
  1198. if [ ! "x$found" = "x" ] ; then
  1199. need_autoheader=yes
  1200. break
  1201. fi
  1202. done
  1203. if [ "x$need_autoheader" = "xyes" ] ; then
  1204. $VERBOSE_ECHO "$AUTOHEADER $AUTOHEADER_OPTIONS"
  1205. autoheader_output="`$AUTOHEADER $AUTOHEADER_OPTIONS 2>&1`"
  1206. ret=$?
  1207. $VERBOSE_ECHO "$autoheader_output"
  1208. if [ ! $ret = 0 ] ; then $ECHO "ERROR: $AUTOHEADER failed" && exit 2 ; fi
  1209. fi # need_autoheader
  1210. ############
  1211. # automake #
  1212. ############
  1213. need_automake=no
  1214. for feature in AM_INIT_AUTOMAKE ; do
  1215. $VERBOSE_ECHO "Searching for $feature in $CONFIGURE"
  1216. found="`grep \"^$feature.*\" $CONFIGURE`"
  1217. if [ ! "x$found" = "x" ] ; then
  1218. need_automake=yes
  1219. break
  1220. fi
  1221. done
  1222. if [ "x$need_automake" = "xyes" ] ; then
  1223. $VERBOSE_ECHO "$AUTOMAKE $AUTOMAKE_OPTIONS"
  1224. automake_output="`$AUTOMAKE $AUTOMAKE_OPTIONS 2>&1`"
  1225. ret=$?
  1226. $VERBOSE_ECHO "$automake_output"
  1227. if [ ! $ret = 0 ] ; then
  1228. ###################
  1229. # automake, retry #
  1230. ###################
  1231. $VERBOSE_ECHO
  1232. $VERBOSE_ECHO "$AUTOMAKE $ALT_AUTOMAKE_OPTIONS"
  1233. # retry without the -f
  1234. automake_output="`$AUTOMAKE $ALT_AUTOMAKE_OPTIONS 2>&1`"
  1235. ret=$?
  1236. $VERBOSE_ECHO "$automake_output"
  1237. if [ ! $ret = 0 ] ; then
  1238. # test if libtool is busted
  1239. libtool_failure "$automake_output"
  1240. # let the user know what went wrong
  1241. cat <<EOF
  1242. $automake_output
  1243. EOF
  1244. $ECHO "ERROR: $AUTOMAKE failed"
  1245. exit 2
  1246. fi # automake retry
  1247. fi # automake ret = 0
  1248. fi # need_automake
  1249. } # end of manual_autogen
  1250. #####################################
  1251. # RECURSIVE_MANUAL_AUTOGEN FUNCTION #
  1252. #####################################
  1253. recursive_manual_autogen ( ) {
  1254. # run the build preparation steps manually for this directory
  1255. manual_autogen
  1256. # for projects using recursive configure, run the build
  1257. # preparation steps for the subdirectories.
  1258. if [ ! "x$CONFIG_SUBDIRS" = "x" ] ; then
  1259. $VERBOSE_ECHO "Recursively configuring the following directories:"
  1260. $VERBOSE_ECHO " $CONFIG_SUBDIRS"
  1261. for dir in $CONFIG_SUBDIRS ; do
  1262. $VERBOSE_ECHO "Processing recursive configure in $dir"
  1263. cd "$START_PATH"
  1264. cd "$dir"
  1265. # new directory, prepare
  1266. initialize
  1267. # run manual steps for the subdir and any others below
  1268. recursive_manual_autogen
  1269. done
  1270. fi
  1271. }
  1272. ################################
  1273. # run manual preparation steps #
  1274. ################################
  1275. if [ "x$reconfigure_manually" = "xyes" ] ; then
  1276. $ECHO
  1277. $ECHO $ECHO_N "Preparing build ... $ECHO_C"
  1278. recursive_manual_autogen
  1279. fi
  1280. #########################
  1281. # restore and summarize #
  1282. #########################
  1283. cd "$START_PATH"
  1284. # restore COPYING and INSTALL from backup if necessary
  1285. recursive_restore
  1286. # make sure we end up with a configure script
  1287. config_ac="`locate_configure_template`"
  1288. config="`echo $config_ac | sed 's/\.ac$//' | sed 's/\.in$//'`"
  1289. if [ "x$config" = "x" ] ; then
  1290. $VERBOSE_ECHO "Could not locate the configure template (from `pwd`)"
  1291. fi
  1292. # summarize
  1293. $ECHO "done"
  1294. $ECHO
  1295. if test "x$config" = "x" -o ! -f "$config" ; then
  1296. $ECHO "WARNING: The $PROJECT build system should now be prepared but there"
  1297. $ECHO "does not seem to be a resulting configure file. This is unexpected"
  1298. $ECHO "and likely the result of an error. You should run $NAME_OF_AUTOGEN"
  1299. $ECHO "with the --verbose option to get more details on a potential"
  1300. $ECHO "misconfiguration."
  1301. else
  1302. $ECHO "The $PROJECT build system is now prepared. To build here, run:"
  1303. $ECHO " $config"
  1304. $ECHO " make"
  1305. fi
  1306. # Local Variables:
  1307. # mode: sh
  1308. # tab-width: 8
  1309. # sh-basic-offset: 4
  1310. # sh-indentation: 4
  1311. # indent-tabs-mode: t
  1312. # End:
  1313. # ex: shiftwidth=4 tabstop=8