PageRenderTime 63ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/tags/sdcc-290-pre1/binutils-avr/ltmain.sh

#
Shell | 2411 lines | 1932 code | 150 blank | 329 comment | 214 complexity | cc7bda19cf9102b71839b39684d536f8 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, LGPL-2.1, GPL-3.0
  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-1999 Free Software Foundation, Inc.
  5. # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. #
  21. # As a special exception to the GNU General Public License, if you
  22. # distribute this file as part of a program that contains a
  23. # configuration script generated by Autoconf, you may include it under
  24. # the same distribution terms that you use for the rest of that program.
  25. # Check that we have a working $echo.
  26. if test "X$1" = X--no-reexec; then
  27. # Discard the --no-reexec flag, and continue.
  28. shift
  29. elif test "X$1" = X--fallback-echo; then
  30. # Avoid inline document here, it may be left over
  31. :
  32. elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
  33. # Yippee, $echo works!
  34. :
  35. else
  36. # Restart under the correct shell, and then maybe $echo will work.
  37. exec $SHELL "$0" --no-reexec ${1+"$@"}
  38. fi
  39. if test "X$1" = X--fallback-echo; then
  40. # used as fallback echo
  41. shift
  42. cat <<EOF
  43. $*
  44. EOF
  45. exit 0
  46. fi
  47. # The name of this program.
  48. progname=`$echo "$0" | sed 's%^.*/%%'`
  49. modename="$progname"
  50. # Constants.
  51. PROGRAM=ltmain.sh
  52. PACKAGE=libtool
  53. VERSION=1.3.2
  54. TIMESTAMP=" (1.385.2.150 1999/05/26 00:28:32)"
  55. default_mode=
  56. help="Try \`$progname --help' for more information."
  57. magic="%%%MAGIC variable%%%"
  58. mkdir="mkdir"
  59. mv="mv -f"
  60. rm="rm -f"
  61. # Sed substitution that helps us do robust quoting. It backslashifies
  62. # metacharacters that are still active within double-quoted strings.
  63. Xsed='sed -e 1s/^X//'
  64. sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
  65. SP2NL='tr \040 \012'
  66. NL2SP='tr \012 \040'
  67. # NLS nuisances.
  68. # Only set LANG and LC_ALL to C if already set.
  69. # These must not be set unconditionally because not all systems understand
  70. # e.g. LANG=C (notably SCO).
  71. # We save the old values to restore during execute mode.
  72. if test "${LC_ALL+set}" = set; then
  73. save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
  74. fi
  75. if test "${LANG+set}" = set; then
  76. save_LANG="$LANG"; LANG=C; export LANG
  77. fi
  78. if test "$LTCONFIG_VERSION" != "$VERSION"; then
  79. echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2
  80. echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
  81. exit 1
  82. fi
  83. if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
  84. echo "$modename: not configured to build any kind of library" 1>&2
  85. echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
  86. exit 1
  87. fi
  88. # Global variables.
  89. mode=$default_mode
  90. nonopt=
  91. prev=
  92. prevopt=
  93. run=
  94. show="$echo"
  95. show_help=
  96. execute_dlfiles=
  97. lo2o="s/\\.lo\$/.${objext}/"
  98. o2lo="s/\\.${objext}\$/.lo/"
  99. # Parse our command line options once, thoroughly.
  100. while test $# -gt 0
  101. do
  102. arg="$1"
  103. shift
  104. case "$arg" in
  105. -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
  106. *) optarg= ;;
  107. esac
  108. # If the previous option needs an argument, assign it.
  109. if test -n "$prev"; then
  110. case "$prev" in
  111. execute_dlfiles)
  112. eval "$prev=\"\$$prev \$arg\""
  113. ;;
  114. *)
  115. eval "$prev=\$arg"
  116. ;;
  117. esac
  118. prev=
  119. prevopt=
  120. continue
  121. fi
  122. # Have we seen a non-optional argument yet?
  123. case "$arg" in
  124. --help)
  125. show_help=yes
  126. ;;
  127. --version)
  128. echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
  129. exit 0
  130. ;;
  131. --config)
  132. sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0
  133. exit 0
  134. ;;
  135. --debug)
  136. echo "$progname: enabling shell trace mode"
  137. set -x
  138. ;;
  139. --dry-run | -n)
  140. run=:
  141. ;;
  142. --features)
  143. echo "host: $host"
  144. if test "$build_libtool_libs" = yes; then
  145. echo "enable shared libraries"
  146. else
  147. echo "disable shared libraries"
  148. fi
  149. if test "$build_old_libs" = yes; then
  150. echo "enable static libraries"
  151. else
  152. echo "disable static libraries"
  153. fi
  154. exit 0
  155. ;;
  156. --finish) mode="finish" ;;
  157. --mode) prevopt="--mode" prev=mode ;;
  158. --mode=*) mode="$optarg" ;;
  159. --quiet | --silent)
  160. show=:
  161. ;;
  162. -dlopen)
  163. prevopt="-dlopen"
  164. prev=execute_dlfiles
  165. ;;
  166. -*)
  167. $echo "$modename: unrecognized option \`$arg'" 1>&2
  168. $echo "$help" 1>&2
  169. exit 1
  170. ;;
  171. *)
  172. nonopt="$arg"
  173. break
  174. ;;
  175. esac
  176. done
  177. if test -n "$prevopt"; then
  178. $echo "$modename: option \`$prevopt' requires an argument" 1>&2
  179. $echo "$help" 1>&2
  180. exit 1
  181. fi
  182. if test -z "$show_help"; then
  183. # Infer the operation mode.
  184. if test -z "$mode"; then
  185. case "$nonopt" in
  186. *cc | *++ | gcc* | *-gcc*)
  187. mode=link
  188. for arg
  189. do
  190. case "$arg" in
  191. -c)
  192. mode=compile
  193. break
  194. ;;
  195. esac
  196. done
  197. ;;
  198. *db | *dbx | *strace | *truss)
  199. mode=execute
  200. ;;
  201. *install*|cp|mv)
  202. mode=install
  203. ;;
  204. *rm)
  205. mode=uninstall
  206. ;;
  207. *)
  208. # If we have no mode, but dlfiles were specified, then do execute mode.
  209. test -n "$execute_dlfiles" && mode=execute
  210. # Just use the default operation mode.
  211. if test -z "$mode"; then
  212. if test -n "$nonopt"; then
  213. $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
  214. else
  215. $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
  216. fi
  217. fi
  218. ;;
  219. esac
  220. fi
  221. # Only execute mode is allowed to have -dlopen flags.
  222. if test -n "$execute_dlfiles" && test "$mode" != execute; then
  223. $echo "$modename: unrecognized option \`-dlopen'" 1>&2
  224. $echo "$help" 1>&2
  225. exit 1
  226. fi
  227. # Change the help message to a mode-specific one.
  228. generic_help="$help"
  229. help="Try \`$modename --help --mode=$mode' for more information."
  230. # These modes are in order of execution frequency so that they run quickly.
  231. case "$mode" in
  232. # libtool compile mode
  233. compile)
  234. modename="$modename: compile"
  235. # Get the compilation command and the source file.
  236. base_compile=
  237. lastarg=
  238. srcfile="$nonopt"
  239. suppress_output=
  240. user_target=no
  241. for arg
  242. do
  243. # Accept any command-line options.
  244. case "$arg" in
  245. -o)
  246. if test "$user_target" != "no"; then
  247. $echo "$modename: you cannot specify \`-o' more than once" 1>&2
  248. exit 1
  249. fi
  250. user_target=next
  251. ;;
  252. -static)
  253. build_old_libs=yes
  254. continue
  255. ;;
  256. esac
  257. case "$user_target" in
  258. next)
  259. # The next one is the -o target name
  260. user_target=yes
  261. continue
  262. ;;
  263. yes)
  264. # We got the output file
  265. user_target=set
  266. libobj="$arg"
  267. continue
  268. ;;
  269. esac
  270. # Accept the current argument as the source file.
  271. lastarg="$srcfile"
  272. srcfile="$arg"
  273. # Aesthetically quote the previous argument.
  274. # Backslashify any backslashes, double quotes, and dollar signs.
  275. # These are the only characters that are still specially
  276. # interpreted inside of double-quoted scrings.
  277. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
  278. # Double-quote args containing other shell metacharacters.
  279. # Many Bourne shells cannot handle close brackets correctly in scan
  280. # sets, so we specify it separately.
  281. case "$lastarg" in
  282. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
  283. lastarg="\"$lastarg\""
  284. ;;
  285. esac
  286. # Add the previous argument to base_compile.
  287. if test -z "$base_compile"; then
  288. base_compile="$lastarg"
  289. else
  290. base_compile="$base_compile $lastarg"
  291. fi
  292. done
  293. case "$user_target" in
  294. set)
  295. ;;
  296. no)
  297. # Get the name of the library object.
  298. libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
  299. ;;
  300. *)
  301. $echo "$modename: you must specify a target with \`-o'" 1>&2
  302. exit 1
  303. ;;
  304. esac
  305. # Recognize several different file suffixes.
  306. # If the user specifies -o file.o, it is replaced with file.lo
  307. xform='[cCFSfmso]'
  308. case "$libobj" in
  309. *.ada) xform=ada ;;
  310. *.adb) xform=adb ;;
  311. *.ads) xform=ads ;;
  312. *.asm) xform=asm ;;
  313. *.c++) xform=c++ ;;
  314. *.cc) xform=cc ;;
  315. *.cpp) xform=cpp ;;
  316. *.cxx) xform=cxx ;;
  317. *.f90) xform=f90 ;;
  318. *.for) xform=for ;;
  319. esac
  320. libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
  321. case "$libobj" in
  322. *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
  323. *)
  324. $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
  325. exit 1
  326. ;;
  327. esac
  328. if test -z "$base_compile"; then
  329. $echo "$modename: you must specify a compilation command" 1>&2
  330. $echo "$help" 1>&2
  331. exit 1
  332. fi
  333. # Delete any leftover library objects.
  334. if test "$build_old_libs" = yes; then
  335. removelist="$obj $libobj"
  336. else
  337. removelist="$libobj"
  338. fi
  339. $run $rm $removelist
  340. trap "$run $rm $removelist; exit 1" 1 2 15
  341. # Calculate the filename of the output object if compiler does
  342. # not support -o with -c
  343. if test "$compiler_c_o" = no; then
  344. output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext}
  345. lockfile="$output_obj.lock"
  346. removelist="$removelist $output_obj $lockfile"
  347. trap "$run $rm $removelist; exit 1" 1 2 15
  348. else
  349. need_locks=no
  350. lockfile=
  351. fi
  352. # Lock this critical section if it is needed
  353. # We use this script file to make the link, it avoids creating a new file
  354. if test "$need_locks" = yes; then
  355. until ln "$0" "$lockfile" 2>/dev/null; do
  356. $show "Waiting for $lockfile to be removed"
  357. sleep 2
  358. done
  359. elif test "$need_locks" = warn; then
  360. if test -f "$lockfile"; then
  361. echo "\
  362. *** ERROR, $lockfile exists and contains:
  363. `cat $lockfile 2>/dev/null`
  364. This indicates that another process is trying to use the same
  365. temporary object file, and libtool could not work around it because
  366. your compiler does not support \`-c' and \`-o' together. If you
  367. repeat this compilation, it may succeed, by chance, but you had better
  368. avoid parallel builds (make -j) in this platform, or get a better
  369. compiler."
  370. $run $rm $removelist
  371. exit 1
  372. fi
  373. echo $srcfile > "$lockfile"
  374. fi
  375. if test -n "$fix_srcfile_path"; then
  376. eval srcfile=\"$fix_srcfile_path\"
  377. fi
  378. # Only build a PIC object if we are building libtool libraries.
  379. if test "$build_libtool_libs" = yes; then
  380. # Without this assignment, base_compile gets emptied.
  381. fbsd_hideous_sh_bug=$base_compile
  382. # All platforms use -DPIC, to notify preprocessed assembler code.
  383. command="$base_compile $pic_flag -DPIC $srcfile"
  384. if test "$build_old_libs" = yes; then
  385. lo_libobj="$libobj"
  386. dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
  387. if test "X$dir" = "X$libobj"; then
  388. dir="$objdir"
  389. else
  390. dir="$dir/$objdir"
  391. fi
  392. libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
  393. if test -d "$dir"; then
  394. $show "$rm $libobj"
  395. $run $rm $libobj
  396. else
  397. $show "$mkdir $dir"
  398. $run $mkdir $dir
  399. status=$?
  400. if test $status -ne 0 && test ! -d $dir; then
  401. exit $status
  402. fi
  403. fi
  404. fi
  405. if test "$compiler_o_lo" = yes; then
  406. output_obj="$libobj"
  407. command="$command -o $output_obj"
  408. elif test "$compiler_c_o" = yes; then
  409. output_obj="$obj"
  410. command="$command -o $output_obj"
  411. fi
  412. $run $rm "$output_obj"
  413. $show "$command"
  414. if $run eval "$command"; then :
  415. else
  416. test -n "$output_obj" && $run $rm $removelist
  417. exit 1
  418. fi
  419. if test "$need_locks" = warn &&
  420. test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
  421. echo "\
  422. *** ERROR, $lockfile contains:
  423. `cat $lockfile 2>/dev/null`
  424. but it should contain:
  425. $srcfile
  426. This indicates that another process is trying to use the same
  427. temporary object file, and libtool could not work around it because
  428. your compiler does not support \`-c' and \`-o' together. If you
  429. repeat this compilation, it may succeed, by chance, but you had better
  430. avoid parallel builds (make -j) in this platform, or get a better
  431. compiler."
  432. $run $rm $removelist
  433. exit 1
  434. fi
  435. # Just move the object if needed, then go on to compile the next one
  436. if test x"$output_obj" != x"$libobj"; then
  437. $show "$mv $output_obj $libobj"
  438. if $run $mv $output_obj $libobj; then :
  439. else
  440. error=$?
  441. $run $rm $removelist
  442. exit $error
  443. fi
  444. fi
  445. # If we have no pic_flag, then copy the object into place and finish.
  446. if test -z "$pic_flag" && test "$build_old_libs" = yes; then
  447. # Rename the .lo from within objdir to obj
  448. if test -f $obj; then
  449. $show $rm $obj
  450. $run $rm $obj
  451. fi
  452. $show "$mv $libobj $obj"
  453. if $run $mv $libobj $obj; then :
  454. else
  455. error=$?
  456. $run $rm $removelist
  457. exit $error
  458. fi
  459. # Now arrange that obj and lo_libobj become the same file
  460. $show "$LN_S $obj $lo_libobj"
  461. if $run $LN_S $obj $lo_libobj; then
  462. exit 0
  463. else
  464. error=$?
  465. $run $rm $removelist
  466. exit $error
  467. fi
  468. fi
  469. # Allow error messages only from the first compilation.
  470. suppress_output=' >/dev/null 2>&1'
  471. fi
  472. # Only build a position-dependent object if we build old libraries.
  473. if test "$build_old_libs" = yes; then
  474. command="$base_compile $srcfile"
  475. if test "$compiler_c_o" = yes; then
  476. command="$command -o $obj"
  477. output_obj="$obj"
  478. fi
  479. # Suppress compiler output if we already did a PIC compilation.
  480. command="$command$suppress_output"
  481. $run $rm "$output_obj"
  482. $show "$command"
  483. if $run eval "$command"; then :
  484. else
  485. $run $rm $removelist
  486. exit 1
  487. fi
  488. if test "$need_locks" = warn &&
  489. test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
  490. echo "\
  491. *** ERROR, $lockfile contains:
  492. `cat $lockfile 2>/dev/null`
  493. but it should contain:
  494. $srcfile
  495. This indicates that another process is trying to use the same
  496. temporary object file, and libtool could not work around it because
  497. your compiler does not support \`-c' and \`-o' together. If you
  498. repeat this compilation, it may succeed, by chance, but you had better
  499. avoid parallel builds (make -j) in this platform, or get a better
  500. compiler."
  501. $run $rm $removelist
  502. exit 1
  503. fi
  504. # Just move the object if needed
  505. if test x"$output_obj" != x"$obj"; then
  506. $show "$mv $output_obj $obj"
  507. if $run $mv $output_obj $obj; then :
  508. else
  509. error=$?
  510. $run $rm $removelist
  511. exit $error
  512. fi
  513. fi
  514. # Create an invalid libtool object if no PIC, so that we do not
  515. # accidentally link it into a program.
  516. if test "$build_libtool_libs" != yes; then
  517. $show "echo timestamp > $libobj"
  518. $run eval "echo timestamp > \$libobj" || exit $?
  519. else
  520. # Move the .lo from within objdir
  521. $show "$mv $libobj $lo_libobj"
  522. if $run $mv $libobj $lo_libobj; then :
  523. else
  524. error=$?
  525. $run $rm $removelist
  526. exit $error
  527. fi
  528. fi
  529. fi
  530. # Unlock the critical section if it was locked
  531. if test "$need_locks" != no; then
  532. $rm "$lockfile"
  533. fi
  534. exit 0
  535. ;;
  536. # libtool link mode
  537. link)
  538. modename="$modename: link"
  539. C_compiler="$CC" # save it, to compile generated C sources
  540. CC="$nonopt"
  541. case "$host" in
  542. *-*-cygwin* | *-*-mingw* | *-*-os2*)
  543. # It is impossible to link a dll without this setting, and
  544. # we shouldn't force the makefile maintainer to figure out
  545. # which system we are compiling for in order to pass an extra
  546. # flag for every libtool invokation.
  547. # allow_undefined=no
  548. # FIXME: Unfortunately, there are problems with the above when trying
  549. # to make a dll which has undefined symbols, in which case not
  550. # even a static library is built. For now, we need to specify
  551. # -no-undefined on the libtool link line when we can be certain
  552. # that all symbols are satisfied, otherwise we get a static library.
  553. allow_undefined=yes
  554. # This is a source program that is used to create dlls on Windows
  555. # Don't remove nor modify the starting and closing comments
  556. # /* ltdll.c starts here */
  557. # #define WIN32_LEAN_AND_MEAN
  558. # #include <windows.h>
  559. # #undef WIN32_LEAN_AND_MEAN
  560. # #include <stdio.h>
  561. #
  562. # #ifdef __cplusplus
  563. # extern "C" {
  564. # #endif
  565. # BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
  566. # #ifdef __cplusplus
  567. # }
  568. # #endif
  569. #
  570. # #include <cygwin/cygwin_dll.h>
  571. # DECLARE_CYGWIN_DLL( DllMain );
  572. # HINSTANCE __hDllInstance_base;
  573. #
  574. # BOOL APIENTRY
  575. # DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
  576. # {
  577. # __hDllInstance_base = hInst;
  578. # return TRUE;
  579. # }
  580. # /* ltdll.c ends here */
  581. # This is a source program that is used to create import libraries
  582. # on Windows for dlls which lack them. Don't remove nor modify the
  583. # starting and closing comments
  584. # /* impgen.c starts here */
  585. # /* Copyright (C) 1999 Free Software Foundation, Inc.
  586. #
  587. # This file is part of GNU libtool.
  588. #
  589. # This program is free software; you can redistribute it and/or modify
  590. # it under the terms of the GNU General Public License as published by
  591. # the Free Software Foundation; either version 2 of the License, or
  592. # (at your option) any later version.
  593. #
  594. # This program is distributed in the hope that it will be useful,
  595. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  596. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  597. # GNU General Public License for more details.
  598. #
  599. # You should have received a copy of the GNU General Public License
  600. # along with this program; if not, write to the Free Software
  601. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  602. # */
  603. #
  604. # #include <stdio.h> /* for printf() */
  605. # #include <unistd.h> /* for open(), lseek(), read() */
  606. # #include <fcntl.h> /* for O_RDONLY, O_BINARY */
  607. # #include <string.h> /* for strdup() */
  608. #
  609. # static unsigned int
  610. # pe_get16 (fd, offset)
  611. # int fd;
  612. # int offset;
  613. # {
  614. # unsigned char b[2];
  615. # lseek (fd, offset, SEEK_SET);
  616. # read (fd, b, 2);
  617. # return b[0] + (b[1]<<8);
  618. # }
  619. #
  620. # static unsigned int
  621. # pe_get32 (fd, offset)
  622. # int fd;
  623. # int offset;
  624. # {
  625. # unsigned char b[4];
  626. # lseek (fd, offset, SEEK_SET);
  627. # read (fd, b, 4);
  628. # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
  629. # }
  630. #
  631. # static unsigned int
  632. # pe_as32 (ptr)
  633. # void *ptr;
  634. # {
  635. # unsigned char *b = ptr;
  636. # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
  637. # }
  638. #
  639. # int
  640. # main (argc, argv)
  641. # int argc;
  642. # char *argv[];
  643. # {
  644. # int dll;
  645. # unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
  646. # unsigned long export_rva, export_size, nsections, secptr, expptr;
  647. # unsigned long name_rvas, nexp;
  648. # unsigned char *expdata, *erva;
  649. # char *filename, *dll_name;
  650. #
  651. # filename = argv[1];
  652. #
  653. # dll = open(filename, O_RDONLY|O_BINARY);
  654. # if (!dll)
  655. # return 1;
  656. #
  657. # dll_name = filename;
  658. #
  659. # for (i=0; filename[i]; i++)
  660. # if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':')
  661. # dll_name = filename + i +1;
  662. #
  663. # pe_header_offset = pe_get32 (dll, 0x3c);
  664. # opthdr_ofs = pe_header_offset + 4 + 20;
  665. # num_entries = pe_get32 (dll, opthdr_ofs + 92);
  666. #
  667. # if (num_entries < 1) /* no exports */
  668. # return 1;
  669. #
  670. # export_rva = pe_get32 (dll, opthdr_ofs + 96);
  671. # export_size = pe_get32 (dll, opthdr_ofs + 100);
  672. # nsections = pe_get16 (dll, pe_header_offset + 4 +2);
  673. # secptr = (pe_header_offset + 4 + 20 +
  674. # pe_get16 (dll, pe_header_offset + 4 + 16));
  675. #
  676. # expptr = 0;
  677. # for (i = 0; i < nsections; i++)
  678. # {
  679. # char sname[8];
  680. # unsigned long secptr1 = secptr + 40 * i;
  681. # unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
  682. # unsigned long vsize = pe_get32 (dll, secptr1 + 16);
  683. # unsigned long fptr = pe_get32 (dll, secptr1 + 20);
  684. # lseek(dll, secptr1, SEEK_SET);
  685. # read(dll, sname, 8);
  686. # if (vaddr <= export_rva && vaddr+vsize > export_rva)
  687. # {
  688. # expptr = fptr + (export_rva - vaddr);
  689. # if (export_rva + export_size > vaddr + vsize)
  690. # export_size = vsize - (export_rva - vaddr);
  691. # break;
  692. # }
  693. # }
  694. #
  695. # expdata = (unsigned char*)malloc(export_size);
  696. # lseek (dll, expptr, SEEK_SET);
  697. # read (dll, expdata, export_size);
  698. # erva = expdata - export_rva;
  699. #
  700. # nexp = pe_as32 (expdata+24);
  701. # name_rvas = pe_as32 (expdata+32);
  702. #
  703. # printf ("EXPORTS\n");
  704. # for (i = 0; i<nexp; i++)
  705. # {
  706. # unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
  707. # printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
  708. # }
  709. #
  710. # return 0;
  711. # }
  712. # /* impgen.c ends here */
  713. ;;
  714. *)
  715. allow_undefined=yes
  716. ;;
  717. esac
  718. compile_command="$CC"
  719. finalize_command="$CC"
  720. compile_rpath=
  721. finalize_rpath=
  722. compile_shlibpath=
  723. finalize_shlibpath=
  724. convenience=
  725. old_convenience=
  726. deplibs=
  727. linkopts=
  728. if test -n "$shlibpath_var"; then
  729. # get the directories listed in $shlibpath_var
  730. eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
  731. else
  732. lib_search_path=
  733. fi
  734. # now prepend the system-specific ones
  735. eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\"
  736. eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
  737. avoid_version=no
  738. dlfiles=
  739. dlprefiles=
  740. dlself=no
  741. export_dynamic=no
  742. export_symbols=
  743. export_symbols_regex=
  744. generated=
  745. libobjs=
  746. link_against_libtool_libs=
  747. ltlibs=
  748. module=no
  749. objs=
  750. prefer_static_libs=no
  751. preload=no
  752. prev=
  753. prevarg=
  754. release=
  755. rpath=
  756. xrpath=
  757. perm_rpath=
  758. temp_rpath=
  759. thread_safe=no
  760. vinfo=
  761. # We need to know -static, to get the right output filenames.
  762. for arg
  763. do
  764. case "$arg" in
  765. -all-static | -static)
  766. if test "X$arg" = "X-all-static"; then
  767. if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
  768. $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
  769. fi
  770. if test -n "$link_static_flag"; then
  771. dlopen_self=$dlopen_self_static
  772. fi
  773. else
  774. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  775. dlopen_self=$dlopen_self_static
  776. fi
  777. fi
  778. build_libtool_libs=no
  779. build_old_libs=yes
  780. prefer_static_libs=yes
  781. break
  782. ;;
  783. esac
  784. done
  785. # See if our shared archives depend on static archives.
  786. test -n "$old_archive_from_new_cmds" && build_old_libs=yes
  787. # Go through the arguments, transforming them on the way.
  788. while test $# -gt 0; do
  789. arg="$1"
  790. shift
  791. # If the previous option needs an argument, assign it.
  792. if test -n "$prev"; then
  793. case "$prev" in
  794. output)
  795. compile_command="$compile_command @OUTPUT@"
  796. finalize_command="$finalize_command @OUTPUT@"
  797. ;;
  798. esac
  799. case "$prev" in
  800. dlfiles|dlprefiles)
  801. if test "$preload" = no; then
  802. # Add the symbol object into the linking commands.
  803. compile_command="$compile_command @SYMFILE@"
  804. finalize_command="$finalize_command @SYMFILE@"
  805. preload=yes
  806. fi
  807. case "$arg" in
  808. *.la | *.lo) ;; # We handle these cases below.
  809. self)
  810. if test "$prev" = dlprefiles; then
  811. dlself=yes
  812. elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
  813. dlself=yes
  814. else
  815. dlself=needless
  816. export_dynamic=yes
  817. fi
  818. prev=
  819. continue
  820. ;;
  821. *)
  822. if test "$prev" = dlfiles; then
  823. dlfiles="$dlfiles $arg"
  824. else
  825. dlprefiles="$dlprefiles $arg"
  826. fi
  827. prev=
  828. ;;
  829. esac
  830. ;;
  831. expsyms)
  832. export_symbols="$arg"
  833. if test ! -f "$arg"; then
  834. $echo "$modename: symbol file \`$arg' does not exist"
  835. exit 1
  836. fi
  837. prev=
  838. continue
  839. ;;
  840. expsyms_regex)
  841. export_symbols_regex="$arg"
  842. prev=
  843. continue
  844. ;;
  845. release)
  846. release="-$arg"
  847. prev=
  848. continue
  849. ;;
  850. rpath | xrpath)
  851. # We need an absolute path.
  852. case "$arg" in
  853. [\\/]* | [A-Za-z]:[\\/]*) ;;
  854. *)
  855. $echo "$modename: only absolute run-paths are allowed" 1>&2
  856. exit 1
  857. ;;
  858. esac
  859. if test "$prev" = rpath; then
  860. case "$rpath " in
  861. *" $arg "*) ;;
  862. *) rpath="$rpath $arg" ;;
  863. esac
  864. else
  865. case "$xrpath " in
  866. *" $arg "*) ;;
  867. *) xrpath="$xrpath $arg" ;;
  868. esac
  869. fi
  870. prev=
  871. continue
  872. ;;
  873. *)
  874. eval "$prev=\"\$arg\""
  875. prev=
  876. continue
  877. ;;
  878. esac
  879. fi
  880. prevarg="$arg"
  881. case "$arg" in
  882. -all-static)
  883. if test -n "$link_static_flag"; then
  884. compile_command="$compile_command $link_static_flag"
  885. finalize_command="$finalize_command $link_static_flag"
  886. fi
  887. continue
  888. ;;
  889. -allow-undefined)
  890. # FIXME: remove this flag sometime in the future.
  891. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
  892. continue
  893. ;;
  894. -avoid-version)
  895. avoid_version=yes
  896. continue
  897. ;;
  898. -dlopen)
  899. prev=dlfiles
  900. continue
  901. ;;
  902. -dlpreopen)
  903. prev=dlprefiles
  904. continue
  905. ;;
  906. -export-dynamic)
  907. export_dynamic=yes
  908. continue
  909. ;;
  910. -export-symbols | -export-symbols-regex)
  911. if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  912. $echo "$modename: not more than one -exported-symbols argument allowed"
  913. exit 1
  914. fi
  915. if test "X$arg" = "X-export-symbols"; then
  916. prev=expsyms
  917. else
  918. prev=expsyms_regex
  919. fi
  920. continue
  921. ;;
  922. -L*)
  923. dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
  924. # We need an absolute path.
  925. case "$dir" in
  926. [\\/]* | [A-Za-z]:[\\/]*) ;;
  927. *)
  928. absdir=`cd "$dir" && pwd`
  929. if test -z "$absdir"; then
  930. $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
  931. $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
  932. absdir="$dir"
  933. fi
  934. dir="$absdir"
  935. ;;
  936. esac
  937. case " $deplibs " in
  938. *" $arg "*) ;;
  939. *) deplibs="$deplibs $arg";;
  940. esac
  941. case " $lib_search_path " in
  942. *" $dir "*) ;;
  943. *) lib_search_path="$lib_search_path $dir";;
  944. esac
  945. case "$host" in
  946. *-*-cygwin* | *-*-mingw* | *-*-os2*)
  947. dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
  948. case ":$dllsearchpath:" in
  949. ::) dllsearchpath="$dllsearchdir";;
  950. *":$dllsearchdir:"*) ;;
  951. *) dllsearchpath="$dllsearchpath:$dllsearchdir";;
  952. esac
  953. ;;
  954. esac
  955. ;;
  956. -l*)
  957. if test "$arg" = "-lc"; then
  958. case "$host" in
  959. *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
  960. # These systems don't actually have c library (as such)
  961. continue
  962. ;;
  963. esac
  964. elif test "$arg" = "-lm"; then
  965. case "$host" in
  966. *-*-cygwin* | *-*-beos*)
  967. # These systems don't actually have math library (as such)
  968. continue
  969. ;;
  970. esac
  971. fi
  972. deplibs="$deplibs $arg"
  973. ;;
  974. -module)
  975. module=yes
  976. continue
  977. ;;
  978. -no-undefined)
  979. allow_undefined=no
  980. continue
  981. ;;
  982. -o) prev=output ;;
  983. -release)
  984. prev=release
  985. continue
  986. ;;
  987. -rpath)
  988. prev=rpath
  989. continue
  990. ;;
  991. -R)
  992. prev=xrpath
  993. continue
  994. ;;
  995. -R*)
  996. dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
  997. # We need an absolute path.
  998. case "$dir" in
  999. [\\/]* | [A-Za-z]:[\\/]*) ;;
  1000. *)
  1001. $echo "$modename: only absolute run-paths are allowed" 1>&2
  1002. exit 1
  1003. ;;
  1004. esac
  1005. case "$xrpath " in
  1006. *" $dir "*) ;;
  1007. *) xrpath="$xrpath $dir" ;;
  1008. esac
  1009. continue
  1010. ;;
  1011. -static)
  1012. # If we have no pic_flag, then this is the same as -all-static.
  1013. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  1014. compile_command="$compile_command $link_static_flag"
  1015. finalize_command="$finalize_command $link_static_flag"
  1016. fi
  1017. continue
  1018. ;;
  1019. -thread-safe)
  1020. thread_safe=yes
  1021. continue
  1022. ;;
  1023. -version-info)
  1024. prev=vinfo
  1025. continue
  1026. ;;
  1027. # Some other compiler flag.
  1028. -* | +*)
  1029. # Unknown arguments in both finalize_command and compile_command need
  1030. # to be aesthetically quoted because they are evaled later.
  1031. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
  1032. case "$arg" in
  1033. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
  1034. arg="\"$arg\""
  1035. ;;
  1036. esac
  1037. ;;
  1038. *.o | *.obj | *.a | *.lib)
  1039. # A standard object.
  1040. objs="$objs $arg"
  1041. ;;
  1042. *.lo)
  1043. # A library object.
  1044. if test "$prev" = dlfiles; then
  1045. dlfiles="$dlfiles $arg"
  1046. if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
  1047. prev=
  1048. continue
  1049. else
  1050. # If libtool objects are unsupported, then we need to preload.
  1051. prev=dlprefiles
  1052. fi
  1053. fi
  1054. if test "$prev" = dlprefiles; then
  1055. # Preload the old-style object.
  1056. dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
  1057. prev=
  1058. fi
  1059. libobjs="$libobjs $arg"
  1060. ;;
  1061. *.la)
  1062. # A libtool-controlled library.
  1063. dlname=
  1064. libdir=
  1065. library_names=
  1066. old_library=
  1067. # Check to see that this really is a libtool archive.
  1068. if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
  1069. else
  1070. $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
  1071. exit 1
  1072. fi
  1073. # If the library was installed with an old release of libtool,
  1074. # it will not redefine variable installed.
  1075. installed=yes
  1076. # Read the .la file
  1077. # If there is no directory component, then add one.
  1078. case "$arg" in
  1079. */* | *\\*) . $arg ;;
  1080. *) . ./$arg ;;
  1081. esac
  1082. # Get the name of the library we link against.
  1083. linklib=
  1084. for l in $old_library $library_names; do
  1085. linklib="$l"
  1086. done
  1087. if test -z "$linklib"; then
  1088. $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
  1089. exit 1
  1090. fi
  1091. # Find the relevant object directory and library name.
  1092. name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
  1093. if test "X$installed" = Xyes; then
  1094. dir="$libdir"
  1095. else
  1096. dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
  1097. if test "X$dir" = "X$arg"; then
  1098. dir="$objdir"
  1099. else
  1100. dir="$dir/$objdir"
  1101. fi
  1102. fi
  1103. if test -n "$dependency_libs"; then
  1104. # Extract -R from dependency_libs
  1105. temp_deplibs=
  1106. for deplib in $dependency_libs; do
  1107. case "$deplib" in
  1108. -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
  1109. case " $rpath $xrpath " in
  1110. *" $temp_xrpath "*) ;;
  1111. *) xrpath="$xrpath $temp_xrpath";;
  1112. esac;;
  1113. -L*) case "$compile_command $temp_deplibs " in
  1114. *" $deplib "*) ;;
  1115. *) temp_deplibs="$temp_deplibs $deplib";;
  1116. esac;;
  1117. *) temp_deplibs="$temp_deplibs $deplib";;
  1118. esac
  1119. done
  1120. dependency_libs="$temp_deplibs"
  1121. fi
  1122. if test -z "$libdir"; then
  1123. # It is a libtool convenience library, so add in its objects.
  1124. convenience="$convenience $dir/$old_library"
  1125. old_convenience="$old_convenience $dir/$old_library"
  1126. deplibs="$deplibs$dependency_libs"
  1127. compile_command="$compile_command $dir/$old_library$dependency_libs"
  1128. finalize_command="$finalize_command $dir/$old_library$dependency_libs"
  1129. continue
  1130. fi
  1131. # This library was specified with -dlopen.
  1132. if test "$prev" = dlfiles; then
  1133. dlfiles="$dlfiles $arg"
  1134. if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
  1135. # If there is no dlname, no dlopen support or we're linking statically,
  1136. # we need to preload.
  1137. prev=dlprefiles
  1138. else
  1139. # We should not create a dependency on this library, but we
  1140. # may need any libraries it requires.
  1141. compile_command="$compile_command$dependency_libs"
  1142. finalize_command="$finalize_command$dependency_libs"
  1143. prev=
  1144. continue
  1145. fi
  1146. fi
  1147. # The library was specified with -dlpreopen.
  1148. if test "$prev" = dlprefiles; then
  1149. # Prefer using a static library (so that no silly _DYNAMIC symbols
  1150. # are required to link).
  1151. if test -n "$old_library"; then
  1152. dlprefiles="$dlprefiles $dir/$old_library"
  1153. else
  1154. dlprefiles="$dlprefiles $dir/$linklib"
  1155. fi
  1156. prev=
  1157. fi
  1158. if test -n "$library_names" &&
  1159. { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
  1160. link_against_libtool_libs="$link_against_libtool_libs $arg"
  1161. if test -n "$shlibpath_var"; then
  1162. # Make sure the rpath contains only unique directories.
  1163. case "$temp_rpath " in
  1164. *" $dir "*) ;;
  1165. *) temp_rpath="$temp_rpath $dir" ;;
  1166. esac
  1167. fi
  1168. # We need an absolute path.
  1169. case "$dir" in
  1170. [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;;
  1171. *)
  1172. absdir=`cd "$dir" && pwd`
  1173. if test -z "$absdir"; then
  1174. $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
  1175. $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
  1176. absdir="$dir"
  1177. fi
  1178. ;;
  1179. esac
  1180. # This is the magic to use -rpath.
  1181. # Skip directories that are in the system default run-time
  1182. # search path, unless they have been requested with -R.
  1183. case " $sys_lib_dlsearch_path " in
  1184. *" $absdir "*) ;;
  1185. *)
  1186. case "$compile_rpath " in
  1187. *" $absdir "*) ;;
  1188. *) compile_rpath="$compile_rpath $absdir"
  1189. esac
  1190. ;;
  1191. esac
  1192. case " $sys_lib_dlsearch_path " in
  1193. *" $libdir "*) ;;
  1194. *)
  1195. case "$finalize_rpath " in
  1196. *" $libdir "*) ;;
  1197. *) finalize_rpath="$finalize_rpath $libdir"
  1198. esac
  1199. ;;
  1200. esac
  1201. lib_linked=yes
  1202. case "$hardcode_action" in
  1203. immediate | unsupported)
  1204. if test "$hardcode_direct" = no; then
  1205. compile_command="$compile_command $dir/$linklib"
  1206. deplibs="$deplibs $dir/$linklib"
  1207. case "$host" in
  1208. *-*-cygwin* | *-*-mingw* | *-*-os2*)
  1209. dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
  1210. if test -n "$dllsearchpath"; then
  1211. dllsearchpath="$dllsearchpath:$dllsearchdir"
  1212. else
  1213. dllsearchpath="$dllsearchdir"
  1214. fi
  1215. ;;
  1216. esac
  1217. elif test "$hardcode_minus_L" = no; then
  1218. case "$host" in
  1219. *-*-sunos*)
  1220. compile_shlibpath="$compile_shlibpath$dir:"
  1221. ;;
  1222. esac
  1223. case "$compile_command " in
  1224. *" -L$dir "*) ;;
  1225. *) compile_command="$compile_command -L$dir";;
  1226. esac
  1227. compile_command="$compile_command -l$name"
  1228. deplibs="$deplibs -L$dir -l$name"
  1229. elif test "$hardcode_shlibpath_var" = no; then
  1230. case ":$compile_shlibpath:" in
  1231. *":$dir:"*) ;;
  1232. *) compile_shlibpath="$compile_shlibpath$dir:";;
  1233. esac
  1234. compile_command="$compile_command -l$name"
  1235. deplibs="$deplibs -l$name"
  1236. else
  1237. lib_linked=no
  1238. fi
  1239. ;;
  1240. relink)
  1241. if test "$hardcode_direct" = yes; then
  1242. compile_command="$compile_command $absdir/$linklib"
  1243. deplibs="$deplibs $absdir/$linklib"
  1244. elif test "$hardcode_minus_L" = yes; then
  1245. case "$compile_command " in
  1246. *" -L$absdir "*) ;;
  1247. *) compile_command="$compile_command -L$absdir";;
  1248. esac
  1249. compile_command="$compile_command -l$name"
  1250. deplibs="$deplibs -L$absdir -l$name"
  1251. elif test "$hardcode_shlibpath_var" = yes; then
  1252. case ":$compile_shlibpath:" in
  1253. *":$absdir:"*) ;;
  1254. *) compile_shlibpath="$compile_shlibpath$absdir:";;
  1255. esac
  1256. compile_command="$compile_command -l$name"
  1257. deplibs="$deplibs -l$name"
  1258. else
  1259. lib_linked=no
  1260. fi
  1261. ;;
  1262. *)
  1263. lib_linked=no
  1264. ;;
  1265. esac
  1266. if test "$lib_linked" != yes; then
  1267. $echo "$modename: configuration error: unsupported hardcode properties"
  1268. exit 1
  1269. fi
  1270. # Finalize command for both is simple: just hardcode it.
  1271. if test "$hardcode_direct" = yes; then
  1272. finalize_command="$finalize_command $libdir/$linklib"
  1273. elif test "$hardcode_minus_L" = yes; then
  1274. case "$finalize_command " in
  1275. *" -L$libdir "*) ;;
  1276. *) finalize_command="$finalize_command -L$libdir";;
  1277. esac
  1278. finalize_command="$finalize_command -l$name"
  1279. elif test "$hardcode_shlibpath_var" = yes; then
  1280. case ":$finalize_shlibpath:" in
  1281. *":$libdir:"*) ;;
  1282. *) finalize_shlibpath="$finalize_shlibpath$libdir:";;
  1283. esac
  1284. finalize_command="$finalize_command -l$name"
  1285. else
  1286. # We cannot seem to hardcode it, guess we'll fake it.
  1287. case "$finalize_command " in
  1288. *" -L$dir "*) ;;
  1289. *) finalize_command="$finalize_command -L$libdir";;
  1290. esac
  1291. finalize_command="$finalize_command -l$name"
  1292. fi
  1293. else
  1294. # Transform directly to old archives if we don't build new libraries.
  1295. if test -n "$pic_flag" && test -z "$old_library"; then
  1296. $echo "$modename: cannot find static library for \`$arg'" 1>&2
  1297. exit 1
  1298. fi
  1299. # Here we assume that one of hardcode_direct or hardcode_minus_L
  1300. # is not unsupported. This is valid on all known static and
  1301. # shared platforms.
  1302. if test "$hardcode_direct" != unsupported; then
  1303. test -n "$old_library" && linklib="$old_library"
  1304. compile_command="$compile_command $dir/$linklib"
  1305. finalize_command="$finalize_command $dir/$linklib"
  1306. else
  1307. case "$compile_command " in
  1308. *" -L$dir "*) ;;
  1309. *) compile_command="$compile_command -L$dir";;
  1310. esac
  1311. compile_command="$compile_command -l$name"
  1312. case "$finalize_command " in
  1313. *" -L$dir "*) ;;
  1314. *) finalize_command="$finalize_command -L$dir";;
  1315. esac
  1316. finalize_command="$finalize_command -l$name"
  1317. fi
  1318. fi
  1319. # Add in any libraries that this one depends upon.
  1320. compile_command="$compile_command$dependency_libs"
  1321. finalize_command="$finalize_command$dependency_libs"
  1322. continue
  1323. ;;
  1324. # Some other compiler argument.
  1325. *)
  1326. # Unknown arguments in both finalize_command and compile_command need
  1327. # to be aesthetically quoted because they are evaled later.
  1328. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
  1329. case "$arg" in
  1330. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
  1331. arg="\"$arg\""
  1332. ;;
  1333. esac
  1334. ;;
  1335. esac
  1336. # Now actually substitute the argument into the commands.
  1337. if test -n "$arg"; then
  1338. compile_command="$compile_command $arg"
  1339. finalize_command="$finalize_command $arg"
  1340. fi
  1341. done
  1342. if test -n "$prev"; then
  1343. $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
  1344. $echo "$help" 1>&2
  1345. exit 1
  1346. fi
  1347. if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
  1348. eval arg=\"$export_dynamic_flag_spec\"
  1349. compile_command="$compile_command $arg"
  1350. finalize_command="$finalize_command $arg"
  1351. fi
  1352. oldlibs=
  1353. # calculate the name of the file, without its directory
  1354. outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
  1355. libobjs_save="$libobjs"
  1356. case "$output" in
  1357. "")
  1358. $echo "$modename: you must specify an output file" 1>&2
  1359. $echo "$help" 1>&2
  1360. exit 1
  1361. ;;
  1362. *.a | *.lib)
  1363. if test -n "$link_against_libtool_libs"; then
  1364. $echo "$modename: error: cannot link libtool libraries into archives" 1>&2
  1365. exit 1
  1366. fi
  1367. if test -n "$deplibs"; then
  1368. $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
  1369. fi
  1370. if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  1371. $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
  1372. fi
  1373. if test -n "$rpath"; then
  1374. $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
  1375. fi
  1376. if test -n "$xrpath"; then
  1377. $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
  1378. fi
  1379. if test -n "$vinfo"; then
  1380. $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
  1381. fi
  1382. if test -n "$release"; then
  1383. $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
  1384. fi
  1385. if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  1386. $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
  1387. fi
  1388. # Now set the variables for building old libraries.
  1389. build_libtool_libs=no
  1390. oldlibs="$output"
  1391. ;;
  1392. *.la)
  1393. # Make sure we only generate libraries of the form `libNAME.la'.
  1394. case "$outputname" in
  1395. lib*)
  1396. name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
  1397. eval libname=\"$libname_spec\"
  1398. ;;
  1399. *)
  1400. if test "$module" = no; then
  1401. $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
  1402. $echo "$help" 1>&2
  1403. exit 1
  1404. fi
  1405. if test "$need_lib_prefix" != no; then
  1406. # Add the "lib" prefix for modules if required
  1407. name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
  1408. eval libname=\"$libname_spec\"
  1409. else
  1410. libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
  1411. fi
  1412. ;;
  1413. esac
  1414. output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
  1415. if test "X$output_objdir" = "X$output"; then
  1416. output_objdir="$objdir"
  1417. else
  1418. output_objdir="$output_objdir/$objdir"
  1419. fi
  1420. if test -n "$objs"; then
  1421. $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
  1422. exit 1
  1423. fi
  1424. # How the heck are we supposed to write a wrapper for a shared library?
  1425. if test -n "$link_against_libtool_libs"; then
  1426. $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
  1427. exit 1
  1428. fi
  1429. if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  1430. $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
  1431. fi
  1432. set dummy $rpath
  1433. if test $# -gt 2; then
  1434. $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
  1435. fi
  1436. install_libdir="$2"
  1437. oldlibs=
  1438. if test -z "$rpath"; then
  1439. if test "$build_libtool_libs" = yes; then
  1440. # Building a libtool convenience library.
  1441. libext=al
  1442. oldlibs="$output_objdir/$libname.$libext $oldlibs"
  1443. build_libtool_libs=convenience
  1444. build_old_libs=yes
  1445. fi
  1446. dependency_libs="$deplibs"
  1447. if test -n "$vinfo"; then
  1448. $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
  1449. fi
  1450. if test -n "$release"; then
  1451. $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
  1452. fi
  1453. else
  1454. # Parse the version information argument.
  1455. IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
  1456. set dummy $vinfo 0 0 0
  1457. IFS="$save_ifs"
  1458. if test -n "$8"; then
  1459. $echo "$modename: too many parameters to \`-version-info'" 1>&2
  1460. $echo "$help" 1>&2
  1461. exit 1
  1462. fi
  1463. current="$2"
  1464. revision="$3"
  1465. age="$4"
  1466. # Check that each of the things are valid numbers.
  1467. case "$current" in
  1468. 0 | [1-9] | [1-9][0-9]*) ;;
  1469. *)
  1470. $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
  1471. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1472. exit 1
  1473. ;;
  1474. esac
  1475. case "$revision" in
  1476. 0 | [1-9] | [1-9][0-9]*) ;;
  1477. *)
  1478. $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
  1479. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1480. exit 1
  1481. ;;
  1482. esac
  1483. case "$age" in
  1484. 0 | [1-9] | [1-9][0-9]*) ;;
  1485. *)
  1486. $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
  1487. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1488. exit 1
  1489. ;;
  1490. esac
  1491. if test $age -gt $current; then
  1492. $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
  1493. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1494. exit 1
  1495. fi
  1496. # Calculate the version variables.
  1497. major=
  1498. versuffix=
  1499. verstring=
  1500. case "$version_type" in
  1501. none) ;;
  1502. irix)
  1503. major=`expr $current - $age + 1`
  1504. versuffix="$major.$revision"
  1505. verstring="sgi$major.$revision"
  1506. # Add in all the interfaces that we are compatible with.
  1507. loop=$revision
  1508. while test $loop != 0; do
  1509. iface=`expr $revision - $loop`
  1510. loop=`expr $loop - 1`
  1511. verstring="sgi$major.$iface:$verstring"
  1512. done
  1513. ;;
  1514. linux)
  1515. major=.`expr $current - $age`
  1516. versuffix="$major.$age.$revision"
  1517. ;;
  1518. osf)
  1519. major=`expr $current - $age`
  1520. versuffix=".$current.$age.$revision"
  1521. verstring="$current.$age.$revision"
  1522. # Add in all the interfaces that we are compatible with.
  1523. loop=$age
  1524. while test $loop != 0; do
  1525. iface=`expr $current - $loop`
  1526. loop=`expr $loop - 1`
  1527. verstring="$verstring:${iface}.0"
  1528. done
  1529. # Make executables depend on our current version.
  1530. verstring="$verstring:${current}.0"
  1531. ;;
  1532. sunos)
  1533. major=".$current"
  1534. versuffix=".$current.$revision"
  1535. ;;
  1536. freebsd-aout)
  1537. major=".$current"
  1538. versuffix=".$current.$revision";
  1539. ;;
  1540. freebsd-elf)
  1541. major=".$current"
  1542. versuffix=".$current";
  1543. ;;
  1544. windows)
  1545. # Like Linux, but with '-' rather than '.', since we only
  1546. # want one extension on Windows 95.
  1547. major=`expr $current - $age`
  1548. versuffix="-$major-$age-$revision"
  1549. ;;
  1550. *)
  1551. $echo "$modename: unknown library version type \`$version_type'" 1>&2
  1552. echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
  1553. exit 1
  1554. ;;
  1555. esac
  1556. # Clear the version info if we defaulted, and they specified a release.
  1557. if test -z "$vinfo" && test -n "$release"; then
  1558. major=
  1559. verstring="0.0"
  1560. if test "$need_version" = no; then
  1561. versuffix=
  1562. else
  1563. versuffix=".0.0"
  1564. fi
  1565. fi
  1566. # Remove version info from name if versioning should be avoided
  1567. if test "$avoid_version" = yes && test "$need_version" = no; then
  1568. major=
  1569. versuffix=
  1570. verstring=""
  1571. fi
  1572. # Check to see if the archive will have undefined symbols.
  1573. if test "$allow_undefined" = yes; then
  1574. if test "$allow_undefined_flag" = unsupported; then
  1575. $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
  1576. build_libtool_libs=no
  1577. build_old_libs=yes
  1578. fi
  1579. else
  1580. # Don't allow undefined symbols.
  1581. allow_undefined_flag="$no_undefined_flag"
  1582. fi
  1583. dependency_libs="$deplibs"
  1584. case "$host" in
  1585. *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
  1586. # these systems don't actually have a c library (as such)!
  1587. ;;
  1588. *)
  1589. # Add libc to deplibs on all other systems.
  1590. deplibs="$deplibs -lc"
  1591. ;;
  1592. esac
  1593. fi
  1594. # Create the output directory, or remove our outputs if we need to.
  1595. if test -d $output_objdir; then
  1596. $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
  1597. $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
  1598. else
  1599. $show "$mkdir $output_objdir"
  1600. $run $mkdir $output_objdir
  1601. status=$?
  1602. if test $status -ne 0 && test ! -d $output_objdir; then
  1603. exit $status
  1604. fi
  1605. fi
  1606. # Now set the variables for building old libraries.
  1607. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
  1608. oldlibs="$oldlibs $output_objdir/$libname.$libext"
  1609. # Transform .lo files to .o files.
  1610. oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
  1611. fi
  1612. if test "$build_libtool_libs" = yes; then
  1613. # Transform deplibs into only deplibs that can be linked in shared.
  1614. name_save=$name
  1615. libname_save=$libname
  1616. release_save=$release
  1617. versuffix_save=$versuffix
  1618. major_save=$major
  1619. # I'm not sure if I'm treating the release correctly. I think
  1620. # release should show up in the -l (ie -lgmp5) so we don't want to
  1621. # add it in twice. Is that correct?
  1622. release=""
  1623. versuffix=""
  1624. major=""
  1625. newdeplibs=
  1626. droppeddeps=no
  1627. case "$deplibs_check_method" in
  1628. pass_all)
  1629. # Don't check for shared/static. Everything works.
  1630. # This might be a little naive. We might want to check
  1631. # whether the library exists or not. But this is on
  1632. # osf3 & osf4 and I'm not really sure... Just
  1633. # implementing what was already the behaviour.
  1634. newdeplibs=$deplibs
  1635. ;;
  1636. test_compile)
  1637. # This code stresses the "libraries are programs" paradigm to its
  1638. # limits. Maybe even breaks it. We compile a program, linking it
  1639. # against the deplibs as a proxy for the library. Then we can check
  1640. # whether they linked in statically or dynamically with ldd.
  1641. $rm conftest.c
  1642. cat > conftest.c <<EOF
  1643. int main() { return 0; }
  1644. EOF
  1645. $rm conftest
  1646. $C_compiler -o conftest conftest.c $deplibs
  1647. if test $? -eq 0 ; then
  1648. ldd_output=`ldd conftest`
  1649. for i in $deplibs; do
  1650. name="`expr $i : '-l\(.*\)'`"
  1651. # If $name is empty we are operating on a -L argument.
  1652. if test "$name" != "" ; then
  1653. libname=`eval \\$echo \"$libname_spec\"`
  1654. deplib_matches=`eval \\$echo \"$library_names_spec\"`
  1655. set dummy $deplib_matches
  1656. deplib_match=$2
  1657. if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
  1658. newdeplibs="$newdeplibs $i"
  1659. else
  1660. droppeddeps=yes
  1661. echo
  1662. echo "*** Warning: This library needs some functionality provided by $i."
  1663. echo "*** I have the capability to make that library automatically link in when"
  1664. echo "*** you link to this library. But I can only do this if you have a"
  1665. echo "*** shared version of the library, which you do not appear to have."
  1666. fi
  1667. else
  1668. newdeplibs="$newdeplibs $i"
  1669. fi
  1670. done
  1671. else
  1672. # Error occured in the first compile. Let's try to salvage the situation:
  1673. # Compile a seperate program for each library.
  1674. for i in $deplibs; do
  1675. name="`expr $i : '-l\(.*\)'`"
  1676. # If $name is empty we are operating on a -L argument.
  1677. if test "$name" != "" ; then
  1678. $rm conftest
  1679. $C_compiler -o conftest conftest.c $i
  1680. # Did it work?
  1681. if test $? -eq 0 ; then
  1682. ldd_output=`ldd conftest`
  1683. libname=`eval \\$echo \"$libname_spec\"`
  1684. deplib_matches=`eval \\$echo \"$library_names_spec\"`
  1685. set dummy $deplib_matches
  1686. deplib_match=$2
  1687. if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
  1688. newdeplibs="$newdeplibs $i"
  1689. else
  1690. droppeddeps=yes
  1691. echo
  1692. echo "*** Warning: This library needs some functionality provided by $i."
  1693. echo "*** I have the capability to make that library automatically link in when"
  1694. echo "*** you link to this library. But I can only do this if you have a"
  1695. echo "*** shared version of the library, which you do not appear to have."
  1696. fi
  1697. else
  1698. droppeddeps=yes
  1699. echo
  1700. echo "*** Warning! Library $i is needed by this library but I was not able to"
  1701. echo "*** make it link in! You will probably need to install it or some"
  1702. echo "*** library that it depends on before this library will be fully"
  1703. echo "*** functional. Installing it before continuing would be even better."
  1704. fi
  1705. else
  1706. newdeplibs="$newdeplibs $i"
  1707. fi
  1708. done
  1709. fi
  1710. ;;
  1711. file_magic*)
  1712. set dummy $deplibs_check_method
  1713. file_magic_regex="`expr \"$deplibs_check_method\" : \"$2 \(.*\)\"`"
  1714. for a_deplib in $deplibs; do
  1715. name="`expr $a_deplib : '-l\(.*\)'`"
  1716. # If $name is empty we are operating on a -L argument.
  1717. if test "$name" != "" ; then
  1718. libname=`eval \\$echo \"$libname_spec\"`
  1719. for i in $lib_search_path; do
  1720. potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
  1721. for potent_lib in $potential_libs; do
  1722. # Follow soft links.
  1723. if ls -lLd "$potent_lib" 2>/dev/null \
  1724. | grep " -> " >/dev/null; then
  1725. continue
  1726. fi
  1727. # The statement above tries to avoid entering an
  1728. # endless loop below, in case of cyclic links.
  1729. # We might still enter an endless loop, since a link
  1730. # loop can be closed while we follow links,
  1731. # but so what?
  1732. potlib="$potent_lib"
  1733. while test -h "$potlib" 2>/dev/null; do
  1734. potliblink=`ls -ld $potlib | sed 's/.* -> //'`
  1735. case "$potliblink" in
  1736. [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
  1737. *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
  1738. esac
  1739. done
  1740. if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
  1741. | sed 10q \
  1742. | egrep "$file_magic_regex" > /dev/null; then
  1743. newdeplibs="$newdeplibs $a_deplib"
  1744. a_deplib=""
  1745. break 2
  1746. fi
  1747. done
  1748. done
  1749. if test -n "$a_deplib" ; then
  1750. droppeddeps=yes
  1751. echo
  1752. echo "*** Warning: This library needs some functionality provided by $a_deplib."
  1753. echo "*** I have the capability to make that library automatically link in when"
  1754. echo "*** you link to this library. But I can only do this if you have a"
  1755. echo "*** shared version of the library, which you do not appear to have."
  1756. fi
  1757. else
  1758. # Add a -L argument.
  1759. newdeplibs="$newdeplibs $a_deplib"
  1760. fi
  1761. done # Gone through all deplibs.
  1762. ;;
  1763. none | unknown | *)
  1764. newdeplibs=""
  1765. if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
  1766. -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' |
  1767. grep . >/dev/null; then
  1768. echo
  1769. if test "X$deplibs_check_method" = "Xnone"; then
  1770. echo "*** Warning: inter-library dependencies are not supported in this platform."
  1771. else
  1772. echo "*** Warning: inter-library dependencies are not known to be supported."
  1773. fi
  1774. echo "*** All declared inter-library dependencies are being dropped."
  1775. droppeddeps=yes
  1776. fi
  1777. ;;
  1778. esac
  1779. versuffix=$versuffix_save
  1780. major=$major_save
  1781. release=$release_save
  1782. libname=$libname_save
  1783. name=$name_save
  1784. if test "$droppeddeps" = yes; then
  1785. if test "$module" = yes; then
  1786. echo
  1787. echo "*** Warning: libtool could not satisfy all declared inter-library"
  1788. echo "*** dependencies of module $libname. Therefore, libtool will create"
  1789. echo "*** a static module, that should work as long as the dlopening"
  1790. echo "*** application is linked with the -dlopen flag."
  1791. if test -z "$global_symbol_pipe"; then
  1792. echo
  1793. echo "*** However, this would only work if libtool was able to extract symbol"
  1794. echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
  1795. echo "*** not find such a program. So, this module is probably useless."
  1796. echo "*** \`nm' from GNU binutils and a full rebuild may help."
  1797. fi
  1798. if test "$build_old_libs" = no; then
  1799. oldlibs="$output_objdir/$libname.$libext"
  1800. build_libtool_libs=module
  1801. build_old_libs=yes
  1802. else
  1803. build_libtool_libs=no
  1804. fi
  1805. else
  1806. echo "*** The inter-library dependencies that have been dropped here will be"
  1807. echo "*** automatically added whenever a program is linked with this library"
  1808. echo "*** or is declared to -dlopen it."
  1809. fi
  1810. fi
  1811. # Done checking deplibs!
  1812. deplibs=$newdeplibs
  1813. fi
  1814. # All the library-specific variables (install_libdir is set above).
  1815. library_names=
  1816. old_library=
  1817. dlname=
  1818. # Test again, we may have decided not to build it any more
  1819. if test "$build_libtool_libs" = yes; then
  1820. # Get the real and link names of the library.
  1821. eval library_names=\"$library_names_spec\"
  1822. set dummy $library_names
  1823. realname="$2"
  1824. shift; shift
  1825. if test -n "$soname_spec"; then
  1826. eval soname=\"$soname_spec\"
  1827. else
  1828. soname="$realname"
  1829. fi
  1830. lib="$output_objdir/$realname"
  1831. for link
  1832. do
  1833. linknames="$linknames $link"
  1834. done
  1835. # Ensure that we have .o objects for linkers which dislike .lo
  1836. # (e.g. aix) incase we are running --disable-static
  1837. for obj in $libobjs; do
  1838. oldobj=`$echo "X$obj" | $Xsed -e "$lo2o"`
  1839. if test ! -f $oldobj; then
  1840. $show "${LN_S} $obj $oldobj"
  1841. $run ${LN_S} $obj $oldobj || exit $?
  1842. fi
  1843. done
  1844. # Use standard objects if they are pic
  1845. test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
  1846. if test -n "$whole_archive_flag_spec"; then
  1847. if test -n "$convenience"; then
  1848. eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
  1849. fi
  1850. else
  1851. gentop="$output_objdir/${outputname}x"
  1852. $show "${rm}r $gentop"
  1853. $run ${rm}r "$gentop"
  1854. $show "mkdir $gentop"
  1855. $run mkdir "$gentop"
  1856. status=$?
  1857. if test $status -ne 0 && test ! -d "$gentop"; then
  1858. exit $status
  1859. fi
  1860. generated="$generated $gentop"
  1861. for xlib in $convenience; do
  1862. # Extract the objects.
  1863. case "$xlib" in
  1864. [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
  1865. *) xabs=`pwd`"/$xlib" ;;
  1866. esac
  1867. xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
  1868. xdir="$gentop/$xlib"
  1869. $show "${rm}r $xdir"
  1870. $run ${rm}r "$xdir"
  1871. $show "mkdir $xdir"
  1872. $run mkdir "$xdir"
  1873. status=$?
  1874. if test $status -ne 0 && test ! -d "$xdir"; then
  1875. exit $status
  1876. fi
  1877. $show "(cd $xdir && $AR x $xabs)"
  1878. $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
  1879. libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
  1880. done
  1881. fi
  1882. if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
  1883. eval flag=\"$thread_safe_flag_spec\"
  1884. linkopts="$linkopts $flag"
  1885. fi
  1886. # Prepare the list of exported symbols
  1887. if test -z "$export_symbols"; then
  1888. if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
  1889. $show "generating symbol list for \`$libname.la'"
  1890. export_symbols="$output_objdir/$libname.exp"
  1891. $run $rm $export_symbols
  1892. eval cmds=\"$export_symbols_cmds\"
  1893. IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
  1894. for cmd in $cmds; do
  1895. IFS="$save_ifs"
  1896. $show "$cmd"
  1897. $run eval "$cmd" || exit $?
  1898. done
  1899. IFS="$save_ifs"
  1900. if test -n "$export_symbols_regex"; then
  1901. $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
  1902. $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
  1903. $show "$mv \"${export_symbols}T\" \"$export_symbols\""
  1904. $run eval '$mv "${export_symbols}T" "$export_symbols"'
  1905. fi
  1906. fi
  1907. fi
  1908. if test -n "$export_symbols" && test -n "$include_expsyms"; then
  1909. $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
  1910. fi
  1911. # Do each of the archive commands.
  1912. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
  1913. eval cmds=\"$archive_expsym_cmds\"
  1914. else
  1915. eval cmds=\"$archive_cmds\"
  1916. fi
  1917. IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
  1918. for cmd in $cmds; do
  1919. IFS="$save_ifs"
  1920. $show "$cmd"
  1921. $run eval "$cmd" || exit $?
  1922. done
  1923. IFS="$save_ifs"
  1924. # Create links to the real library.
  1925. for linkname in $linknames; do
  1926. if test "$realname" != "$linkname"; then
  1927. $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
  1928. $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
  1929. fi
  1930. done
  1931. # If -module or -export-dynamic was specified, set the dlname.
  1932. if test "$module" = yes || test "$export_dynamic" = yes; then
  1933. # On all known operating systems, these are identical.
  1934. dlname="$soname"
  1935. fi
  1936. fi
  1937. ;;
  1938. *.lo | *.o | *.obj)
  1939. if test -n "$link_against_libtool_libs"; then
  1940. $echo "$modename: error: cannot link libtool libraries into objects" 1>&2
  1941. exit 1
  1942. fi
  1943. if test -n "$deplibs"; then
  1944. $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
  1945. fi
  1946. if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  1947. $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
  1948. fi
  1949. if test -n "$rpath"; then
  1950. $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
  1951. fi
  1952. if test -n "$xrpath"; then
  1953. $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
  1954. fi
  1955. if test -n "$vinfo"; then
  1956. $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
  1957. fi
  1958. if test -n "$release"; then
  1959. $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
  1960. fi
  1961. case "$output" in
  1962. *.lo)
  1963. if test -n "$objs"; then
  1964. $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
  1965. exit 1
  1966. fi
  1967. libobj="$output"
  1968. obj=`$echo "X$output" | $Xsed -e "$lo2o"`
  1969. ;;
  1970. *)
  1971. libobj=
  1972. obj="$output"
  1973. ;;
  1974. esac
  1975. # Delete the old objects.
  1976. $run $rm $obj $libobj
  1977. # Create the old-style object.
  1978. reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
  1979. output="$obj"
  1980. eval cmds=\"$reload_cmds\"
  1981. IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
  1982. for cmd in $cmds; do
  1983. IFS="$save_ifs"
  1984. $show "$cmd"
  1985. $run eval "$cmd" || exit $?
  1986. done
  1987. IFS="$save_ifs"
  1988. # Exit if we aren't doing a library object file.
  1989. test -z "$libobj" && exit 0
  1990. if test "$build_libtool_libs" != yes; then
  1991. # Create an invalid libtool object if no PIC, so that we don't
  1992. # accidentally link it into a program.
  1993. $show "echo timestamp > $libobj"
  1994. $run eval "echo timestamp > $libobj" || exit $?
  1995. exit 0
  1996. fi
  1997. if test -n "$pic_flag"; then
  1998. # Only do commands if we really have different PIC objects.
  1999. reload_objs="$libobjs"
  2000. output="$libobj"
  2001. eval cmds=\"$reload_cmds\"
  2002. IFS="${IFS= }"; save_ifs="$IFS"; IFS='~'
  2003. for cmd in $cmds; do
  2004. IFS="$save_ifs"
  2005. $show "$cmd"
  2006. $run eval "$cmd" || exit $?
  2007. done
  2008. IFS="$save_ifs"
  2009. else
  2010. # Just create a symlink.
  2011. $show $rm $libobj
  2012. $run $rm $libobj
  2013. $show "$LN_S $obj $libobj"
  2014. $run $LN_S $obj $libobj || exit $?
  2015. fi
  2016. exit 0
  2017. ;;
  2018. # Anything else should be a program.
  2019. *)
  2020. if test -n "$vinfo"; then
  2021. $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
  2022. fi
  2023. if test -n "$release"; then
  2024. $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
  2025. fi
  2026. if test "$preload" = yes; then
  2027. if test "$dlopen" = unknown && test "$dlopen_self" = unknown &&
  2028. test "$dlopen_self_static" = unknown; then
  2029. $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
  2030. fi
  2031. fi
  2032. if test -n "$rpath$xrpath"; then
  2033. # If the user specified any rpath flags, then add them.
  2034. for libdir in $rpath $xrpath; do
  2035. # This is the magic to use -rpath.
  2036. case "$compile_rpath " in
  2037. *" $libdir "*) ;;
  2038. *) compile_rpath="$compile_rpath $libdir" ;;
  2039. esac
  2040. case "$finalize_rpath " in
  2041. *" $libdir "*) ;;
  2042. *) finalize_rpath="$finalize_rpath $libdir" ;;
  2043. esac
  2044. done
  2045. fi
  2046. # Now hardcode the library paths
  2047. rpath=
  2048. hardcode_libdirs=
  2049. for libdir in $compile_rpath $finalize_rpath; do
  2050. if test -n "$hardcode_libdir_flag_spec"; then
  2051. if test -n "$hardcode_libdir_separator"; then
  2052. if test -z "$hardcode_libdirs"; then
  2053. hardcode_libdirs="$libdir"
  2054. else
  2055. # Just accumulate the unique libdirs.
  2056. case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
  2057. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  2058. ;;
  2059. *)
  2060. hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
  2061. ;;
  2062. esac
  2063. fi
  2064. else
  2065. eval flag=\"$hardcode_libdir_flag_spec\"
  2066. rpath="$rpath $flag"
  2067. fi
  2068. elif test -n "$runpath_var"; then
  2069. case "$perm_rpath " in
  2070. *" $libdir "*) ;;
  2071. *) perm_rpath="$perm_rpath $libdir" ;;
  2072. esac
  2073. fi
  2074. done
  2075. # Substitute the hardcoded libdirs into the rpath.
  2076. if test -n "$hardcode_libdir_separator" &&
  2077. test -n "$hardcode_libdirs"; then
  2078. libdir="$hardcode_libdirs"
  2079. eval rpath=\" $hardcode_libdir_flag_spec\"
  2080. fi
  2081. compile_rpath="$rpath"
  2082. rpath=
  2083. hardcode_libdirs=
  2084. for libdir in $finalize_rpath; do
  2085. if test -n "$hardcode_libdir_flag_spec"; then
  2086. if test -n "$hardcode_libdir_separator"; then
  2087. if test -z "$hardcode_libdirs"; then
  2088. hardcode_libdirs="$libdir"
  2089. else
  2090. # Just accumulate the unique libdirs.
  2091. case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
  2092. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  2093. ;;
  2094. *)
  2095. hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
  2096. ;;
  2097. esac
  2098. fi
  2099. else
  2100. eval flag=\"$hardcode_libdir_flag_spec\"
  2101. rpath="$rpath $flag"
  2102. fi
  2103. elif test -n "$runpath_var"; then
  2104. case "$finalize_perm_rpath " in
  2105. *" $libdir "*) ;;
  2106. *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
  2107. esac
  2108. fi
  2109. done
  2110. # Substitute the hardcoded libdirs into the rpath.
  2111. if test -n "$hardcode_libdir_separator" &&
  2112. test -n "$hardcode_libdirs"; then
  2113. libdir="$hardcode_libdirs"
  2114. eval rpath=\" $hardcode_libdir_flag_spec\"
  2115. fi
  2116. finalize_rpath="$rpath"
  2117. output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
  2118. if test "X$output_objdir" = "X$output"; then
  2119. output_objdir="$objdir"
  2120. else
  2121. output_objdir="$output_objdir/$objdir"
  2122. fi
  2123. # Create the binary in the object directory, then wrap it.
  2124. if test ! -d $output_objdir; then
  2125. $show "$mkdir $output_objdir"
  2126. $run $mkdir $output_objdir
  2127. status=$?
  2128. if test $status -ne 0 && test ! -d $output_objdir; then
  2129. exit $status
  2130. fi
  2131. fi
  2132. if test -n "$libobjs" && test "$build_old_libs" = yes; then
  2133. # Transform all the library objects into standard objects.
  2134. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
  2135. finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
  2136. fi
  2137. dlsyms=
  2138. if test -n "$dlfiles$dlprefiles" || test "$dlself" = yes; then
  2139. if test -n "$NM" && test -n "$global_symbol_pipe"; then
  2140. dlsyms="${outputname}S.c"
  2141. else
  2142. $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
  2143. fi
  2144. fi
  2145. if test -n "$dlsyms"; then
  2146. case "$dlsyms" in
  2147. "") ;;
  2148. *.c)
  2149. # Discover the nlist of each of the dlfiles.
  2150. nlist="$output_objdir/${outputname}.nm"
  2151. $show "$rm $nlist ${nlist}S ${nlist}T"
  2152. $run $rm "$nlist" "${nlist}S" "${nlist}T"
  2153. # Parse the name list into a source file.
  2154. $show "creating $output_objdir/$dlsyms"
  2155. test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
  2156. /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
  2157. /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
  2158. #ifdef __cplusplus
  2159. extern \"C\" {
  2160. #endif
  2161. /* Prevent the only kind of declaration conflicts we can make. */
  2162. #define lt_preloaded_symbols some_other_symbol
  2163. /* External symbol declarations for the compiler. */\
  2164. "
  2165. if test "$dlself" = yes; then
  2166. $show "generating symbol list for \`$output'"
  2167. test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
  2168. # Add our own program objects to the symbol list.
  2169. progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
  2170. for arg in $progfiles; do
  2171. $show "extracting global C symbols from \`$arg'"
  2172. $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
  2173. do