/Unittests/googletest/build-aux/ltmain.sh

http://unladen-swallow.googlecode.com/ · Shell · 6964 lines · 5912 code · 446 blank · 606 comment · 705 complexity · b529f1b434c30d86d7cdb018f7fad727 MD5 · raw file

Large files are truncated click here to view the full file

  1. # ltmain.sh - Provide generalized library-building support services.
  2. # NOTE: Changing this file will not affect anything until you rerun configure.
  3. #
  4. # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
  5. # 2007, 2008 Free Software Foundation, Inc.
  6. # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. # General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21. #
  22. # As a special exception to the GNU General Public License, if you
  23. # distribute this file as part of a program that contains a
  24. # configuration script generated by Autoconf, you may include it under
  25. # the same distribution terms that you use for the rest of that program.
  26. basename="s,^.*/,,g"
  27. # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
  28. # is ksh but when the shell is invoked as "sh" and the current value of
  29. # the _XPG environment variable is not equal to 1 (one), the special
  30. # positional parameter $0, within a function call, is the name of the
  31. # function.
  32. progpath="$0"
  33. # The name of this program:
  34. progname=`echo "$progpath" | $SED $basename`
  35. modename="$progname"
  36. # Global variables:
  37. EXIT_SUCCESS=0
  38. EXIT_FAILURE=1
  39. PROGRAM=ltmain.sh
  40. PACKAGE=libtool
  41. VERSION="1.5.26 Debian 1.5.26-1ubuntu1"
  42. TIMESTAMP=" (1.1220.2.493 2008/02/01 16:58:18)"
  43. # Be Bourne compatible (taken from Autoconf:_AS_BOURNE_COMPATIBLE).
  44. if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  45. emulate sh
  46. NULLCMD=:
  47. # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  48. # is contrary to our usage. Disable this feature.
  49. alias -g '${1+"$@"}'='"$@"'
  50. setopt NO_GLOB_SUBST
  51. else
  52. case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
  53. fi
  54. BIN_SH=xpg4; export BIN_SH # for Tru64
  55. DUALCASE=1; export DUALCASE # for MKS sh
  56. # Check that we have a working $echo.
  57. if test "X$1" = X--no-reexec; then
  58. # Discard the --no-reexec flag, and continue.
  59. shift
  60. elif test "X$1" = X--fallback-echo; then
  61. # Avoid inline document here, it may be left over
  62. :
  63. elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
  64. # Yippee, $echo works!
  65. :
  66. else
  67. # Restart under the correct shell, and then maybe $echo will work.
  68. exec $SHELL "$progpath" --no-reexec ${1+"$@"}
  69. fi
  70. if test "X$1" = X--fallback-echo; then
  71. # used as fallback echo
  72. shift
  73. cat <<EOF
  74. $*
  75. EOF
  76. exit $EXIT_SUCCESS
  77. fi
  78. default_mode=
  79. help="Try \`$progname --help' for more information."
  80. magic="%%%MAGIC variable%%%"
  81. mkdir="mkdir"
  82. mv="mv -f"
  83. rm="rm -f"
  84. # Sed substitution that helps us do robust quoting. It backslashifies
  85. # metacharacters that are still active within double-quoted strings.
  86. Xsed="${SED}"' -e 1s/^X//'
  87. sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
  88. # test EBCDIC or ASCII
  89. case `echo X|tr X '\101'` in
  90. A) # ASCII based system
  91. # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
  92. SP2NL='tr \040 \012'
  93. NL2SP='tr \015\012 \040\040'
  94. ;;
  95. *) # EBCDIC based system
  96. SP2NL='tr \100 \n'
  97. NL2SP='tr \r\n \100\100'
  98. ;;
  99. esac
  100. # NLS nuisances.
  101. # Only set LANG and LC_ALL to C if already set.
  102. # These must not be set unconditionally because not all systems understand
  103. # e.g. LANG=C (notably SCO).
  104. # We save the old values to restore during execute mode.
  105. lt_env=
  106. for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  107. do
  108. eval "if test \"\${$lt_var+set}\" = set; then
  109. save_$lt_var=\$$lt_var
  110. lt_env=\"$lt_var=\$$lt_var \$lt_env\"
  111. $lt_var=C
  112. export $lt_var
  113. fi"
  114. done
  115. if test -n "$lt_env"; then
  116. lt_env="env $lt_env"
  117. fi
  118. # Make sure IFS has a sensible default
  119. lt_nl='
  120. '
  121. IFS=" $lt_nl"
  122. if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
  123. $echo "$modename: not configured to build any kind of library" 1>&2
  124. $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
  125. exit $EXIT_FAILURE
  126. fi
  127. # Global variables.
  128. mode=$default_mode
  129. nonopt=
  130. prev=
  131. prevopt=
  132. run=
  133. show="$echo"
  134. show_help=
  135. execute_dlfiles=
  136. duplicate_deps=no
  137. preserve_args=
  138. lo2o="s/\\.lo\$/.${objext}/"
  139. o2lo="s/\\.${objext}\$/.lo/"
  140. extracted_archives=
  141. extracted_serial=0
  142. #####################################
  143. # Shell function definitions:
  144. # This seems to be the best place for them
  145. # func_mktempdir [string]
  146. # Make a temporary directory that won't clash with other running
  147. # libtool processes, and avoids race conditions if possible. If
  148. # given, STRING is the basename for that directory.
  149. func_mktempdir ()
  150. {
  151. my_template="${TMPDIR-/tmp}/${1-$progname}"
  152. if test "$run" = ":"; then
  153. # Return a directory name, but don't create it in dry-run mode
  154. my_tmpdir="${my_template}-$$"
  155. else
  156. # If mktemp works, use that first and foremost
  157. my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
  158. if test ! -d "$my_tmpdir"; then
  159. # Failing that, at least try and use $RANDOM to avoid a race
  160. my_tmpdir="${my_template}-${RANDOM-0}$$"
  161. save_mktempdir_umask=`umask`
  162. umask 0077
  163. $mkdir "$my_tmpdir"
  164. umask $save_mktempdir_umask
  165. fi
  166. # If we're not in dry-run mode, bomb out on failure
  167. test -d "$my_tmpdir" || {
  168. $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
  169. exit $EXIT_FAILURE
  170. }
  171. fi
  172. $echo "X$my_tmpdir" | $Xsed
  173. }
  174. # func_win32_libid arg
  175. # return the library type of file 'arg'
  176. #
  177. # Need a lot of goo to handle *both* DLLs and import libs
  178. # Has to be a shell function in order to 'eat' the argument
  179. # that is supplied when $file_magic_command is called.
  180. func_win32_libid ()
  181. {
  182. win32_libid_type="unknown"
  183. win32_fileres=`file -L $1 2>/dev/null`
  184. case $win32_fileres in
  185. *ar\ archive\ import\ library*) # definitely import
  186. win32_libid_type="x86 archive import"
  187. ;;
  188. *ar\ archive*) # could be an import, or static
  189. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
  190. $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
  191. win32_nmres=`eval $NM -f posix -A $1 | \
  192. $SED -n -e '1,100{
  193. / I /{
  194. s,.*,import,
  195. p
  196. q
  197. }
  198. }'`
  199. case $win32_nmres in
  200. import*) win32_libid_type="x86 archive import";;
  201. *) win32_libid_type="x86 archive static";;
  202. esac
  203. fi
  204. ;;
  205. *DLL*)
  206. win32_libid_type="x86 DLL"
  207. ;;
  208. *executable*) # but shell scripts are "executable" too...
  209. case $win32_fileres in
  210. *MS\ Windows\ PE\ Intel*)
  211. win32_libid_type="x86 DLL"
  212. ;;
  213. esac
  214. ;;
  215. esac
  216. $echo $win32_libid_type
  217. }
  218. # func_infer_tag arg
  219. # Infer tagged configuration to use if any are available and
  220. # if one wasn't chosen via the "--tag" command line option.
  221. # Only attempt this if the compiler in the base compile
  222. # command doesn't match the default compiler.
  223. # arg is usually of the form 'gcc ...'
  224. func_infer_tag ()
  225. {
  226. if test -n "$available_tags" && test -z "$tagname"; then
  227. CC_quoted=
  228. for arg in $CC; do
  229. case $arg in
  230. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  231. arg="\"$arg\""
  232. ;;
  233. esac
  234. CC_quoted="$CC_quoted $arg"
  235. done
  236. case $@ in
  237. # Blanks in the command may have been stripped by the calling shell,
  238. # but not from the CC environment variable when configure was run.
  239. " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
  240. # Blanks at the start of $base_compile will cause this to fail
  241. # if we don't check for them as well.
  242. *)
  243. for z in $available_tags; do
  244. if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
  245. # Evaluate the configuration.
  246. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
  247. CC_quoted=
  248. for arg in $CC; do
  249. # Double-quote args containing other shell metacharacters.
  250. case $arg in
  251. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  252. arg="\"$arg\""
  253. ;;
  254. esac
  255. CC_quoted="$CC_quoted $arg"
  256. done
  257. case "$@ " in
  258. " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
  259. # The compiler in the base compile command matches
  260. # the one in the tagged configuration.
  261. # Assume this is the tagged configuration we want.
  262. tagname=$z
  263. break
  264. ;;
  265. esac
  266. fi
  267. done
  268. # If $tagname still isn't set, then no tagged configuration
  269. # was found and let the user know that the "--tag" command
  270. # line option must be used.
  271. if test -z "$tagname"; then
  272. $echo "$modename: unable to infer tagged configuration"
  273. $echo "$modename: specify a tag with \`--tag'" 1>&2
  274. exit $EXIT_FAILURE
  275. # else
  276. # $echo "$modename: using $tagname tagged configuration"
  277. fi
  278. ;;
  279. esac
  280. fi
  281. }
  282. # func_extract_an_archive dir oldlib
  283. func_extract_an_archive ()
  284. {
  285. f_ex_an_ar_dir="$1"; shift
  286. f_ex_an_ar_oldlib="$1"
  287. $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
  288. $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
  289. if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
  290. :
  291. else
  292. $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
  293. exit $EXIT_FAILURE
  294. fi
  295. }
  296. # func_extract_archives gentop oldlib ...
  297. func_extract_archives ()
  298. {
  299. my_gentop="$1"; shift
  300. my_oldlibs=${1+"$@"}
  301. my_oldobjs=""
  302. my_xlib=""
  303. my_xabs=""
  304. my_xdir=""
  305. my_status=""
  306. $show "${rm}r $my_gentop"
  307. $run ${rm}r "$my_gentop"
  308. $show "$mkdir $my_gentop"
  309. $run $mkdir "$my_gentop"
  310. my_status=$?
  311. if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
  312. exit $my_status
  313. fi
  314. for my_xlib in $my_oldlibs; do
  315. # Extract the objects.
  316. case $my_xlib in
  317. [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
  318. *) my_xabs=`pwd`"/$my_xlib" ;;
  319. esac
  320. my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
  321. my_xlib_u=$my_xlib
  322. while :; do
  323. case " $extracted_archives " in
  324. *" $my_xlib_u "*)
  325. extracted_serial=`expr $extracted_serial + 1`
  326. my_xlib_u=lt$extracted_serial-$my_xlib ;;
  327. *) break ;;
  328. esac
  329. done
  330. extracted_archives="$extracted_archives $my_xlib_u"
  331. my_xdir="$my_gentop/$my_xlib_u"
  332. $show "${rm}r $my_xdir"
  333. $run ${rm}r "$my_xdir"
  334. $show "$mkdir $my_xdir"
  335. $run $mkdir "$my_xdir"
  336. exit_status=$?
  337. if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
  338. exit $exit_status
  339. fi
  340. case $host in
  341. *-darwin*)
  342. $show "Extracting $my_xabs"
  343. # Do not bother doing anything if just a dry run
  344. if test -z "$run"; then
  345. darwin_orig_dir=`pwd`
  346. cd $my_xdir || exit $?
  347. darwin_archive=$my_xabs
  348. darwin_curdir=`pwd`
  349. darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
  350. darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
  351. if test -n "$darwin_arches"; then
  352. darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
  353. darwin_arch=
  354. $show "$darwin_base_archive has multiple architectures $darwin_arches"
  355. for darwin_arch in $darwin_arches ; do
  356. mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
  357. lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
  358. cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
  359. func_extract_an_archive "`pwd`" "${darwin_base_archive}"
  360. cd "$darwin_curdir"
  361. $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
  362. done # $darwin_arches
  363. ## Okay now we have a bunch of thin objects, gotta fatten them up :)
  364. darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
  365. darwin_file=
  366. darwin_files=
  367. for darwin_file in $darwin_filelist; do
  368. darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
  369. lipo -create -output "$darwin_file" $darwin_files
  370. done # $darwin_filelist
  371. ${rm}r unfat-$$
  372. cd "$darwin_orig_dir"
  373. else
  374. cd "$darwin_orig_dir"
  375. func_extract_an_archive "$my_xdir" "$my_xabs"
  376. fi # $darwin_arches
  377. fi # $run
  378. ;;
  379. *)
  380. func_extract_an_archive "$my_xdir" "$my_xabs"
  381. ;;
  382. esac
  383. my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
  384. done
  385. func_extract_archives_result="$my_oldobjs"
  386. }
  387. # End of Shell function definitions
  388. #####################################
  389. # Darwin sucks
  390. eval std_shrext=\"$shrext_cmds\"
  391. disable_libs=no
  392. # Parse our command line options once, thoroughly.
  393. while test "$#" -gt 0
  394. do
  395. arg="$1"
  396. shift
  397. case $arg in
  398. -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
  399. *) optarg= ;;
  400. esac
  401. # If the previous option needs an argument, assign it.
  402. if test -n "$prev"; then
  403. case $prev in
  404. execute_dlfiles)
  405. execute_dlfiles="$execute_dlfiles $arg"
  406. ;;
  407. tag)
  408. tagname="$arg"
  409. preserve_args="${preserve_args}=$arg"
  410. # Check whether tagname contains only valid characters
  411. case $tagname in
  412. *[!-_A-Za-z0-9,/]*)
  413. $echo "$progname: invalid tag name: $tagname" 1>&2
  414. exit $EXIT_FAILURE
  415. ;;
  416. esac
  417. case $tagname in
  418. CC)
  419. # Don't test for the "default" C tag, as we know, it's there, but
  420. # not specially marked.
  421. ;;
  422. *)
  423. if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
  424. taglist="$taglist $tagname"
  425. # Evaluate the configuration.
  426. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
  427. else
  428. $echo "$progname: ignoring unknown tag $tagname" 1>&2
  429. fi
  430. ;;
  431. esac
  432. ;;
  433. *)
  434. eval "$prev=\$arg"
  435. ;;
  436. esac
  437. prev=
  438. prevopt=
  439. continue
  440. fi
  441. # Have we seen a non-optional argument yet?
  442. case $arg in
  443. --help)
  444. show_help=yes
  445. ;;
  446. --version)
  447. echo "\
  448. $PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP
  449. Copyright (C) 2008 Free Software Foundation, Inc.
  450. This is free software; see the source for copying conditions. There is NO
  451. warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
  452. exit $?
  453. ;;
  454. --config)
  455. ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
  456. # Now print the configurations for the tags.
  457. for tagname in $taglist; do
  458. ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
  459. done
  460. exit $?
  461. ;;
  462. --debug)
  463. $echo "$progname: enabling shell trace mode"
  464. set -x
  465. preserve_args="$preserve_args $arg"
  466. ;;
  467. --dry-run | -n)
  468. run=:
  469. ;;
  470. --features)
  471. $echo "host: $host"
  472. if test "$build_libtool_libs" = yes; then
  473. $echo "enable shared libraries"
  474. else
  475. $echo "disable shared libraries"
  476. fi
  477. if test "$build_old_libs" = yes; then
  478. $echo "enable static libraries"
  479. else
  480. $echo "disable static libraries"
  481. fi
  482. exit $?
  483. ;;
  484. --finish) mode="finish" ;;
  485. --mode) prevopt="--mode" prev=mode ;;
  486. --mode=*) mode="$optarg" ;;
  487. --preserve-dup-deps) duplicate_deps="yes" ;;
  488. --quiet | --silent)
  489. show=:
  490. preserve_args="$preserve_args $arg"
  491. ;;
  492. --tag)
  493. prevopt="--tag"
  494. prev=tag
  495. preserve_args="$preserve_args --tag"
  496. ;;
  497. --tag=*)
  498. set tag "$optarg" ${1+"$@"}
  499. shift
  500. prev=tag
  501. preserve_args="$preserve_args --tag"
  502. ;;
  503. -dlopen)
  504. prevopt="-dlopen"
  505. prev=execute_dlfiles
  506. ;;
  507. -*)
  508. $echo "$modename: unrecognized option \`$arg'" 1>&2
  509. $echo "$help" 1>&2
  510. exit $EXIT_FAILURE
  511. ;;
  512. *)
  513. nonopt="$arg"
  514. break
  515. ;;
  516. esac
  517. done
  518. if test -n "$prevopt"; then
  519. $echo "$modename: option \`$prevopt' requires an argument" 1>&2
  520. $echo "$help" 1>&2
  521. exit $EXIT_FAILURE
  522. fi
  523. case $disable_libs in
  524. no)
  525. ;;
  526. shared)
  527. build_libtool_libs=no
  528. build_old_libs=yes
  529. ;;
  530. static)
  531. build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
  532. ;;
  533. esac
  534. # If this variable is set in any of the actions, the command in it
  535. # will be execed at the end. This prevents here-documents from being
  536. # left over by shells.
  537. exec_cmd=
  538. if test -z "$show_help"; then
  539. # Infer the operation mode.
  540. if test -z "$mode"; then
  541. $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
  542. $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
  543. case $nonopt in
  544. *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
  545. mode=link
  546. for arg
  547. do
  548. case $arg in
  549. -c)
  550. mode=compile
  551. break
  552. ;;
  553. esac
  554. done
  555. ;;
  556. *db | *dbx | *strace | *truss)
  557. mode=execute
  558. ;;
  559. *install*|cp|mv)
  560. mode=install
  561. ;;
  562. *rm)
  563. mode=uninstall
  564. ;;
  565. *)
  566. # If we have no mode, but dlfiles were specified, then do execute mode.
  567. test -n "$execute_dlfiles" && mode=execute
  568. # Just use the default operation mode.
  569. if test -z "$mode"; then
  570. if test -n "$nonopt"; then
  571. $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
  572. else
  573. $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
  574. fi
  575. fi
  576. ;;
  577. esac
  578. fi
  579. # Only execute mode is allowed to have -dlopen flags.
  580. if test -n "$execute_dlfiles" && test "$mode" != execute; then
  581. $echo "$modename: unrecognized option \`-dlopen'" 1>&2
  582. $echo "$help" 1>&2
  583. exit $EXIT_FAILURE
  584. fi
  585. # Change the help message to a mode-specific one.
  586. generic_help="$help"
  587. help="Try \`$modename --help --mode=$mode' for more information."
  588. # These modes are in order of execution frequency so that they run quickly.
  589. case $mode in
  590. # libtool compile mode
  591. compile)
  592. modename="$modename: compile"
  593. # Get the compilation command and the source file.
  594. base_compile=
  595. srcfile="$nonopt" # always keep a non-empty value in "srcfile"
  596. suppress_opt=yes
  597. suppress_output=
  598. arg_mode=normal
  599. libobj=
  600. later=
  601. for arg
  602. do
  603. case $arg_mode in
  604. arg )
  605. # do not "continue". Instead, add this to base_compile
  606. lastarg="$arg"
  607. arg_mode=normal
  608. ;;
  609. target )
  610. libobj="$arg"
  611. arg_mode=normal
  612. continue
  613. ;;
  614. normal )
  615. # Accept any command-line options.
  616. case $arg in
  617. -o)
  618. if test -n "$libobj" ; then
  619. $echo "$modename: you cannot specify \`-o' more than once" 1>&2
  620. exit $EXIT_FAILURE
  621. fi
  622. arg_mode=target
  623. continue
  624. ;;
  625. -static | -prefer-pic | -prefer-non-pic)
  626. later="$later $arg"
  627. continue
  628. ;;
  629. -no-suppress)
  630. suppress_opt=no
  631. continue
  632. ;;
  633. -Xcompiler)
  634. arg_mode=arg # the next one goes into the "base_compile" arg list
  635. continue # The current "srcfile" will either be retained or
  636. ;; # replaced later. I would guess that would be a bug.
  637. -Wc,*)
  638. args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
  639. lastarg=
  640. save_ifs="$IFS"; IFS=','
  641. for arg in $args; do
  642. IFS="$save_ifs"
  643. # Double-quote args containing other shell metacharacters.
  644. # Many Bourne shells cannot handle close brackets correctly
  645. # in scan sets, so we specify it separately.
  646. case $arg in
  647. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  648. arg="\"$arg\""
  649. ;;
  650. esac
  651. lastarg="$lastarg $arg"
  652. done
  653. IFS="$save_ifs"
  654. lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
  655. # Add the arguments to base_compile.
  656. base_compile="$base_compile $lastarg"
  657. continue
  658. ;;
  659. * )
  660. # Accept the current argument as the source file.
  661. # The previous "srcfile" becomes the current argument.
  662. #
  663. lastarg="$srcfile"
  664. srcfile="$arg"
  665. ;;
  666. esac # case $arg
  667. ;;
  668. esac # case $arg_mode
  669. # Aesthetically quote the previous argument.
  670. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
  671. case $lastarg in
  672. # Double-quote args containing other shell metacharacters.
  673. # Many Bourne shells cannot handle close brackets correctly
  674. # in scan sets, and some SunOS ksh mistreat backslash-escaping
  675. # in scan sets (worked around with variable expansion),
  676. # and furthermore cannot handle '|' '&' '(' ')' in scan sets
  677. # at all, so we specify them separately.
  678. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  679. lastarg="\"$lastarg\""
  680. ;;
  681. esac
  682. base_compile="$base_compile $lastarg"
  683. done # for arg
  684. case $arg_mode in
  685. arg)
  686. $echo "$modename: you must specify an argument for -Xcompile"
  687. exit $EXIT_FAILURE
  688. ;;
  689. target)
  690. $echo "$modename: you must specify a target with \`-o'" 1>&2
  691. exit $EXIT_FAILURE
  692. ;;
  693. *)
  694. # Get the name of the library object.
  695. [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
  696. ;;
  697. esac
  698. # Recognize several different file suffixes.
  699. # If the user specifies -o file.o, it is replaced with file.lo
  700. xform='[cCFSifmso]'
  701. case $libobj in
  702. *.ada) xform=ada ;;
  703. *.adb) xform=adb ;;
  704. *.ads) xform=ads ;;
  705. *.asm) xform=asm ;;
  706. *.c++) xform=c++ ;;
  707. *.cc) xform=cc ;;
  708. *.ii) xform=ii ;;
  709. *.class) xform=class ;;
  710. *.cpp) xform=cpp ;;
  711. *.cxx) xform=cxx ;;
  712. *.[fF][09]?) xform=[fF][09]. ;;
  713. *.for) xform=for ;;
  714. *.java) xform=java ;;
  715. *.obj) xform=obj ;;
  716. *.sx) xform=sx ;;
  717. esac
  718. libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
  719. case $libobj in
  720. *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
  721. *)
  722. $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
  723. exit $EXIT_FAILURE
  724. ;;
  725. esac
  726. func_infer_tag $base_compile
  727. for arg in $later; do
  728. case $arg in
  729. -static)
  730. build_old_libs=yes
  731. continue
  732. ;;
  733. -prefer-pic)
  734. pic_mode=yes
  735. continue
  736. ;;
  737. -prefer-non-pic)
  738. pic_mode=no
  739. continue
  740. ;;
  741. esac
  742. done
  743. qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
  744. case $qlibobj in
  745. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  746. qlibobj="\"$qlibobj\"" ;;
  747. esac
  748. test "X$libobj" != "X$qlibobj" \
  749. && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"' &()|`$[]' \
  750. && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
  751. objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
  752. xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
  753. if test "X$xdir" = "X$obj"; then
  754. xdir=
  755. else
  756. xdir=$xdir/
  757. fi
  758. lobj=${xdir}$objdir/$objname
  759. if test -z "$base_compile"; then
  760. $echo "$modename: you must specify a compilation command" 1>&2
  761. $echo "$help" 1>&2
  762. exit $EXIT_FAILURE
  763. fi
  764. # Delete any leftover library objects.
  765. if test "$build_old_libs" = yes; then
  766. removelist="$obj $lobj $libobj ${libobj}T"
  767. else
  768. removelist="$lobj $libobj ${libobj}T"
  769. fi
  770. $run $rm $removelist
  771. trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
  772. # On Cygwin there's no "real" PIC flag so we must build both object types
  773. case $host_os in
  774. cygwin* | mingw* | pw32* | os2*)
  775. pic_mode=default
  776. ;;
  777. esac
  778. if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
  779. # non-PIC code in shared libraries is not supported
  780. pic_mode=default
  781. fi
  782. # Calculate the filename of the output object if compiler does
  783. # not support -o with -c
  784. if test "$compiler_c_o" = no; then
  785. output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
  786. lockfile="$output_obj.lock"
  787. removelist="$removelist $output_obj $lockfile"
  788. trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
  789. else
  790. output_obj=
  791. need_locks=no
  792. lockfile=
  793. fi
  794. # Lock this critical section if it is needed
  795. # We use this script file to make the link, it avoids creating a new file
  796. if test "$need_locks" = yes; then
  797. until $run ln "$progpath" "$lockfile" 2>/dev/null; do
  798. $show "Waiting for $lockfile to be removed"
  799. sleep 2
  800. done
  801. elif test "$need_locks" = warn; then
  802. if test -f "$lockfile"; then
  803. $echo "\
  804. *** ERROR, $lockfile exists and contains:
  805. `cat $lockfile 2>/dev/null`
  806. This indicates that another process is trying to use the same
  807. temporary object file, and libtool could not work around it because
  808. your compiler does not support \`-c' and \`-o' together. If you
  809. repeat this compilation, it may succeed, by chance, but you had better
  810. avoid parallel builds (make -j) in this platform, or get a better
  811. compiler."
  812. $run $rm $removelist
  813. exit $EXIT_FAILURE
  814. fi
  815. $echo "$srcfile" > "$lockfile"
  816. fi
  817. if test -n "$fix_srcfile_path"; then
  818. eval srcfile=\"$fix_srcfile_path\"
  819. fi
  820. qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
  821. case $qsrcfile in
  822. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  823. qsrcfile="\"$qsrcfile\"" ;;
  824. esac
  825. $run $rm "$libobj" "${libobj}T"
  826. # Create a libtool object file (analogous to a ".la" file),
  827. # but don't create it if we're doing a dry run.
  828. test -z "$run" && cat > ${libobj}T <<EOF
  829. # $libobj - a libtool object file
  830. # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
  831. #
  832. # Please DO NOT delete this file!
  833. # It is necessary for linking the library.
  834. # Name of the PIC object.
  835. EOF
  836. # Only build a PIC object if we are building libtool libraries.
  837. if test "$build_libtool_libs" = yes; then
  838. # Without this assignment, base_compile gets emptied.
  839. fbsd_hideous_sh_bug=$base_compile
  840. if test "$pic_mode" != no; then
  841. command="$base_compile $qsrcfile $pic_flag"
  842. else
  843. # Don't build PIC code
  844. command="$base_compile $qsrcfile"
  845. fi
  846. if test ! -d "${xdir}$objdir"; then
  847. $show "$mkdir ${xdir}$objdir"
  848. $run $mkdir ${xdir}$objdir
  849. exit_status=$?
  850. if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
  851. exit $exit_status
  852. fi
  853. fi
  854. if test -z "$output_obj"; then
  855. # Place PIC objects in $objdir
  856. command="$command -o $lobj"
  857. fi
  858. $run $rm "$lobj" "$output_obj"
  859. $show "$command"
  860. if $run eval $lt_env "$command"; then :
  861. else
  862. test -n "$output_obj" && $run $rm $removelist
  863. exit $EXIT_FAILURE
  864. fi
  865. if test "$need_locks" = warn &&
  866. test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  867. $echo "\
  868. *** ERROR, $lockfile contains:
  869. `cat $lockfile 2>/dev/null`
  870. but it should contain:
  871. $srcfile
  872. This indicates that another process is trying to use the same
  873. temporary object file, and libtool could not work around it because
  874. your compiler does not support \`-c' and \`-o' together. If you
  875. repeat this compilation, it may succeed, by chance, but you had better
  876. avoid parallel builds (make -j) in this platform, or get a better
  877. compiler."
  878. $run $rm $removelist
  879. exit $EXIT_FAILURE
  880. fi
  881. # Just move the object if needed, then go on to compile the next one
  882. if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
  883. $show "$mv $output_obj $lobj"
  884. if $run $mv $output_obj $lobj; then :
  885. else
  886. error=$?
  887. $run $rm $removelist
  888. exit $error
  889. fi
  890. fi
  891. # Append the name of the PIC object to the libtool object file.
  892. test -z "$run" && cat >> ${libobj}T <<EOF
  893. pic_object='$objdir/$objname'
  894. EOF
  895. # Allow error messages only from the first compilation.
  896. if test "$suppress_opt" = yes; then
  897. suppress_output=' >/dev/null 2>&1'
  898. fi
  899. else
  900. # No PIC object so indicate it doesn't exist in the libtool
  901. # object file.
  902. test -z "$run" && cat >> ${libobj}T <<EOF
  903. pic_object=none
  904. EOF
  905. fi
  906. # Only build a position-dependent object if we build old libraries.
  907. if test "$build_old_libs" = yes; then
  908. if test "$pic_mode" != yes; then
  909. # Don't build PIC code
  910. command="$base_compile $qsrcfile"
  911. else
  912. command="$base_compile $qsrcfile $pic_flag"
  913. fi
  914. if test "$compiler_c_o" = yes; then
  915. command="$command -o $obj"
  916. fi
  917. # Suppress compiler output if we already did a PIC compilation.
  918. command="$command$suppress_output"
  919. $run $rm "$obj" "$output_obj"
  920. $show "$command"
  921. if $run eval $lt_env "$command"; then :
  922. else
  923. $run $rm $removelist
  924. exit $EXIT_FAILURE
  925. fi
  926. if test "$need_locks" = warn &&
  927. test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  928. $echo "\
  929. *** ERROR, $lockfile contains:
  930. `cat $lockfile 2>/dev/null`
  931. but it should contain:
  932. $srcfile
  933. This indicates that another process is trying to use the same
  934. temporary object file, and libtool could not work around it because
  935. your compiler does not support \`-c' and \`-o' together. If you
  936. repeat this compilation, it may succeed, by chance, but you had better
  937. avoid parallel builds (make -j) in this platform, or get a better
  938. compiler."
  939. $run $rm $removelist
  940. exit $EXIT_FAILURE
  941. fi
  942. # Just move the object if needed
  943. if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
  944. $show "$mv $output_obj $obj"
  945. if $run $mv $output_obj $obj; then :
  946. else
  947. error=$?
  948. $run $rm $removelist
  949. exit $error
  950. fi
  951. fi
  952. # Append the name of the non-PIC object the libtool object file.
  953. # Only append if the libtool object file exists.
  954. test -z "$run" && cat >> ${libobj}T <<EOF
  955. # Name of the non-PIC object.
  956. non_pic_object='$objname'
  957. EOF
  958. else
  959. # Append the name of the non-PIC object the libtool object file.
  960. # Only append if the libtool object file exists.
  961. test -z "$run" && cat >> ${libobj}T <<EOF
  962. # Name of the non-PIC object.
  963. non_pic_object=none
  964. EOF
  965. fi
  966. $run $mv "${libobj}T" "${libobj}"
  967. # Unlock the critical section if it was locked
  968. if test "$need_locks" != no; then
  969. $run $rm "$lockfile"
  970. fi
  971. exit $EXIT_SUCCESS
  972. ;;
  973. # libtool link mode
  974. link | relink)
  975. modename="$modename: link"
  976. case $host in
  977. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
  978. # It is impossible to link a dll without this setting, and
  979. # we shouldn't force the makefile maintainer to figure out
  980. # which system we are compiling for in order to pass an extra
  981. # flag for every libtool invocation.
  982. # allow_undefined=no
  983. # FIXME: Unfortunately, there are problems with the above when trying
  984. # to make a dll which has undefined symbols, in which case not
  985. # even a static library is built. For now, we need to specify
  986. # -no-undefined on the libtool link line when we can be certain
  987. # that all symbols are satisfied, otherwise we get a static library.
  988. allow_undefined=yes
  989. ;;
  990. *)
  991. allow_undefined=yes
  992. ;;
  993. esac
  994. libtool_args="$nonopt"
  995. base_compile="$nonopt $@"
  996. compile_command="$nonopt"
  997. finalize_command="$nonopt"
  998. compile_rpath=
  999. finalize_rpath=
  1000. compile_shlibpath=
  1001. finalize_shlibpath=
  1002. convenience=
  1003. old_convenience=
  1004. deplibs=
  1005. old_deplibs=
  1006. compiler_flags=
  1007. linker_flags=
  1008. dllsearchpath=
  1009. lib_search_path=`pwd`
  1010. inst_prefix_dir=
  1011. avoid_version=no
  1012. dlfiles=
  1013. dlprefiles=
  1014. dlself=no
  1015. export_dynamic=no
  1016. export_symbols=
  1017. export_symbols_regex=
  1018. generated=
  1019. libobjs=
  1020. ltlibs=
  1021. module=no
  1022. no_install=no
  1023. objs=
  1024. non_pic_objects=
  1025. notinst_path= # paths that contain not-installed libtool libraries
  1026. precious_files_regex=
  1027. prefer_static_libs=no
  1028. preload=no
  1029. prev=
  1030. prevarg=
  1031. release=
  1032. rpath=
  1033. xrpath=
  1034. perm_rpath=
  1035. temp_rpath=
  1036. thread_safe=no
  1037. vinfo=
  1038. vinfo_number=no
  1039. single_module="${wl}-single_module"
  1040. func_infer_tag $base_compile
  1041. # We need to know -static, to get the right output filenames.
  1042. for arg
  1043. do
  1044. case $arg in
  1045. -all-static | -static | -static-libtool-libs)
  1046. case $arg in
  1047. -all-static)
  1048. if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
  1049. $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
  1050. fi
  1051. if test -n "$link_static_flag"; then
  1052. dlopen_self=$dlopen_self_static
  1053. fi
  1054. prefer_static_libs=yes
  1055. ;;
  1056. -static)
  1057. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  1058. dlopen_self=$dlopen_self_static
  1059. fi
  1060. prefer_static_libs=built
  1061. ;;
  1062. -static-libtool-libs)
  1063. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  1064. dlopen_self=$dlopen_self_static
  1065. fi
  1066. prefer_static_libs=yes
  1067. ;;
  1068. esac
  1069. build_libtool_libs=no
  1070. build_old_libs=yes
  1071. break
  1072. ;;
  1073. esac
  1074. done
  1075. # See if our shared archives depend on static archives.
  1076. test -n "$old_archive_from_new_cmds" && build_old_libs=yes
  1077. # Go through the arguments, transforming them on the way.
  1078. while test "$#" -gt 0; do
  1079. arg="$1"
  1080. shift
  1081. case $arg in
  1082. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1083. qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
  1084. ;;
  1085. *) qarg=$arg ;;
  1086. esac
  1087. libtool_args="$libtool_args $qarg"
  1088. # If the previous option needs an argument, assign it.
  1089. if test -n "$prev"; then
  1090. case $prev in
  1091. output)
  1092. compile_command="$compile_command @OUTPUT@"
  1093. finalize_command="$finalize_command @OUTPUT@"
  1094. ;;
  1095. esac
  1096. case $prev in
  1097. dlfiles|dlprefiles)
  1098. if test "$preload" = no; then
  1099. # Add the symbol object into the linking commands.
  1100. compile_command="$compile_command @SYMFILE@"
  1101. finalize_command="$finalize_command @SYMFILE@"
  1102. preload=yes
  1103. fi
  1104. case $arg in
  1105. *.la | *.lo) ;; # We handle these cases below.
  1106. force)
  1107. if test "$dlself" = no; then
  1108. dlself=needless
  1109. export_dynamic=yes
  1110. fi
  1111. prev=
  1112. continue
  1113. ;;
  1114. self)
  1115. if test "$prev" = dlprefiles; then
  1116. dlself=yes
  1117. elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
  1118. dlself=yes
  1119. else
  1120. dlself=needless
  1121. export_dynamic=yes
  1122. fi
  1123. prev=
  1124. continue
  1125. ;;
  1126. *)
  1127. if test "$prev" = dlfiles; then
  1128. dlfiles="$dlfiles $arg"
  1129. else
  1130. dlprefiles="$dlprefiles $arg"
  1131. fi
  1132. prev=
  1133. continue
  1134. ;;
  1135. esac
  1136. ;;
  1137. expsyms)
  1138. export_symbols="$arg"
  1139. if test ! -f "$arg"; then
  1140. $echo "$modename: symbol file \`$arg' does not exist"
  1141. exit $EXIT_FAILURE
  1142. fi
  1143. prev=
  1144. continue
  1145. ;;
  1146. expsyms_regex)
  1147. export_symbols_regex="$arg"
  1148. prev=
  1149. continue
  1150. ;;
  1151. inst_prefix)
  1152. inst_prefix_dir="$arg"
  1153. prev=
  1154. continue
  1155. ;;
  1156. precious_regex)
  1157. precious_files_regex="$arg"
  1158. prev=
  1159. continue
  1160. ;;
  1161. release)
  1162. release="-$arg"
  1163. prev=
  1164. continue
  1165. ;;
  1166. objectlist)
  1167. if test -f "$arg"; then
  1168. save_arg=$arg
  1169. moreargs=
  1170. for fil in `cat $save_arg`
  1171. do
  1172. # moreargs="$moreargs $fil"
  1173. arg=$fil
  1174. # A libtool-controlled object.
  1175. # Check to see that this really is a libtool object.
  1176. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
  1177. pic_object=
  1178. non_pic_object=
  1179. # Read the .lo file
  1180. # If there is no directory component, then add one.
  1181. case $arg in
  1182. */* | *\\*) . $arg ;;
  1183. *) . ./$arg ;;
  1184. esac
  1185. if test -z "$pic_object" || \
  1186. test -z "$non_pic_object" ||
  1187. test "$pic_object" = none && \
  1188. test "$non_pic_object" = none; then
  1189. $echo "$modename: cannot find name of object for \`$arg'" 1>&2
  1190. exit $EXIT_FAILURE
  1191. fi
  1192. # Extract subdirectory from the argument.
  1193. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
  1194. if test "X$xdir" = "X$arg"; then
  1195. xdir=
  1196. else
  1197. xdir="$xdir/"
  1198. fi
  1199. if test "$pic_object" != none; then
  1200. # Prepend the subdirectory the object is found in.
  1201. pic_object="$xdir$pic_object"
  1202. if test "$prev" = dlfiles; then
  1203. if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
  1204. dlfiles="$dlfiles $pic_object"
  1205. prev=
  1206. continue
  1207. else
  1208. # If libtool objects are unsupported, then we need to preload.
  1209. prev=dlprefiles
  1210. fi
  1211. fi
  1212. # CHECK ME: I think I busted this. -Ossama
  1213. if test "$prev" = dlprefiles; then
  1214. # Preload the old-style object.
  1215. dlprefiles="$dlprefiles $pic_object"
  1216. prev=
  1217. fi
  1218. # A PIC object.
  1219. libobjs="$libobjs $pic_object"
  1220. arg="$pic_object"
  1221. fi
  1222. # Non-PIC object.
  1223. if test "$non_pic_object" != none; then
  1224. # Prepend the subdirectory the object is found in.
  1225. non_pic_object="$xdir$non_pic_object"
  1226. # A standard non-PIC object
  1227. non_pic_objects="$non_pic_objects $non_pic_object"
  1228. if test -z "$pic_object" || test "$pic_object" = none ; then
  1229. arg="$non_pic_object"
  1230. fi
  1231. else
  1232. # If the PIC object exists, use it instead.
  1233. # $xdir was prepended to $pic_object above.
  1234. non_pic_object="$pic_object"
  1235. non_pic_objects="$non_pic_objects $non_pic_object"
  1236. fi
  1237. else
  1238. # Only an error if not doing a dry-run.
  1239. if test -z "$run"; then
  1240. $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
  1241. exit $EXIT_FAILURE
  1242. else
  1243. # Dry-run case.
  1244. # Extract subdirectory from the argument.
  1245. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
  1246. if test "X$xdir" = "X$arg"; then
  1247. xdir=
  1248. else
  1249. xdir="$xdir/"
  1250. fi
  1251. pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
  1252. non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
  1253. libobjs="$libobjs $pic_object"
  1254. non_pic_objects="$non_pic_objects $non_pic_object"
  1255. fi
  1256. fi
  1257. done
  1258. else
  1259. $echo "$modename: link input file \`$save_arg' does not exist"
  1260. exit $EXIT_FAILURE
  1261. fi
  1262. arg=$save_arg
  1263. prev=
  1264. continue
  1265. ;;
  1266. rpath | xrpath)
  1267. # We need an absolute path.
  1268. case $arg in
  1269. [\\/]* | [A-Za-z]:[\\/]*) ;;
  1270. *)
  1271. $echo "$modename: only absolute run-paths are allowed" 1>&2
  1272. exit $EXIT_FAILURE
  1273. ;;
  1274. esac
  1275. if test "$prev" = rpath; then
  1276. case "$rpath " in
  1277. *" $arg "*) ;;
  1278. *) rpath="$rpath $arg" ;;
  1279. esac
  1280. else
  1281. case "$xrpath " in
  1282. *" $arg "*) ;;
  1283. *) xrpath="$xrpath $arg" ;;
  1284. esac
  1285. fi
  1286. prev=
  1287. continue
  1288. ;;
  1289. xcompiler)
  1290. compiler_flags="$compiler_flags $qarg"
  1291. prev=
  1292. compile_command="$compile_command $qarg"
  1293. finalize_command="$finalize_command $qarg"
  1294. continue
  1295. ;;
  1296. xlinker)
  1297. linker_flags="$linker_flags $qarg"
  1298. compiler_flags="$compiler_flags $wl$qarg"
  1299. prev=
  1300. compile_command="$compile_command $wl$qarg"
  1301. finalize_command="$finalize_command $wl$qarg"
  1302. continue
  1303. ;;
  1304. xcclinker)
  1305. linker_flags="$linker_flags $qarg"
  1306. compiler_flags="$compiler_flags $qarg"
  1307. prev=
  1308. compile_command="$compile_command $qarg"
  1309. finalize_command="$finalize_command $qarg"
  1310. continue
  1311. ;;
  1312. shrext)
  1313. shrext_cmds="$arg"
  1314. prev=
  1315. continue
  1316. ;;
  1317. darwin_framework|darwin_framework_skip)
  1318. test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
  1319. compile_command="$compile_command $arg"
  1320. finalize_command="$finalize_command $arg"
  1321. prev=
  1322. continue
  1323. ;;
  1324. *)
  1325. eval "$prev=\"\$arg\""
  1326. prev=
  1327. continue
  1328. ;;
  1329. esac
  1330. fi # test -n "$prev"
  1331. prevarg="$arg"
  1332. case $arg in
  1333. -all-static)
  1334. if test -n "$link_static_flag"; then
  1335. compile_command="$compile_command $link_static_flag"
  1336. finalize_command="$finalize_command $link_static_flag"
  1337. fi
  1338. continue
  1339. ;;
  1340. -allow-undefined)
  1341. # FIXME: remove this flag sometime in the future.
  1342. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
  1343. continue
  1344. ;;
  1345. -avoid-version)
  1346. avoid_version=yes
  1347. continue
  1348. ;;
  1349. -dlopen)
  1350. prev=dlfiles
  1351. continue
  1352. ;;
  1353. -dlpreopen)
  1354. prev=dlprefiles
  1355. continue
  1356. ;;
  1357. -export-dynamic)
  1358. export_dynamic=yes
  1359. continue
  1360. ;;
  1361. -export-symbols | -export-symbols-regex)
  1362. if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  1363. $echo "$modename: more than one -exported-symbols argument is not allowed"
  1364. exit $EXIT_FAILURE
  1365. fi
  1366. if test "X$arg" = "X-export-symbols"; then
  1367. prev=expsyms
  1368. else
  1369. prev=expsyms_regex
  1370. fi
  1371. continue
  1372. ;;
  1373. -framework|-arch|-isysroot)
  1374. case " $CC " in
  1375. *" ${arg} ${1} "* | *" ${arg} ${1} "*)
  1376. prev=darwin_framework_skip ;;
  1377. *) compiler_flags="$compiler_flags $arg"
  1378. prev=darwin_framework ;;
  1379. esac
  1380. compile_command="$compile_command $arg"
  1381. finalize_command="$finalize_command $arg"
  1382. continue
  1383. ;;
  1384. -inst-prefix-dir)
  1385. prev=inst_prefix
  1386. continue
  1387. ;;
  1388. # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
  1389. # so, if we see these flags be careful not to treat them like -L
  1390. -L[A-Z][A-Z]*:*)
  1391. case $with_gcc/$host in
  1392. no/*-*-irix* | /*-*-irix*)
  1393. compile_command="$compile_command $arg"
  1394. finalize_command="$finalize_command $arg"
  1395. ;;
  1396. esac
  1397. continue
  1398. ;;
  1399. -L*)
  1400. dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
  1401. # We need an absolute path.
  1402. case $dir in
  1403. [\\/]* | [A-Za-z]:[\\/]*) ;;
  1404. *)
  1405. absdir=`cd "$dir" && pwd`
  1406. if test -z "$absdir"; then
  1407. $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
  1408. absdir="$dir"
  1409. notinst_path="$notinst_path $dir"
  1410. fi
  1411. dir="$absdir"
  1412. ;;
  1413. esac
  1414. case "$deplibs " in
  1415. *" -L$dir "*) ;;
  1416. *)
  1417. deplibs="$deplibs -L$dir"
  1418. lib_search_path="$lib_search_path $dir"
  1419. ;;
  1420. esac
  1421. case $host in
  1422. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
  1423. testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
  1424. case :$dllsearchpath: in
  1425. *":$dir:"*) ;;
  1426. *) dllsearchpath="$dllsearchpath:$dir";;
  1427. esac
  1428. case :$dllsearchpath: in
  1429. *":$testbindir:"*) ;;
  1430. *) dllsearchpath="$dllsearchpath:$testbindir";;
  1431. esac
  1432. ;;
  1433. esac
  1434. continue
  1435. ;;
  1436. -l*)
  1437. if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
  1438. case $host in
  1439. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
  1440. # These systems don't actually have a C or math library (as such)
  1441. continue
  1442. ;;
  1443. *-*-os2*)
  1444. # These systems don't actually have a C library (as such)
  1445. test "X$arg" = "X-lc" && continue
  1446. ;;
  1447. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
  1448. # Do not include libc due to us having libc/libc_r.
  1449. test "X$arg" = "X-lc" && continue
  1450. ;;
  1451. *-*-rhapsody* | *-*-darwin1.[012])
  1452. # Rhapsody C and math libraries are in the System framework
  1453. deplibs="$deplibs -framework System"
  1454. continue
  1455. ;;
  1456. *-*-sco3.2v5* | *-*-sco5v6*)
  1457. # Causes problems with __ctype
  1458. test "X$arg" = "X-lc" && continue
  1459. ;;
  1460. *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
  1461. # Compiler inserts libc in the correct place for threads to work
  1462. test "X$arg" = "X-lc" && continue
  1463. ;;
  1464. esac
  1465. elif test "X$arg" = "X-lc_r"; then
  1466. case $host in
  1467. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
  1468. # Do not include libc_r directly, use -pthread flag.
  1469. continue
  1470. ;;
  1471. esac
  1472. fi
  1473. deplibs="$deplibs $arg"
  1474. continue
  1475. ;;
  1476. # Tru64 UNIX uses -model [arg] to determine the layout of C++
  1477. # classes, name mangling, and exception handling.
  1478. -model)
  1479. compile_command="$compile_command $arg"
  1480. compiler_flags="$compiler_flags $arg"
  1481. finalize_command="$finalize_command $arg"
  1482. prev=xcompiler
  1483. continue
  1484. ;;
  1485. -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
  1486. compiler_flags="$compiler_flags $arg"
  1487. compile_command="$compile_command $arg"
  1488. finalize_command="$finalize_command $arg"
  1489. continue
  1490. ;;
  1491. -multi_module)
  1492. single_module="${wl}-multi_module"
  1493. continue
  1494. ;;
  1495. -module)
  1496. module=yes
  1497. continue
  1498. ;;
  1499. # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
  1500. # -r[0-9][0-9]* specifies the processor on the SGI compiler
  1501. # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
  1502. # +DA*, +DD* enable 64-bit mode on the HP compiler
  1503. # -q* pass through compiler args for the IBM compiler
  1504. # -m* pass through architecture-specific compiler args for GCC
  1505. # -m*, -t[45]*, -txscale* pass through architecture-specific
  1506. # compiler args for GCC
  1507. # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
  1508. # -F/path gives path to uninstalled frameworks, gcc on darwin
  1509. # @file GCC response files
  1510. -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
  1511. -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
  1512. # Unknown arguments in both finalize_command and compile_command need
  1513. # to be aesthetically quoted because they are evaled later.
  1514. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
  1515. case $arg in
  1516. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1517. arg="\"$arg\""
  1518. ;;
  1519. esac
  1520. compile_command="$compile_command $arg"
  1521. finalize_command="$finalize_command $arg"
  1522. compiler_flags="$compiler_flags $arg"
  1523. continue
  1524. ;;
  1525. -shrext)
  1526. prev=shrext
  1527. continue
  1528. ;;
  1529. -no-fast-install)
  1530. fast_install=no
  1531. continue
  1532. ;;
  1533. -no-install)
  1534. case $host in
  1535. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin*)
  1536. # The PATH hackery in wrapper scripts is required on Windows
  1537. # and Darwin in order for the loader to find any dlls it needs.
  1538. $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
  1539. $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
  1540. fast_install=no
  1541. ;;
  1542. *) no_install=yes ;;
  1543. esac
  1544. continue
  1545. ;;
  1546. -no-undefined)
  1547. allow_undefined=no
  1548. continue
  1549. ;;
  1550. -objectlist)
  1551. prev=objectlist
  1552. continue
  1553. ;;
  1554. -o) prev=output ;;
  1555. -precious-files-regex)
  1556. prev=precious_regex
  1557. continue
  1558. ;;
  1559. -release)
  1560. prev=release
  1561. continue
  1562. ;;
  1563. -rpath)
  1564. prev=rpath
  1565. continue
  1566. ;;
  1567. -R)
  1568. prev=xrpath
  1569. continue
  1570. ;;
  1571. -R*)
  1572. dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
  1573. # We need an absolute path.
  1574. case $dir in
  1575. [\\/]* | [A-Za-z]:[\\/]*) ;;
  1576. *)
  1577. $echo "$modename: only absolute run-paths are allowed" 1>&2
  1578. exit $EXIT_FAILURE
  1579. ;;
  1580. esac
  1581. case "$xrpath " in
  1582. *" $dir "*) ;;
  1583. *) xrpath="$xrpath $dir" ;;
  1584. esac
  1585. continue
  1586. ;;
  1587. -static | -static-libtool-libs)
  1588. # The effects of -static are defined in a previous loop.
  1589. # We used to do the same as -all-static on platforms that
  1590. # didn't have a PIC flag, but the assumption that the effects
  1591. # would be equivalent was wrong. It would break on at least
  1592. # Digital Unix and AIX.
  1593. continue
  1594. ;;
  1595. -thread-safe)
  1596. thread_safe=yes
  1597. continue
  1598. ;;
  1599. -version-info)
  1600. prev=vinfo
  1601. continue
  1602. ;;
  1603. -version-number)
  1604. prev=vinfo
  1605. vinfo_number=yes
  1606. continue
  1607. ;;
  1608. -Wc,*)
  1609. args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
  1610. arg=
  1611. save_ifs="$IFS"; IFS=','
  1612. for flag in $args; do
  1613. IFS="$save_ifs"
  1614. case $flag in
  1615. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1616. flag="\"$flag\""
  1617. ;;
  1618. esac
  1619. arg="$arg $wl$flag"
  1620. compiler_flags="$compiler_flags $flag"
  1621. done
  1622. IFS="$save_ifs"
  1623. arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
  1624. ;;
  1625. -Wl,*)
  1626. args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
  1627. arg=
  1628. save_ifs="$IFS"; IFS=','
  1629. for flag in $args; do
  1630. IFS="$save_ifs"
  1631. case $flag in
  1632. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1633. flag="\"$flag\""
  1634. ;;
  1635. esac
  1636. arg="$arg $wl$flag"
  1637. compiler_flags="$compiler_flags $wl$flag"
  1638. linker_flags="$linker_flags $flag"
  1639. done
  1640. IFS="$save_ifs"
  1641. arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
  1642. ;;
  1643. -Xcompiler)
  1644. prev=xcompiler
  1645. continue
  1646. ;;
  1647. -Xlinker)
  1648. prev=xlinker
  1649. continue
  1650. ;;
  1651. -XCClinker)
  1652. prev=xcclinker
  1653. continue
  1654. ;;
  1655. # Some other compiler flag.
  1656. -* | +*)
  1657. # Unknown arguments in both finalize_command and compile_command need
  1658. # to be aesthetically quoted because they are evaled later.
  1659. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
  1660. case $arg in
  1661. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1662. arg="\"$arg\""
  1663. ;;
  1664. esac
  1665. ;;
  1666. *.$objext)
  1667. # A standard object.
  1668. objs="$objs $arg"
  1669. ;;
  1670. *.lo)
  1671. # A libtool-controlled object.
  1672. # Check to see that this really is a libtool object.
  1673. if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
  1674. pic_object=
  1675. non_pic_object=
  1676. # Read the .lo file
  1677. # If there is no directory component, then add one.
  1678. case $arg in
  1679. */* | *\\*) . $arg ;;
  1680. *) . ./$arg ;;
  1681. esac
  1682. if test -z "$pic_object" || \
  1683. test -z "$non_pic_object" ||
  1684. test "$pic_object" = none && \
  1685. test "$non_pic_object" = none; then
  1686. $echo "$modename: cannot find name of object for \`$arg'" 1>&2
  1687. exit $EXIT_FAILURE
  1688. fi
  1689. # Extract subdirectory from the argument.
  1690. xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
  1691. if test "X$xdir" = "X$arg"; then
  1692. xdir=
  1693. else
  1694. xdir="$xdir/"
  1695. fi
  1696. if test "$pic_object" != none; then
  1697. # Prepend the subdirectory the object is found in.
  1698. pic_object="$xdir$pic_object"
  1699. if test "$prev" = dlfiles; then
  1700. if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
  1701. dlfiles="$dlfiles $pic_object"
  1702. prev=
  1703. continue
  1704. else
  1705. # If libtool objects are unsupported, then we need to preload.
  1706. prev=dlprefiles
  1707. fi
  1708. fi
  1709. # CHECK ME: I think I busted this. -Ossama
  1710. if test "$prev" = dlprefiles; then
  1711. # Preload the old-style object.
  1712. dlprefiles="$dlprefiles $pic_object"
  1713. prev=
  1714. fi
  1715. # A PIC object.
  1716. libobjs="$libobjs $pic_object"
  1717. arg="$pic_object"
  1718. fi
  1719. # Non-PIC object.
  1720. if test "$non_pic_object" != none; then
  1721. # Prepend the subdirectory the object is found in.
  1722. non_pic_object="$xdir$non_pic_object"
  1723. # A standard non-PIC object
  1724. non_pic_objects="$non_pic_objects $non_pic_object"
  1725. if test -z "$pic_object" || test "$pic_object" = none ; then
  1726. arg="$non_pic_object"
  1727. fi
  1728. else
  1729. # If the PIC object exists, use it instead.
  1730. # $xdir was prepended to $pic_object above.
  1731. non_pic_object="$pic_object"
  1732. non_pic_objects="$non_pic_objects $non_pic_object"
  1733. fi
  1734. else
  1735. # Only an error if not doing a dry-run.
  1736. if test -z "$ru…