autogen.sh 46 KB

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