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

/tags/FREEFEM_3_5/freefem/admin/ltmain.sh

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