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

/tags/v-1-3-a5-release/SWIG/Tools/ltmain.sh

#
Shell | 2425 lines | 1935 code | 151 blank | 339 comment | 221 complexity | 09aa44e26600516ad104d79ea5e5df6b MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0

Large files files are truncated, but you can click here to view the full file

  1. # ltmain.sh - Provide generalized library-building support services.
  2. # NOTE: Changing this file will not affect anything until you rerun 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.4
  54. TIMESTAMP=" (1.385.2.196 1999/12/07 21:47:57)"
  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 \015\012 \040\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 $srcfile $pic_flag -DPIC"
  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. xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
  460. if test "X$xdir" = "X$obj"; then
  461. xdir="."
  462. else
  463. xdir="$xdir"
  464. fi
  465. baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`
  466. libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
  467. # Now arrange that obj and lo_libobj become the same file
  468. $show "(cd $xdir && $LN_S $baseobj $libobj)"
  469. if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
  470. exit 0
  471. else
  472. error=$?
  473. $run $rm $removelist
  474. exit $error
  475. fi
  476. fi
  477. # Allow error messages only from the first compilation.
  478. suppress_output=' >/dev/null 2>&1'
  479. fi
  480. # Only build a position-dependent object if we build old libraries.
  481. if test "$build_old_libs" = yes; then
  482. command="$base_compile $srcfile"
  483. if test "$compiler_c_o" = yes; then
  484. command="$command -o $obj"
  485. output_obj="$obj"
  486. fi
  487. # Suppress compiler output if we already did a PIC compilation.
  488. command="$command$suppress_output"
  489. $run $rm "$output_obj"
  490. $show "$command"
  491. if $run eval "$command"; then :
  492. else
  493. $run $rm $removelist
  494. exit 1
  495. fi
  496. if test "$need_locks" = warn &&
  497. test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
  498. echo "\
  499. *** ERROR, $lockfile contains:
  500. `cat $lockfile 2>/dev/null`
  501. but it should contain:
  502. $srcfile
  503. This indicates that another process is trying to use the same
  504. temporary object file, and libtool could not work around it because
  505. your compiler does not support \`-c' and \`-o' together. If you
  506. repeat this compilation, it may succeed, by chance, but you had better
  507. avoid parallel builds (make -j) in this platform, or get a better
  508. compiler."
  509. $run $rm $removelist
  510. exit 1
  511. fi
  512. # Just move the object if needed
  513. if test x"$output_obj" != x"$obj"; then
  514. $show "$mv $output_obj $obj"
  515. if $run $mv $output_obj $obj; then :
  516. else
  517. error=$?
  518. $run $rm $removelist
  519. exit $error
  520. fi
  521. fi
  522. # Create an invalid libtool object if no PIC, so that we do not
  523. # accidentally link it into a program.
  524. if test "$build_libtool_libs" != yes; then
  525. $show "echo timestamp > $libobj"
  526. $run eval "echo timestamp > \$libobj" || exit $?
  527. else
  528. # Move the .lo from within objdir
  529. $show "$mv $libobj $lo_libobj"
  530. if $run $mv $libobj $lo_libobj; then :
  531. else
  532. error=$?
  533. $run $rm $removelist
  534. exit $error
  535. fi
  536. fi
  537. fi
  538. # Unlock the critical section if it was locked
  539. if test "$need_locks" != no; then
  540. $rm "$lockfile"
  541. fi
  542. exit 0
  543. ;;
  544. # libtool link mode
  545. link)
  546. modename="$modename: link"
  547. case "$host" in
  548. *-*-cygwin* | *-*-mingw* | *-*-os2*)
  549. # It is impossible to link a dll without this setting, and
  550. # we shouldn't force the makefile maintainer to figure out
  551. # which system we are compiling for in order to pass an extra
  552. # flag for every libtool invokation.
  553. # allow_undefined=no
  554. # FIXME: Unfortunately, there are problems with the above when trying
  555. # to make a dll which has undefined symbols, in which case not
  556. # even a static library is built. For now, we need to specify
  557. # -no-undefined on the libtool link line when we can be certain
  558. # that all symbols are satisfied, otherwise we get a static library.
  559. allow_undefined=yes
  560. # This is a source program that is used to create dlls on Windows
  561. # Don't remove nor modify the starting and closing comments
  562. # /* ltdll.c starts here */
  563. # #define WIN32_LEAN_AND_MEAN
  564. # #include <windows.h>
  565. # #undef WIN32_LEAN_AND_MEAN
  566. # #include <stdio.h>
  567. #
  568. # #ifndef __CYGWIN__
  569. # # ifdef __CYGWIN32__
  570. # # define __CYGWIN__ __CYGWIN32__
  571. # # endif
  572. # #endif
  573. #
  574. # #ifdef __cplusplus
  575. # extern "C" {
  576. # #endif
  577. # BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
  578. # #ifdef __cplusplus
  579. # }
  580. # #endif
  581. #
  582. # #ifdef __CYGWIN__
  583. # #include <cygwin/cygwin_dll.h>
  584. # DECLARE_CYGWIN_DLL( DllMain );
  585. # #endif
  586. # HINSTANCE __hDllInstance_base;
  587. #
  588. # BOOL APIENTRY
  589. # DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
  590. # {
  591. # __hDllInstance_base = hInst;
  592. # return TRUE;
  593. # }
  594. # /* ltdll.c ends here */
  595. # This is a source program that is used to create import libraries
  596. # on Windows for dlls which lack them. Don't remove nor modify the
  597. # starting and closing comments
  598. # /* impgen.c starts here */
  599. # /* Copyright (C) 1999 Free Software Foundation, Inc.
  600. #
  601. # This file is part of GNU libtool.
  602. #
  603. # This program is free software; you can redistribute it and/or modify
  604. # it under the terms of the GNU General Public License as published by
  605. # the Free Software Foundation; either version 2 of the License, or
  606. # (at your option) any later version.
  607. #
  608. # This program is distributed in the hope that it will be useful,
  609. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  610. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  611. # GNU General Public License for more details.
  612. #
  613. # You should have received a copy of the GNU General Public License
  614. # along with this program; if not, write to the Free Software
  615. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  616. # */
  617. #
  618. # #include <stdio.h> /* for printf() */
  619. # #include <unistd.h> /* for open(), lseek(), read() */
  620. # #include <fcntl.h> /* for O_RDONLY, O_BINARY */
  621. # #include <string.h> /* for strdup() */
  622. #
  623. # static unsigned int
  624. # pe_get16 (fd, offset)
  625. # int fd;
  626. # int offset;
  627. # {
  628. # unsigned char b[2];
  629. # lseek (fd, offset, SEEK_SET);
  630. # read (fd, b, 2);
  631. # return b[0] + (b[1]<<8);
  632. # }
  633. #
  634. # static unsigned int
  635. # pe_get32 (fd, offset)
  636. # int fd;
  637. # int offset;
  638. # {
  639. # unsigned char b[4];
  640. # lseek (fd, offset, SEEK_SET);
  641. # read (fd, b, 4);
  642. # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
  643. # }
  644. #
  645. # static unsigned int
  646. # pe_as32 (ptr)
  647. # void *ptr;
  648. # {
  649. # unsigned char *b = ptr;
  650. # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
  651. # }
  652. #
  653. # int
  654. # main (argc, argv)
  655. # int argc;
  656. # char *argv[];
  657. # {
  658. # int dll;
  659. # unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
  660. # unsigned long export_rva, export_size, nsections, secptr, expptr;
  661. # unsigned long name_rvas, nexp;
  662. # unsigned char *expdata, *erva;
  663. # char *filename, *dll_name;
  664. #
  665. # filename = argv[1];
  666. #
  667. # dll = open(filename, O_RDONLY|O_BINARY);
  668. # if (!dll)
  669. # return 1;
  670. #
  671. # dll_name = filename;
  672. #
  673. # for (i=0; filename[i]; i++)
  674. # if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':')
  675. # dll_name = filename + i +1;
  676. #
  677. # pe_header_offset = pe_get32 (dll, 0x3c);
  678. # opthdr_ofs = pe_header_offset + 4 + 20;
  679. # num_entries = pe_get32 (dll, opthdr_ofs + 92);
  680. #
  681. # if (num_entries < 1) /* no exports */
  682. # return 1;
  683. #
  684. # export_rva = pe_get32 (dll, opthdr_ofs + 96);
  685. # export_size = pe_get32 (dll, opthdr_ofs + 100);
  686. # nsections = pe_get16 (dll, pe_header_offset + 4 +2);
  687. # secptr = (pe_header_offset + 4 + 20 +
  688. # pe_get16 (dll, pe_header_offset + 4 + 16));
  689. #
  690. # expptr = 0;
  691. # for (i = 0; i < nsections; i++)
  692. # {
  693. # char sname[8];
  694. # unsigned long secptr1 = secptr + 40 * i;
  695. # unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
  696. # unsigned long vsize = pe_get32 (dll, secptr1 + 16);
  697. # unsigned long fptr = pe_get32 (dll, secptr1 + 20);
  698. # lseek(dll, secptr1, SEEK_SET);
  699. # read(dll, sname, 8);
  700. # if (vaddr <= export_rva && vaddr+vsize > export_rva)
  701. # {
  702. # expptr = fptr + (export_rva - vaddr);
  703. # if (export_rva + export_size > vaddr + vsize)
  704. # export_size = vsize - (export_rva - vaddr);
  705. # break;
  706. # }
  707. # }
  708. #
  709. # expdata = (unsigned char*)malloc(export_size);
  710. # lseek (dll, expptr, SEEK_SET);
  711. # read (dll, expdata, export_size);
  712. # erva = expdata - export_rva;
  713. #
  714. # nexp = pe_as32 (expdata+24);
  715. # name_rvas = pe_as32 (expdata+32);
  716. #
  717. # printf ("EXPORTS\n");
  718. # for (i = 0; i<nexp; i++)
  719. # {
  720. # unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
  721. # printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
  722. # }
  723. #
  724. # return 0;
  725. # }
  726. # /* impgen.c ends here */
  727. ;;
  728. *)
  729. allow_undefined=yes
  730. ;;
  731. esac
  732. compile_command="$nonopt"
  733. finalize_command="$nonopt"
  734. compile_rpath=
  735. finalize_rpath=
  736. compile_shlibpath=
  737. finalize_shlibpath=
  738. convenience=
  739. old_convenience=
  740. deplibs=
  741. linkopts=
  742. if test -n "$shlibpath_var"; then
  743. # get the directories listed in $shlibpath_var
  744. eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
  745. else
  746. lib_search_path=
  747. fi
  748. # now prepend the system-specific ones
  749. eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\"
  750. eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
  751. avoid_version=no
  752. dlfiles=
  753. dlprefiles=
  754. dlself=no
  755. export_dynamic=no
  756. export_symbols=
  757. export_symbols_regex=
  758. generated=
  759. libobjs=
  760. link_against_libtool_libs=
  761. ltlibs=
  762. module=no
  763. objs=
  764. prefer_static_libs=no
  765. preload=no
  766. prev=
  767. prevarg=
  768. release=
  769. rpath=
  770. xrpath=
  771. perm_rpath=
  772. temp_rpath=
  773. thread_safe=no
  774. vinfo=
  775. # We need to know -static, to get the right output filenames.
  776. for arg
  777. do
  778. case "$arg" in
  779. -all-static | -static)
  780. if test "X$arg" = "X-all-static"; then
  781. if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
  782. $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
  783. fi
  784. if test -n "$link_static_flag"; then
  785. dlopen_self=$dlopen_self_static
  786. fi
  787. else
  788. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  789. dlopen_self=$dlopen_self_static
  790. fi
  791. fi
  792. build_libtool_libs=no
  793. build_old_libs=yes
  794. prefer_static_libs=yes
  795. break
  796. ;;
  797. esac
  798. done
  799. # See if our shared archives depend on static archives.
  800. test -n "$old_archive_from_new_cmds" && build_old_libs=yes
  801. # Go through the arguments, transforming them on the way.
  802. while test $# -gt 0; do
  803. arg="$1"
  804. shift
  805. # If the previous option needs an argument, assign it.
  806. if test -n "$prev"; then
  807. case "$prev" in
  808. output)
  809. compile_command="$compile_command @OUTPUT@"
  810. finalize_command="$finalize_command @OUTPUT@"
  811. ;;
  812. esac
  813. case "$prev" in
  814. dlfiles|dlprefiles)
  815. if test "$preload" = no; then
  816. # Add the symbol object into the linking commands.
  817. compile_command="$compile_command @SYMFILE@"
  818. finalize_command="$finalize_command @SYMFILE@"
  819. preload=yes
  820. fi
  821. case "$arg" in
  822. *.la | *.lo) ;; # We handle these cases below.
  823. force)
  824. if test "$dlself" = no; then
  825. dlself=needless
  826. export_dynamic=yes
  827. fi
  828. prev=
  829. continue
  830. ;;
  831. self)
  832. if test "$prev" = dlprefiles; then
  833. dlself=yes
  834. elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
  835. dlself=yes
  836. else
  837. dlself=needless
  838. export_dynamic=yes
  839. fi
  840. prev=
  841. continue
  842. ;;
  843. *)
  844. if test "$prev" = dlfiles; then
  845. dlfiles="$dlfiles $arg"
  846. else
  847. dlprefiles="$dlprefiles $arg"
  848. fi
  849. prev=
  850. ;;
  851. esac
  852. ;;
  853. expsyms)
  854. export_symbols="$arg"
  855. if test ! -f "$arg"; then
  856. $echo "$modename: symbol file \`$arg' does not exist"
  857. exit 1
  858. fi
  859. prev=
  860. continue
  861. ;;
  862. expsyms_regex)
  863. export_symbols_regex="$arg"
  864. prev=
  865. continue
  866. ;;
  867. release)
  868. release="-$arg"
  869. prev=
  870. continue
  871. ;;
  872. rpath | xrpath)
  873. # We need an absolute path.
  874. case "$arg" in
  875. [\\/]* | [A-Za-z]:[\\/]*) ;;
  876. *)
  877. $echo "$modename: only absolute run-paths are allowed" 1>&2
  878. exit 1
  879. ;;
  880. esac
  881. if test "$prev" = rpath; then
  882. case "$rpath " in
  883. *" $arg "*) ;;
  884. *) rpath="$rpath $arg" ;;
  885. esac
  886. else
  887. case "$xrpath " in
  888. *" $arg "*) ;;
  889. *) xrpath="$xrpath $arg" ;;
  890. esac
  891. fi
  892. prev=
  893. continue
  894. ;;
  895. *)
  896. eval "$prev=\"\$arg\""
  897. prev=
  898. continue
  899. ;;
  900. esac
  901. fi
  902. prevarg="$arg"
  903. case "$arg" in
  904. -all-static)
  905. if test -n "$link_static_flag"; then
  906. compile_command="$compile_command $link_static_flag"
  907. finalize_command="$finalize_command $link_static_flag"
  908. fi
  909. continue
  910. ;;
  911. -allow-undefined)
  912. # FIXME: remove this flag sometime in the future.
  913. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
  914. continue
  915. ;;
  916. -avoid-version)
  917. avoid_version=yes
  918. continue
  919. ;;
  920. -dlopen)
  921. prev=dlfiles
  922. continue
  923. ;;
  924. -dlpreopen)
  925. prev=dlprefiles
  926. continue
  927. ;;
  928. -export-dynamic)
  929. export_dynamic=yes
  930. continue
  931. ;;
  932. -export-symbols | -export-symbols-regex)
  933. if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  934. $echo "$modename: not more than one -exported-symbols argument allowed"
  935. exit 1
  936. fi
  937. if test "X$arg" = "X-export-symbols"; then
  938. prev=expsyms
  939. else
  940. prev=expsyms_regex
  941. fi
  942. continue
  943. ;;
  944. -L*)
  945. dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
  946. # We need an absolute path.
  947. case "$dir" in
  948. [\\/]* | [A-Za-z]:[\\/]*) ;;
  949. *)
  950. absdir=`cd "$dir" && pwd`
  951. if test -z "$absdir"; then
  952. $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
  953. $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
  954. absdir="$dir"
  955. fi
  956. dir="$absdir"
  957. ;;
  958. esac
  959. case " $deplibs " in
  960. *" $arg "*) ;;
  961. *) deplibs="$deplibs $arg";;
  962. esac
  963. case " $lib_search_path " in
  964. *" $dir "*) ;;
  965. *) lib_search_path="$lib_search_path $dir";;
  966. esac
  967. case "$host" in
  968. *-*-cygwin* | *-*-mingw* | *-*-os2*)
  969. dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
  970. case ":$dllsearchpath:" in
  971. ::) dllsearchpath="$dllsearchdir";;
  972. *":$dllsearchdir:"*) ;;
  973. *) dllsearchpath="$dllsearchpath:$dllsearchdir";;
  974. esac
  975. ;;
  976. esac
  977. ;;
  978. -l*)
  979. if test "$arg" = "-lc"; then
  980. case "$host" in
  981. *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
  982. # These systems don't actually have c library (as such)
  983. continue
  984. ;;
  985. esac
  986. elif test "$arg" = "-lm"; then
  987. case "$host" in
  988. *-*-cygwin* | *-*-beos*)
  989. # These systems don't actually have math library (as such)
  990. continue
  991. ;;
  992. esac
  993. fi
  994. deplibs="$deplibs $arg"
  995. ;;
  996. -module)
  997. module=yes
  998. continue
  999. ;;
  1000. -no-undefined)
  1001. allow_undefined=no
  1002. continue
  1003. ;;
  1004. -o) prev=output ;;
  1005. -release)
  1006. prev=release
  1007. continue
  1008. ;;
  1009. -rpath)
  1010. prev=rpath
  1011. continue
  1012. ;;
  1013. -R)
  1014. prev=xrpath
  1015. continue
  1016. ;;
  1017. -R*)
  1018. dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
  1019. # We need an absolute path.
  1020. case "$dir" in
  1021. [\\/]* | [A-Za-z]:[\\/]*) ;;
  1022. *)
  1023. $echo "$modename: only absolute run-paths are allowed" 1>&2
  1024. exit 1
  1025. ;;
  1026. esac
  1027. case "$xrpath " in
  1028. *" $dir "*) ;;
  1029. *) xrpath="$xrpath $dir" ;;
  1030. esac
  1031. continue
  1032. ;;
  1033. -static)
  1034. # If we have no pic_flag, then this is the same as -all-static.
  1035. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  1036. compile_command="$compile_command $link_static_flag"
  1037. finalize_command="$finalize_command $link_static_flag"
  1038. fi
  1039. continue
  1040. ;;
  1041. -thread-safe)
  1042. thread_safe=yes
  1043. continue
  1044. ;;
  1045. -version-info)
  1046. prev=vinfo
  1047. continue
  1048. ;;
  1049. # Some other compiler flag.
  1050. -* | +*)
  1051. # Unknown arguments in both finalize_command and compile_command need
  1052. # to be aesthetically quoted because they are evaled later.
  1053. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
  1054. case "$arg" in
  1055. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
  1056. arg="\"$arg\""
  1057. ;;
  1058. esac
  1059. ;;
  1060. *.o | *.obj | *.a | *.lib)
  1061. # A standard object.
  1062. objs="$objs $arg"
  1063. ;;
  1064. *.lo)
  1065. # A library object.
  1066. if test "$prev" = dlfiles; then
  1067. dlfiles="$dlfiles $arg"
  1068. if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
  1069. prev=
  1070. continue
  1071. else
  1072. # If libtool objects are unsupported, then we need to preload.
  1073. prev=dlprefiles
  1074. fi
  1075. fi
  1076. if test "$prev" = dlprefiles; then
  1077. # Preload the old-style object.
  1078. dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
  1079. prev=
  1080. fi
  1081. libobjs="$libobjs $arg"
  1082. ;;
  1083. *.la)
  1084. # A libtool-controlled library.
  1085. dlname=
  1086. libdir=
  1087. library_names=
  1088. old_library=
  1089. # Check to see that this really is a libtool archive.
  1090. if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
  1091. else
  1092. $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
  1093. exit 1
  1094. fi
  1095. # If the library was installed with an old release of libtool,
  1096. # it will not redefine variable installed.
  1097. installed=yes
  1098. # Read the .la file
  1099. # If there is no directory component, then add one.
  1100. case "$arg" in
  1101. */* | *\\*) . $arg ;;
  1102. *) . ./$arg ;;
  1103. esac
  1104. # Get the name of the library we link against.
  1105. linklib=
  1106. for l in $old_library $library_names; do
  1107. linklib="$l"
  1108. done
  1109. if test -z "$linklib"; then
  1110. $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
  1111. exit 1
  1112. fi
  1113. # Find the relevant object directory and library name.
  1114. name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
  1115. if test "X$installed" = Xyes; then
  1116. dir="$libdir"
  1117. else
  1118. dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
  1119. if test "X$dir" = "X$arg"; then
  1120. dir="$objdir"
  1121. else
  1122. dir="$dir/$objdir"
  1123. fi
  1124. fi
  1125. if test -n "$dependency_libs"; then
  1126. # Extract -R and -L from dependency_libs
  1127. temp_deplibs=
  1128. for deplib in $dependency_libs; do
  1129. case "$deplib" in
  1130. -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
  1131. case " $rpath $xrpath " in
  1132. *" $temp_xrpath "*) ;;
  1133. *) xrpath="$xrpath $temp_xrpath";;
  1134. esac;;
  1135. -L*) case "$compile_command $temp_deplibs " in
  1136. *" $deplib "*) ;;
  1137. *) temp_deplibs="$temp_deplibs $deplib";;
  1138. esac
  1139. temp_dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'`
  1140. case " $lib_search_path " in
  1141. *" $temp_dir "*) ;;
  1142. *) lib_search_path="$lib_search_path $temp_dir";;
  1143. esac
  1144. ;;
  1145. *) temp_deplibs="$temp_deplibs $deplib";;
  1146. esac
  1147. done
  1148. dependency_libs="$temp_deplibs"
  1149. fi
  1150. if test -z "$libdir"; then
  1151. # It is a libtool convenience library, so add in its objects.
  1152. convenience="$convenience $dir/$old_library"
  1153. old_convenience="$old_convenience $dir/$old_library"
  1154. deplibs="$deplibs$dependency_libs"
  1155. compile_command="$compile_command $dir/$old_library$dependency_libs"
  1156. finalize_command="$finalize_command $dir/$old_library$dependency_libs"
  1157. continue
  1158. fi
  1159. # This library was specified with -dlopen.
  1160. if test "$prev" = dlfiles; then
  1161. dlfiles="$dlfiles $arg"
  1162. if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
  1163. # If there is no dlname, no dlopen support or we're linking statically,
  1164. # we need to preload.
  1165. prev=dlprefiles
  1166. else
  1167. # We should not create a dependency on this library, but we
  1168. # may need any libraries it requires.
  1169. compile_command="$compile_command$dependency_libs"
  1170. finalize_command="$finalize_command$dependency_libs"
  1171. prev=
  1172. continue
  1173. fi
  1174. fi
  1175. # The library was specified with -dlpreopen.
  1176. if test "$prev" = dlprefiles; then
  1177. # Prefer using a static library (so that no silly _DYNAMIC symbols
  1178. # are required to link).
  1179. if test -n "$old_library"; then
  1180. dlprefiles="$dlprefiles $dir/$old_library"
  1181. else
  1182. dlprefiles="$dlprefiles $dir/$linklib"
  1183. fi
  1184. prev=
  1185. fi
  1186. if test -n "$library_names" &&
  1187. { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
  1188. link_against_libtool_libs="$link_against_libtool_libs $arg"
  1189. if test -n "$shlibpath_var"; then
  1190. # Make sure the rpath contains only unique directories.
  1191. case "$temp_rpath " in
  1192. *" $dir "*) ;;
  1193. *) temp_rpath="$temp_rpath $dir" ;;
  1194. esac
  1195. fi
  1196. # We need an absolute path.
  1197. case "$dir" in
  1198. [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;;
  1199. *)
  1200. absdir=`cd "$dir" && pwd`
  1201. if test -z "$absdir"; then
  1202. $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
  1203. $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
  1204. absdir="$dir"
  1205. fi
  1206. ;;
  1207. esac
  1208. # This is the magic to use -rpath.
  1209. # Skip directories that are in the system default run-time
  1210. # search path, unless they have been requested with -R.
  1211. case " $sys_lib_dlsearch_path " in
  1212. *" $absdir "*) ;;
  1213. *)
  1214. case "$compile_rpath " in
  1215. *" $absdir "*) ;;
  1216. *) compile_rpath="$compile_rpath $absdir"
  1217. esac
  1218. ;;
  1219. esac
  1220. case " $sys_lib_dlsearch_path " in
  1221. *" $libdir "*) ;;
  1222. *)
  1223. case "$finalize_rpath " in
  1224. *" $libdir "*) ;;
  1225. *) finalize_rpath="$finalize_rpath $libdir"
  1226. esac
  1227. ;;
  1228. esac
  1229. lib_linked=yes
  1230. case "$hardcode_action" in
  1231. immediate | unsupported)
  1232. if test "$hardcode_direct" = no; then
  1233. compile_command="$compile_command $dir/$linklib"
  1234. deplibs="$deplibs $dir/$linklib"
  1235. case "$host" in
  1236. *-*-cygwin* | *-*-mingw* | *-*-os2*)
  1237. dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
  1238. if test -n "$dllsearchpath"; then
  1239. dllsearchpath="$dllsearchpath:$dllsearchdir"
  1240. else
  1241. dllsearchpath="$dllsearchdir"
  1242. fi
  1243. ;;
  1244. esac
  1245. elif test "$hardcode_minus_L" = no; then
  1246. case "$host" in
  1247. *-*-sunos*)
  1248. compile_shlibpath="$compile_shlibpath$dir:"
  1249. ;;
  1250. esac
  1251. case "$compile_command " in
  1252. *" -L$dir "*) ;;
  1253. *) compile_command="$compile_command -L$dir";;
  1254. esac
  1255. compile_command="$compile_command -l$name"
  1256. deplibs="$deplibs -L$dir -l$name"
  1257. elif test "$hardcode_shlibpath_var" = no; then
  1258. case ":$compile_shlibpath:" in
  1259. *":$dir:"*) ;;
  1260. *) compile_shlibpath="$compile_shlibpath$dir:";;
  1261. esac
  1262. compile_command="$compile_command -l$name"
  1263. deplibs="$deplibs -l$name"
  1264. else
  1265. lib_linked=no
  1266. fi
  1267. ;;
  1268. relink)
  1269. if test "$hardcode_direct" = yes; then
  1270. compile_command="$compile_command $absdir/$linklib"
  1271. deplibs="$deplibs $absdir/$linklib"
  1272. elif test "$hardcode_minus_L" = yes; then
  1273. case "$compile_command " in
  1274. *" -L$absdir "*) ;;
  1275. *) compile_command="$compile_command -L$absdir";;
  1276. esac
  1277. compile_command="$compile_command -l$name"
  1278. deplibs="$deplibs -L$absdir -l$name"
  1279. elif test "$hardcode_shlibpath_var" = yes; then
  1280. case ":$compile_shlibpath:" in
  1281. *":$absdir:"*) ;;
  1282. *) compile_shlibpath="$compile_shlibpath$absdir:";;
  1283. esac
  1284. compile_command="$compile_command -l$name"
  1285. deplibs="$deplibs -l$name"
  1286. else
  1287. lib_linked=no
  1288. fi
  1289. ;;
  1290. *)
  1291. lib_linked=no
  1292. ;;
  1293. esac
  1294. if test "$lib_linked" != yes; then
  1295. $echo "$modename: configuration error: unsupported hardcode properties"
  1296. exit 1
  1297. fi
  1298. # Finalize command for both is simple: just hardcode it.
  1299. if test "$hardcode_direct" = yes; then
  1300. finalize_command="$finalize_command $libdir/$linklib"
  1301. elif test "$hardcode_minus_L" = yes; then
  1302. case "$finalize_command " in
  1303. *" -L$libdir "*) ;;
  1304. *) finalize_command="$finalize_command -L$libdir";;
  1305. esac
  1306. finalize_command="$finalize_command -l$name"
  1307. elif test "$hardcode_shlibpath_var" = yes; then
  1308. case ":$finalize_shlibpath:" in
  1309. *":$libdir:"*) ;;
  1310. *) finalize_shlibpath="$finalize_shlibpath$libdir:";;
  1311. esac
  1312. finalize_command="$finalize_command -l$name"
  1313. else
  1314. # We cannot seem to hardcode it, guess we'll fake it.
  1315. case "$finalize_command " in
  1316. *" -L$dir "*) ;;
  1317. *) finalize_command="$finalize_command -L$libdir";;
  1318. esac
  1319. finalize_command="$finalize_command -l$name"
  1320. fi
  1321. else
  1322. # Transform directly to old archives if we don't build new libraries.
  1323. if test -n "$pic_flag" && test -z "$old_library"; then
  1324. $echo "$modename: cannot find static library for \`$arg'" 1>&2
  1325. exit 1
  1326. fi
  1327. # Here we assume that one of hardcode_direct or hardcode_minus_L
  1328. # is not unsupported. This is valid on all known static and
  1329. # shared platforms.
  1330. if test "$hardcode_direct" != unsupported; then
  1331. test -n "$old_library" && linklib="$old_library"
  1332. compile_command="$compile_command $dir/$linklib"
  1333. finalize_command="$finalize_command $dir/$linklib"
  1334. else
  1335. case "$compile_command " in
  1336. *" -L$dir "*) ;;
  1337. *) compile_command="$compile_command -L$dir";;
  1338. esac
  1339. compile_command="$compile_command -l$name"
  1340. case "$finalize_command " in
  1341. *" -L$dir "*) ;;
  1342. *) finalize_command="$finalize_command -L$dir";;
  1343. esac
  1344. finalize_command="$finalize_command -l$name"
  1345. fi
  1346. fi
  1347. # Add in any libraries that this one depends upon.
  1348. compile_command="$compile_command$dependency_libs"
  1349. finalize_command="$finalize_command$dependency_libs"
  1350. continue
  1351. ;;
  1352. # Some other compiler argument.
  1353. *)
  1354. # Unknown arguments in both finalize_command and compile_command need
  1355. # to be aesthetically quoted because they are evaled later.
  1356. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
  1357. case "$arg" in
  1358. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*)
  1359. arg="\"$arg\""
  1360. ;;
  1361. esac
  1362. ;;
  1363. esac
  1364. # Now actually substitute the argument into the commands.
  1365. if test -n "$arg"; then
  1366. compile_command="$compile_command $arg"
  1367. finalize_command="$finalize_command $arg"
  1368. fi
  1369. done
  1370. if test -n "$prev"; then
  1371. $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
  1372. $echo "$help" 1>&2
  1373. exit 1
  1374. fi
  1375. if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
  1376. eval arg=\"$export_dynamic_flag_spec\"
  1377. compile_command="$compile_command $arg"
  1378. finalize_command="$finalize_command $arg"
  1379. fi
  1380. oldlibs=
  1381. # calculate the name of the file, without its directory
  1382. outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
  1383. libobjs_save="$libobjs"
  1384. case "$output" in
  1385. "")
  1386. $echo "$modename: you must specify an output file" 1>&2
  1387. $echo "$help" 1>&2
  1388. exit 1
  1389. ;;
  1390. *.a | *.lib)
  1391. if test -n "$link_against_libtool_libs"; then
  1392. $echo "$modename: error: cannot link libtool libraries into archives" 1>&2
  1393. exit 1
  1394. fi
  1395. if test -n "$deplibs"; then
  1396. $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
  1397. fi
  1398. if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  1399. $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
  1400. fi
  1401. if test -n "$rpath"; then
  1402. $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
  1403. fi
  1404. if test -n "$xrpath"; then
  1405. $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
  1406. fi
  1407. if test -n "$vinfo"; then
  1408. $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
  1409. fi
  1410. if test -n "$release"; then
  1411. $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
  1412. fi
  1413. if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  1414. $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
  1415. fi
  1416. # Now set the variables for building old libraries.
  1417. build_libtool_libs=no
  1418. oldlibs="$output"
  1419. ;;
  1420. *.la)
  1421. # Make sure we only generate libraries of the form `libNAME.la'.
  1422. case "$outputname" in
  1423. lib*)
  1424. name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
  1425. eval libname=\"$libname_spec\"
  1426. ;;
  1427. *)
  1428. if test "$module" = no; then
  1429. $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
  1430. $echo "$help" 1>&2
  1431. exit 1
  1432. fi
  1433. if test "$need_lib_prefix" != no; then
  1434. # Add the "lib" prefix for modules if required
  1435. name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
  1436. eval libname=\"$libname_spec\"
  1437. else
  1438. libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
  1439. fi
  1440. ;;
  1441. esac
  1442. output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
  1443. if test "X$output_objdir" = "X$output"; then
  1444. output_objdir="$objdir"
  1445. else
  1446. output_objdir="$output_objdir/$objdir"
  1447. fi
  1448. if test -n "$objs"; then
  1449. $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
  1450. exit 1
  1451. fi
  1452. # How the heck are we supposed to write a wrapper for a shared library?
  1453. if test -n "$link_against_libtool_libs"; then
  1454. $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
  1455. exit 1
  1456. fi
  1457. if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
  1458. $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
  1459. fi
  1460. set dummy $rpath
  1461. if test $# -gt 2; then
  1462. $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
  1463. fi
  1464. install_libdir="$2"
  1465. oldlibs=
  1466. if test -z "$rpath"; then
  1467. if test "$build_libtool_libs" = yes; then
  1468. # Building a libtool convenience library.
  1469. libext=al
  1470. oldlibs="$output_objdir/$libname.$libext $oldlibs"
  1471. build_libtool_libs=convenience
  1472. build_old_libs=yes
  1473. fi
  1474. dependency_libs="$deplibs"
  1475. if test -n "$vinfo"; then
  1476. $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
  1477. fi
  1478. if test -n "$release"; then
  1479. $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
  1480. fi
  1481. else
  1482. # Parse the version information argument.
  1483. IFS="${IFS= }"; save_ifs="$IFS"; IFS=':'
  1484. set dummy $vinfo 0 0 0
  1485. IFS="$save_ifs"
  1486. if test -n "$8"; then
  1487. $echo "$modename: too many parameters to \`-version-info'" 1>&2
  1488. $echo "$help" 1>&2
  1489. exit 1
  1490. fi
  1491. current="$2"
  1492. revision="$3"
  1493. age="$4"
  1494. # Check that each of the things are valid numbers.
  1495. case "$current" in
  1496. 0 | [1-9] | [1-9][0-9]*) ;;
  1497. *)
  1498. $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
  1499. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1500. exit 1
  1501. ;;
  1502. esac
  1503. case "$revision" in
  1504. 0 | [1-9] | [1-9][0-9]*) ;;
  1505. *)
  1506. $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
  1507. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1508. exit 1
  1509. ;;
  1510. esac
  1511. case "$age" in
  1512. 0 | [1-9] | [1-9][0-9]*) ;;
  1513. *)
  1514. $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
  1515. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1516. exit 1
  1517. ;;
  1518. esac
  1519. if test $age -gt $current; then
  1520. $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
  1521. $echo "$modename: \`$vinfo' is not valid version information" 1>&2
  1522. exit 1
  1523. fi
  1524. # Calculate the version variables.
  1525. major=
  1526. versuffix=
  1527. verstring=
  1528. case "$version_type" in
  1529. none) ;;
  1530. irix)
  1531. major=`expr $current - $age + 1`
  1532. versuffix="$major.$revision"
  1533. verstring="sgi$major.$revision"
  1534. # Add in all the interfaces that we are compatible with.
  1535. loop=$revision
  1536. while test $loop != 0; do
  1537. iface=`expr $revision - $loop`
  1538. loop=`expr $loop - 1`
  1539. verstring="sgi$major.$iface:$verstring"
  1540. done
  1541. ;;
  1542. linux)
  1543. major=.`expr $current - $age`
  1544. versuffix="$major.$age.$revision"
  1545. ;;
  1546. osf)
  1547. major=`expr $current - $age`
  1548. versuffix=".$current.$age.$revision"
  1549. verstring="$current.$age.$revision"
  1550. # Add in all the interfaces that we are compatible with.
  1551. loop=$age
  1552. while test $loop != 0; do
  1553. iface=`expr $current - $loop`
  1554. loop=`expr $loop - 1`
  1555. verstring="$verstring:${iface}.0"
  1556. done
  1557. # Make executables depend on our current version.
  1558. verstring="$verstring:${current}.0"
  1559. ;;
  1560. sunos)
  1561. major=".$current"
  1562. versuffix=".$current.$revision"
  1563. ;;
  1564. freebsd-aout)
  1565. major=".$current"
  1566. versuffix=".$current.$revision";
  1567. ;;
  1568. freebsd-elf)
  1569. major=".$current"
  1570. versuffix=".$current";
  1571. ;;
  1572. windows)
  1573. # Like Linux, but with '-' rather than '.', since we only
  1574. # want one extension on Windows 95.
  1575. major=`expr $current - $age`
  1576. versuffix="-$major-$age-$revision"
  1577. ;;
  1578. *)
  1579. $echo "$modename: unknown library version type \`$version_type'" 1>&2
  1580. echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2
  1581. exit 1
  1582. ;;
  1583. esac
  1584. # Clear the version info if we defaulted, and they specified a release.
  1585. if test -z "$vinfo" && test -n "$release"; then
  1586. major=
  1587. verstring="0.0"
  1588. if test "$need_version" = no; then
  1589. versuffix=
  1590. else
  1591. versuffix=".0.0"
  1592. fi
  1593. fi
  1594. # Remove version info from name if versioning should be avoided
  1595. if test "$avoid_version" = yes && test "$need_version" = no; then
  1596. major=
  1597. versuffix=
  1598. verstring=""
  1599. fi
  1600. # Check to see if the archive will have undefined symbols.
  1601. if test "$allow_undefined" = yes; then
  1602. if test "$allow_undefined_flag" = unsupported; then
  1603. $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
  1604. build_libtool_libs=no
  1605. build_old_libs=yes
  1606. fi
  1607. else
  1608. # Don't allow undefined symbols.
  1609. allow_undefined_flag="$no_undefined_flag"
  1610. fi
  1611. dependency_libs="$deplibs"
  1612. case "$host" in
  1613. *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*)
  1614. # these systems don't actually have a c library (as such)!
  1615. ;;
  1616. *)
  1617. # Add libc to deplibs on all other systems.
  1618. deplibs="$deplibs -lc"
  1619. ;;
  1620. esac
  1621. fi
  1622. # Create the output directory, or remove our outputs if we need to.
  1623. if test -d $output_objdir; then
  1624. $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
  1625. $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
  1626. else
  1627. $show "$mkdir $output_objdir"
  1628. $run $mkdir $output_objdir
  1629. status=$?
  1630. if test $status -ne 0 && test ! -d $output_objdir; then
  1631. exit $status
  1632. fi
  1633. fi
  1634. # Now set the variables for building old libraries.
  1635. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
  1636. oldlibs="$oldlibs $output_objdir/$libname.$libext"
  1637. # Transform .lo files to .o files.
  1638. oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
  1639. fi
  1640. if test "$build_libtool_libs" = yes; then
  1641. # Transform deplibs into only deplibs that can be linked in shared.
  1642. name_save=$name
  1643. libname_save=$libname
  1644. release_save=$release
  1645. versuffix_save=$versuffix
  1646. major_save=$major
  1647. # I'm not sure if I'm treating the release correctly. I think
  1648. # release should show up in the -l (ie -lgmp5) so we don't want to
  1649. # add it in twice. Is that correct?
  1650. release=""
  1651. versuffix=""
  1652. major=""
  1653. newdeplibs=
  1654. droppeddeps=no
  1655. case "$deplibs_check_method" in
  1656. pass_all)
  1657. # Don't check for shared/static. Everything works.
  1658. # This might be a little naive. We might want to check
  1659. # whether the library exists or not. But this is on
  1660. # osf3 & osf4 and I'm not really sure... Just
  1661. # implementing what was already the behaviour.
  1662. newdeplibs=$deplibs
  1663. ;;
  1664. test_compile)
  1665. # This code stresses the "libraries are programs" paradigm to its
  1666. # limits. Maybe even breaks it. We compile a program, linking it
  1667. # against the deplibs as a proxy for the library. Then we can check
  1668. # whether they linked in statically or dynamically with ldd.
  1669. $rm conftest.c
  1670. cat > conftest.c <<EOF
  1671. int main() { return 0; }
  1672. EOF
  1673. $rm conftest
  1674. $CC -o conftest conftest.c $deplibs
  1675. if test $? -eq 0 ; then
  1676. ldd_output=`ldd conftest`
  1677. for i in $deplibs; do
  1678. name="`expr $i : '-l\(.*\)'`"
  1679. # If $name is empty we are operating on a -L argument.
  1680. if test "$name" != "" ; then
  1681. libname=`eval \\$echo \"$libname_spec\"`
  1682. deplib_matches=`eval \\$echo \"$library_names_spec\"`
  1683. set dummy $deplib_matches
  1684. deplib_match=$2
  1685. if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
  1686. newdeplibs="$newdeplibs $i"
  1687. else
  1688. droppeddeps=yes
  1689. echo
  1690. echo "*** Warning: This library needs some functionality provided by $i."
  1691. echo "*** I have the capability to make that library automatically link in when"
  1692. echo "*** you link to this library. But I can only do this if you have a"
  1693. echo "*** shared version of the library, which you do not appear to have."
  1694. fi
  1695. else
  1696. newdeplibs="$newdeplibs $i"
  1697. fi
  1698. done
  1699. else
  1700. # Error occured in the first compile. Let's try to salvage the situation:
  1701. # Compile a seperate program for each library.
  1702. for i in $deplibs; do
  1703. name="`expr $i : '-l\(.*\)'`"
  1704. # If $name is empty we are operating on a -L argument.
  1705. if test "$name" != "" ; then
  1706. $rm conftest
  1707. $CC -o conftest conftest.c $i
  1708. # Did it work?
  1709. if test $? -eq 0 ; then
  1710. ldd_output=`ldd conftest`
  1711. libname=`eval \\$echo \"$libname_spec\"`
  1712. deplib_matches=`eval \\$echo \"$library_names_spec\"`
  1713. set dummy $deplib_matches
  1714. deplib_match=$2
  1715. if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
  1716. newdeplibs="$newdeplibs $i"
  1717. else
  1718. droppeddeps=yes
  1719. echo
  1720. echo "*** Warning: This library needs some functionality provided by $i."
  1721. echo "*** I have the capability to make that library automatically link in when"
  1722. echo "*** you link to this library. But I can only do this if you have a"
  1723. echo "*** shared version of the library, which you do not a…

Large files files are truncated, but you can click here to view the full file