PageRenderTime 1678ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

/src/freebsd/contrib/gdb/ltmain.sh

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