You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11659 lines
332KB

  1. #! /bin/sh
  2. # Generated automatically by config.status (jansson) 2.10
  3. # Libtool was configured on host TERA:
  4. # NOTE: Changes made to this file will be lost: look at ltmain.sh.
  5. # Provide generalized library-building support services.
  6. # Written by Gordon Matzigkeit, 1996
  7. # Copyright (C) 2014 Free Software Foundation, Inc.
  8. # This is free software; see the source for copying conditions. There is NO
  9. # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # GNU Libtool is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of of the License, or
  13. # (at your option) any later version.
  14. #
  15. # As a special exception to the GNU General Public License, if you
  16. # distribute this file as part of a program or library that is built
  17. # using GNU Libtool, you may include this file under the same
  18. # distribution terms that you use for the rest of that program.
  19. #
  20. # GNU Libtool is distributed in the hope that it will be useful, but
  21. # WITHOUT ANY WARRANTY; without even the implied warranty of
  22. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. # GNU General Public License for more details.
  24. #
  25. # You should have received a copy of the GNU General Public License
  26. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. # The names of the tagged configurations supported by this script.
  28. available_tags=''
  29. # Configured defaults for sys_lib_dlsearch_path munging.
  30. : ${LT_SYS_LIBRARY_PATH=""}
  31. # ### BEGIN LIBTOOL CONFIG
  32. # Which release of libtool.m4 was used?
  33. macro_version=2.4.6
  34. macro_revision=2.4.6
  35. # Whether or not to build shared libraries.
  36. build_libtool_libs=yes
  37. # Whether or not to build static libraries.
  38. build_old_libs=yes
  39. # What type of objects to build.
  40. pic_mode=default
  41. # Whether or not to optimize for fast installation.
  42. fast_install=needless
  43. # Shared archive member basename,for filename based shared library versioning on AIX.
  44. shared_archive_member_spec=
  45. # Shell to use when invoking shell scripts.
  46. SHELL="/bin/sh"
  47. # An echo program that protects backslashes.
  48. ECHO="printf %s\\n"
  49. # The PATH separator for the build system.
  50. PATH_SEPARATOR=":"
  51. # The host system.
  52. host_alias=
  53. host=x86_64-w64-mingw32
  54. host_os=mingw32
  55. # The build system.
  56. build_alias=x86_64-w64-mingw32
  57. build=x86_64-w64-mingw32
  58. build_os=mingw32
  59. # A sed program that does not truncate output.
  60. SED="/usr/bin/sed"
  61. # Sed that helps us avoid accidentally triggering echo(1) options like -n.
  62. Xsed="$SED -e 1s/^X//"
  63. # A grep program that handles long lines.
  64. GREP="/usr/bin/grep"
  65. # An ERE matcher.
  66. EGREP="/usr/bin/grep -E"
  67. # A literal string matcher.
  68. FGREP="/usr/bin/grep -F"
  69. # A BSD- or MS-compatible name lister.
  70. NM="/mingw64/bin/nm -B"
  71. # Whether we need soft or hard links.
  72. LN_S="cp -pR"
  73. # What is the maximum length of a command?
  74. max_cmd_len=8192
  75. # Object file suffix (normally "o").
  76. objext=o
  77. # Executable file suffix (normally "").
  78. exeext=
  79. # whether the shell understands "unset".
  80. lt_unset=unset
  81. # turn spaces into newlines.
  82. SP2NL="tr \\040 \\012"
  83. # turn newlines into spaces.
  84. NL2SP="tr \\015\\012 \\040\\040"
  85. # convert $build file names to $host format.
  86. to_host_file_cmd=func_convert_file_msys_to_w32
  87. # convert $build files to toolchain format.
  88. to_tool_file_cmd=func_convert_file_msys_to_w32
  89. # An object symbol dumper.
  90. OBJDUMP="objdump"
  91. # Method to check whether dependent libraries are shared objects.
  92. deplibs_check_method="file_magic ^x86 archive import|^x86 DLL"
  93. # Command to use when deplibs_check_method = "file_magic".
  94. file_magic_cmd="func_win32_libid"
  95. # How to find potential files when deplibs_check_method = "file_magic".
  96. file_magic_glob=""
  97. # Find potential files using nocaseglob when deplibs_check_method = "file_magic".
  98. want_nocaseglob="yes"
  99. # DLL creation program.
  100. DLLTOOL="dlltool"
  101. # Command to associate shared and link libraries.
  102. sharedlib_from_linklib_cmd="func_cygming_dll_for_implib"
  103. # The archiver.
  104. AR="ar"
  105. # Flags to create an archive.
  106. AR_FLAGS="cru"
  107. # How to feed a file listing to the archiver.
  108. archiver_list_spec="@"
  109. # A symbol stripping program.
  110. STRIP="strip"
  111. # Commands used to install an old-style archive.
  112. RANLIB="ranlib"
  113. old_postinstall_cmds="chmod 644 \$oldlib~\$RANLIB \$tool_oldlib"
  114. old_postuninstall_cmds=""
  115. # Whether to use a lock for old archive extraction.
  116. lock_old_archive_extraction=no
  117. # A C compiler.
  118. LTCC="gcc"
  119. # LTCC compiler flags.
  120. LTCFLAGS="-g -O3 -march=nocona"
  121. # Take the output of nm and produce a listing of raw symbols and C names.
  122. global_symbol_pipe="sed -n -e 's/^.*[ ]\\([ABCDGIRSTW][ABCDGIRSTW]*\\)[ ][ ]*\\([_A-Za-z][_A-Za-z0-9]*\\)\\{0,1\\}\$/\\1 \\2 \\2/p' | sed '/ __gnu_lto/d'"
  123. # Transform the output of nm in a proper C declaration.
  124. global_symbol_to_cdecl="sed -n -e 's/^T .* \\(.*\\)\$/extern int \\1();/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(.*\\)\$/extern char \\1;/p'"
  125. # Transform the output of nm into a list of symbols to manually relocate.
  126. global_symbol_to_import=""
  127. # Transform the output of nm in a C name address pair.
  128. global_symbol_to_c_name_address="sed -n -e 's/^: \\(.*\\) .*\$/ {\"\\1\", (void *) 0},/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(.*\\)\$/ {\"\\1\", (void *) \\&\\1},/p'"
  129. # Transform the output of nm in a C name address pair when lib prefix is needed.
  130. global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \\(.*\\) .*\$/ {\"\\1\", (void *) 0},/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(lib.*\\)\$/ {\"\\1\", (void *) \\&\\1},/p' -e 's/^[ABCDGIRSTW][ABCDGIRSTW]* .* \\(.*\\)\$/ {\"lib\\1\", (void *) \\&\\1},/p'"
  131. # The name lister interface.
  132. nm_interface="BSD nm"
  133. # Specify filename containing input files for $NM.
  134. nm_file_list_spec="@"
  135. # The root where to search for dependent libraries,and where our libraries should be installed.
  136. lt_sysroot=
  137. # Command to truncate a binary pipe.
  138. lt_truncate_bin="/usr/bin/dd bs=4096 count=1"
  139. # The name of the directory that contains temporary libtool files.
  140. objdir=.libs
  141. # Used to examine libraries when file_magic_cmd begins with "file".
  142. MAGIC_CMD=file
  143. # Must we lock files when doing compilation?
  144. need_locks="no"
  145. # Manifest tool.
  146. MANIFEST_TOOL=":"
  147. # Tool to manipulate archived DWARF debug symbol files on Mac OS X.
  148. DSYMUTIL=""
  149. # Tool to change global to local symbols on Mac OS X.
  150. NMEDIT=""
  151. # Tool to manipulate fat objects and archives on Mac OS X.
  152. LIPO=""
  153. # ldd/readelf like tool for Mach-O binaries on Mac OS X.
  154. OTOOL=""
  155. # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
  156. OTOOL64=""
  157. # Old archive suffix (normally "a").
  158. libext=a
  159. # Shared library suffix (normally ".so").
  160. shrext_cmds=".dll"
  161. # The commands to extract the exported symbol list from a shared archive.
  162. extract_expsyms_cmds=""
  163. # Variables whose values should be saved in libtool wrapper scripts and
  164. # restored at link time.
  165. variables_saved_for_relink="PATH PATH LD_RUN_PATH GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
  166. # Do we need the "lib" prefix for modules?
  167. need_lib_prefix=no
  168. # Do we need a version for libraries?
  169. need_version=no
  170. # Library versioning type.
  171. version_type=windows
  172. # Shared library runtime path variable.
  173. runpath_var=LD_RUN_PATH
  174. # Shared library path variable.
  175. shlibpath_var=PATH
  176. # Is shlibpath searched before the hard-coded library search path?
  177. shlibpath_overrides_runpath=yes
  178. # Format of library name prefix.
  179. libname_spec="lib\$name"
  180. # List of archive names. First name is the real one, the rest are links.
  181. # The last name is the one that the linker finds with -lNAME
  182. library_names_spec="\$libname.dll.a"
  183. # The coded name of the library, if different from the real name.
  184. soname_spec="\$libname\`echo \$release | \$SED -e s/[.]/-/g\`\$versuffix\$shared_ext"
  185. # Permission mode override for installation of shared libraries.
  186. install_override_mode=""
  187. # Command to use after installation of a shared archive.
  188. postinstall_cmds="base_file=\\\`basename \\\$file\\\`~
  189. dlpath=\\\`\$SHELL 2>&1 -c '. \$dir/'\\\$base_file'i; echo \\\$dlname'\\\`~
  190. dldir=\$destdir/\\\`dirname \\\$dlpath\\\`~
  191. test -d \\\$dldir || mkdir -p \\\$dldir~
  192. \$install_prog \$dir/\$dlname \\\$dldir/\$dlname~
  193. chmod a+x \\\$dldir/\$dlname~
  194. if test -n '\$stripme' && test -n '\$striplib'; then
  195. eval '\$striplib \\\$dldir/\$dlname' || exit \\\$?;
  196. fi"
  197. # Command to use after uninstallation of a shared archive.
  198. postuninstall_cmds="dldll=\\\`\$SHELL 2>&1 -c '. \$file; echo \\\$dlname'\\\`~
  199. dlpath=\$dir/\\\$dldll~
  200. \$RM \\\$dlpath"
  201. # Commands used to finish a libtool library installation in a directory.
  202. finish_cmds=""
  203. # As "finish_cmds", except a single script fragment to be evaled but
  204. # not shown.
  205. finish_eval=""
  206. # Whether we should hardcode library paths into libraries.
  207. hardcode_into_libs=no
  208. # Compile-time system search path for libraries.
  209. sys_lib_search_path_spec="C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/7.3.0 C:/msys64/mingw64/lib/gcc C:/msys64/mingw64/x86_64-w64-mingw32/lib C:/msys64/mingw64/lib "
  210. # Detected run-time system search path for libraries.
  211. sys_lib_dlsearch_path_spec="/lib /usr/lib"
  212. # Explicit LT_SYS_LIBRARY_PATH set during ./configure time.
  213. configure_time_lt_sys_library_path=""
  214. # Whether dlopen is supported.
  215. dlopen_support=unknown
  216. # Whether dlopen of programs is supported.
  217. dlopen_self=unknown
  218. # Whether dlopen of statically linked programs is supported.
  219. dlopen_self_static=unknown
  220. # Commands to strip libraries.
  221. old_striplib="strip --strip-debug"
  222. striplib="strip --strip-unneeded"
  223. # The linker used to build libraries.
  224. LD="C:/msys64/mingw64/x86_64-w64-mingw32/bin/ld.exe"
  225. # How to create reloadable object files.
  226. reload_flag=" -r"
  227. reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs"
  228. # Commands used to build an old-style archive.
  229. old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib"
  230. # A language specific compiler.
  231. CC="gcc"
  232. # Is the compiler the GNU compiler?
  233. with_gcc=yes
  234. # Compiler flag to turn off builtin functions.
  235. no_builtin_flag=" -fno-builtin"
  236. # Additional compiler flags for building library objects.
  237. pic_flag=" -DDLL_EXPORT -DPIC"
  238. # How to pass a linker flag through the compiler.
  239. wl="-Wl,"
  240. # Compiler flag to prevent dynamic linking.
  241. link_static_flag="-static"
  242. # Does compiler simultaneously support -c and -o options?
  243. compiler_c_o="yes"
  244. # Whether or not to add -lc for building shared libraries.
  245. build_libtool_need_lc=yes
  246. # Whether or not to disallow shared libs when runtime libs are static.
  247. allow_libtool_libs_with_static_runtimes=yes
  248. # Compiler flag to allow reflexive dlopens.
  249. export_dynamic_flag_spec="\$wl--export-all-symbols"
  250. # Compiler flag to generate shared objects directly from archives.
  251. whole_archive_flag_spec="\$wl--whole-archive\$convenience \$wl--no-whole-archive"
  252. # Whether the compiler copes with passing no objects directly.
  253. compiler_needs_object="no"
  254. # Create an old-style archive from a shared archive.
  255. old_archive_from_new_cmds=""
  256. # Create a temporary old-style archive to link instead of a shared archive.
  257. old_archive_from_expsyms_cmds=""
  258. # Commands used to build a shared archive.
  259. archive_cmds="\$CC -shared \$libobjs \$deplibs \$compiler_flags -o \$output_objdir/\$soname \$wl--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"
  260. archive_expsym_cmds="if test DEF = \\\"\\\`\$SED -n -e 's/^[ ]*//' -e '/^\\\\(;.*\\\\)*\$/d' -e 's/^\\\\(EXPORTS\\\\|LIBRARY\\\\)\\\\([ ].*\\\\)*\$/DEF/p' -e q \$export_symbols\\\`\\\" ; then
  261. cp \$export_symbols \$output_objdir/\$soname.def;
  262. else
  263. echo EXPORTS > \$output_objdir/\$soname.def;
  264. cat \$export_symbols >> \$output_objdir/\$soname.def;
  265. fi~
  266. \$CC -shared \$output_objdir/\$soname.def \$libobjs \$deplibs \$compiler_flags -o \$output_objdir/\$soname \$wl--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"
  267. # Commands used to build a loadable module if different from building
  268. # a shared archive.
  269. module_cmds=""
  270. module_expsym_cmds=""
  271. # Whether we are building with GNU ld or not.
  272. with_gnu_ld="yes"
  273. # Flag that allows shared libraries with undefined symbols to be built.
  274. allow_undefined_flag="unsupported"
  275. # Flag that enforces no undefined symbols.
  276. no_undefined_flag=""
  277. # Flag to hardcode $libdir into a binary during linking.
  278. # This must work even if $libdir does not exist
  279. hardcode_libdir_flag_spec="-L\$libdir"
  280. # Whether we need a single "-rpath" flag with a separated argument.
  281. hardcode_libdir_separator=""
  282. # Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
  283. # DIR into the resulting binary.
  284. hardcode_direct=no
  285. # Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes
  286. # DIR into the resulting binary and the resulting library dependency is
  287. # "absolute",i.e impossible to change by setting $shlibpath_var if the
  288. # library is relocated.
  289. hardcode_direct_absolute=no
  290. # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
  291. # into the resulting binary.
  292. hardcode_minus_L=no
  293. # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
  294. # into the resulting binary.
  295. hardcode_shlibpath_var=unsupported
  296. # Set to "yes" if building a shared library automatically hardcodes DIR
  297. # into the library and all subsequent libraries and executables linked
  298. # against it.
  299. hardcode_automatic=no
  300. # Set to yes if linker adds runtime paths of dependent libraries
  301. # to runtime path list.
  302. inherit_rpath=no
  303. # Whether libtool must link a program against all its dependency libraries.
  304. link_all_deplibs=unknown
  305. # Set to "yes" if exported symbols are required.
  306. always_export_symbols=no
  307. # The commands to list exported symbols.
  308. export_symbols_cmds="\$NM \$libobjs \$convenience | \$global_symbol_pipe | \$SED -e '/^[BCDGRS][ ]/s/.*[ ]\\\\([^ ]*\\\\)/\\\\1 DATA/;s/^.*[ ]__nm__\\\\([^ ]*\\\\)[ ][^ ]*/\\\\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //' | sort | uniq > \$export_symbols"
  309. # Symbols that should not be listed in the preloaded symbols.
  310. exclude_expsyms="[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname"
  311. # Symbols that must always be exported.
  312. include_expsyms=""
  313. # Commands necessary for linking programs (against libraries) with templates.
  314. prelink_cmds=""
  315. # Commands necessary for finishing linking programs.
  316. postlink_cmds=""
  317. # Specify filename containing input files.
  318. file_list_spec=""
  319. # How to hardcode a shared library path into an executable.
  320. hardcode_action=immediate
  321. # ### END LIBTOOL CONFIG
  322. # ### BEGIN FUNCTIONS SHARED WITH CONFIGURE
  323. # func_munge_path_list VARIABLE PATH
  324. # -----------------------------------
  325. # VARIABLE is name of variable containing _space_ separated list of
  326. # directories to be munged by the contents of PATH, which is string
  327. # having a format:
  328. # "DIR[:DIR]:"
  329. # string "DIR[ DIR]" will be prepended to VARIABLE
  330. # ":DIR[:DIR]"
  331. # string "DIR[ DIR]" will be appended to VARIABLE
  332. # "DIRP[:DIRP]::[DIRA:]DIRA"
  333. # string "DIRP[ DIRP]" will be prepended to VARIABLE and string
  334. # "DIRA[ DIRA]" will be appended to VARIABLE
  335. # "DIR[:DIR]"
  336. # VARIABLE will be replaced by "DIR[ DIR]"
  337. func_munge_path_list ()
  338. {
  339. case x$2 in
  340. x)
  341. ;;
  342. *:)
  343. eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"
  344. ;;
  345. x:*)
  346. eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"
  347. ;;
  348. *::*)
  349. eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
  350. eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"
  351. ;;
  352. *)
  353. eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"
  354. ;;
  355. esac
  356. }
  357. # Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
  358. func_cc_basename ()
  359. {
  360. for cc_temp in $*""; do
  361. case $cc_temp in
  362. compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
  363. distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
  364. \-*) ;;
  365. *) break;;
  366. esac
  367. done
  368. func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
  369. }
  370. # ### END FUNCTIONS SHARED WITH CONFIGURE
  371. #! /bin/sh
  372. ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
  373. ## by inline-source v2014-01-03.01
  374. # libtool (GNU libtool) 2.4.6
  375. # Provide generalized library-building support services.
  376. # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  377. # Copyright (C) 1996-2015 Free Software Foundation, Inc.
  378. # This is free software; see the source for copying conditions. There is NO
  379. # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  380. # GNU Libtool is free software; you can redistribute it and/or modify
  381. # it under the terms of the GNU General Public License as published by
  382. # the Free Software Foundation; either version 2 of the License, or
  383. # (at your option) any later version.
  384. #
  385. # As a special exception to the GNU General Public License,
  386. # if you distribute this file as part of a program or library that
  387. # is built using GNU Libtool, you may include this file under the
  388. # same distribution terms that you use for the rest of that program.
  389. #
  390. # GNU Libtool is distributed in the hope that it will be useful, but
  391. # WITHOUT ANY WARRANTY; without even the implied warranty of
  392. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  393. # General Public License for more details.
  394. #
  395. # You should have received a copy of the GNU General Public License
  396. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  397. PROGRAM=libtool
  398. PACKAGE=libtool
  399. VERSION=2.4.6
  400. package_revision=2.4.6
  401. ## ------ ##
  402. ## Usage. ##
  403. ## ------ ##
  404. # Run './libtool --help' for help with using this script from the
  405. # command line.
  406. ## ------------------------------- ##
  407. ## User overridable command paths. ##
  408. ## ------------------------------- ##
  409. # After configure completes, it has a better idea of some of the
  410. # shell tools we need than the defaults used by the functions shared
  411. # with bootstrap, so set those here where they can still be over-
  412. # ridden by the user, but otherwise take precedence.
  413. : ${AUTOCONF="autoconf"}
  414. : ${AUTOMAKE="automake"}
  415. ## -------------------------- ##
  416. ## Source external libraries. ##
  417. ## -------------------------- ##
  418. # Much of our low-level functionality needs to be sourced from external
  419. # libraries, which are installed to $pkgauxdir.
  420. # Set a version string for this script.
  421. scriptversion=2015-01-20.17; # UTC
  422. # General shell script boiler plate, and helper functions.
  423. # Written by Gary V. Vaughan, 2004
  424. # Copyright (C) 2004-2015 Free Software Foundation, Inc.
  425. # This is free software; see the source for copying conditions. There is NO
  426. # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  427. # This program is free software; you can redistribute it and/or modify
  428. # it under the terms of the GNU General Public License as published by
  429. # the Free Software Foundation; either version 3 of the License, or
  430. # (at your option) any later version.
  431. # As a special exception to the GNU General Public License, if you distribute
  432. # this file as part of a program or library that is built using GNU Libtool,
  433. # you may include this file under the same distribution terms that you use
  434. # for the rest of that program.
  435. # This program is distributed in the hope that it will be useful,
  436. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  437. # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
  438. # General Public License for more details.
  439. # You should have received a copy of the GNU General Public License
  440. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  441. # Please report bugs or propose patches to gary@gnu.org.
  442. ## ------ ##
  443. ## Usage. ##
  444. ## ------ ##
  445. # Evaluate this file near the top of your script to gain access to
  446. # the functions and variables defined here:
  447. #
  448. # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
  449. #
  450. # If you need to override any of the default environment variable
  451. # settings, do that before evaluating this file.
  452. ## -------------------- ##
  453. ## Shell normalisation. ##
  454. ## -------------------- ##
  455. # Some shells need a little help to be as Bourne compatible as possible.
  456. # Before doing anything else, make sure all that help has been provided!
  457. DUALCASE=1; export DUALCASE # for MKS sh
  458. if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  459. emulate sh
  460. NULLCMD=:
  461. # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
  462. # is contrary to our usage. Disable this feature.
  463. alias -g '${1+"$@"}'='"$@"'
  464. setopt NO_GLOB_SUBST
  465. else
  466. case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
  467. fi
  468. # NLS nuisances: We save the old values in case they are required later.
  469. _G_user_locale=
  470. _G_safe_locale=
  471. for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  472. do
  473. eval "if test set = \"\${$_G_var+set}\"; then
  474. save_$_G_var=\$$_G_var
  475. $_G_var=C
  476. export $_G_var
  477. _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
  478. _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
  479. fi"
  480. done
  481. # CDPATH.
  482. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  483. # Make sure IFS has a sensible default
  484. sp=' '
  485. nl='
  486. '
  487. IFS="$sp $nl"
  488. # There are apparently some retarded systems that use ';' as a PATH separator!
  489. if test "${PATH_SEPARATOR+set}" != set; then
  490. PATH_SEPARATOR=:
  491. (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
  492. (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
  493. PATH_SEPARATOR=';'
  494. }
  495. fi
  496. ## ------------------------- ##
  497. ## Locate command utilities. ##
  498. ## ------------------------- ##
  499. # func_executable_p FILE
  500. # ----------------------
  501. # Check that FILE is an executable regular file.
  502. func_executable_p ()
  503. {
  504. test -f "$1" && test -x "$1"
  505. }
  506. # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
  507. # --------------------------------------------
  508. # Search for either a program that responds to --version with output
  509. # containing "GNU", or else returned by CHECK_FUNC otherwise, by
  510. # trying all the directories in PATH with each of the elements of
  511. # PROGS_LIST.
  512. #
  513. # CHECK_FUNC should accept the path to a candidate program, and
  514. # set $func_check_prog_result if it truncates its output less than
  515. # $_G_path_prog_max characters.
  516. func_path_progs ()
  517. {
  518. _G_progs_list=$1
  519. _G_check_func=$2
  520. _G_PATH=${3-"$PATH"}
  521. _G_path_prog_max=0
  522. _G_path_prog_found=false
  523. _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
  524. for _G_dir in $_G_PATH; do
  525. IFS=$_G_save_IFS
  526. test -z "$_G_dir" && _G_dir=.
  527. for _G_prog_name in $_G_progs_list; do
  528. for _exeext in '' .EXE; do
  529. _G_path_prog=$_G_dir/$_G_prog_name$_exeext
  530. func_executable_p "$_G_path_prog" || continue
  531. case `"$_G_path_prog" --version 2>&1` in
  532. *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
  533. *) $_G_check_func $_G_path_prog
  534. func_path_progs_result=$func_check_prog_result
  535. ;;
  536. esac
  537. $_G_path_prog_found && break 3
  538. done
  539. done
  540. done
  541. IFS=$_G_save_IFS
  542. test -z "$func_path_progs_result" && {
  543. echo "no acceptable sed could be found in \$PATH" >&2
  544. exit 1
  545. }
  546. }
  547. # We want to be able to use the functions in this file before configure
  548. # has figured out where the best binaries are kept, which means we have
  549. # to search for them ourselves - except when the results are already set
  550. # where we skip the searches.
  551. # Unless the user overrides by setting SED, search the path for either GNU
  552. # sed, or the sed that truncates its output the least.
  553. test -z "$SED" && {
  554. _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
  555. for _G_i in 1 2 3 4 5 6 7; do
  556. _G_sed_script=$_G_sed_script$nl$_G_sed_script
  557. done
  558. echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
  559. _G_sed_script=
  560. func_check_prog_sed ()
  561. {
  562. _G_path_prog=$1
  563. _G_count=0
  564. printf 0123456789 >conftest.in
  565. while :
  566. do
  567. cat conftest.in conftest.in >conftest.tmp
  568. mv conftest.tmp conftest.in
  569. cp conftest.in conftest.nl
  570. echo '' >> conftest.nl
  571. "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
  572. diff conftest.out conftest.nl >/dev/null 2>&1 || break
  573. _G_count=`expr $_G_count + 1`
  574. if test "$_G_count" -gt "$_G_path_prog_max"; then
  575. # Best one so far, save it but keep looking for a better one
  576. func_check_prog_result=$_G_path_prog
  577. _G_path_prog_max=$_G_count
  578. fi
  579. # 10*(2^10) chars as input seems more than enough
  580. test 10 -lt "$_G_count" && break
  581. done
  582. rm -f conftest.in conftest.tmp conftest.nl conftest.out
  583. }
  584. func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
  585. rm -f conftest.sed
  586. SED=$func_path_progs_result
  587. }
  588. # Unless the user overrides by setting GREP, search the path for either GNU
  589. # grep, or the grep that truncates its output the least.
  590. test -z "$GREP" && {
  591. func_check_prog_grep ()
  592. {
  593. _G_path_prog=$1
  594. _G_count=0
  595. _G_path_prog_max=0
  596. printf 0123456789 >conftest.in
  597. while :
  598. do
  599. cat conftest.in conftest.in >conftest.tmp
  600. mv conftest.tmp conftest.in
  601. cp conftest.in conftest.nl
  602. echo 'GREP' >> conftest.nl
  603. "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
  604. diff conftest.out conftest.nl >/dev/null 2>&1 || break
  605. _G_count=`expr $_G_count + 1`
  606. if test "$_G_count" -gt "$_G_path_prog_max"; then
  607. # Best one so far, save it but keep looking for a better one
  608. func_check_prog_result=$_G_path_prog
  609. _G_path_prog_max=$_G_count
  610. fi
  611. # 10*(2^10) chars as input seems more than enough
  612. test 10 -lt "$_G_count" && break
  613. done
  614. rm -f conftest.in conftest.tmp conftest.nl conftest.out
  615. }
  616. func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
  617. GREP=$func_path_progs_result
  618. }
  619. ## ------------------------------- ##
  620. ## User overridable command paths. ##
  621. ## ------------------------------- ##
  622. # All uppercase variable names are used for environment variables. These
  623. # variables can be overridden by the user before calling a script that
  624. # uses them if a suitable command of that name is not already available
  625. # in the command search PATH.
  626. : ${CP="cp -f"}
  627. : ${ECHO="printf %s\n"}
  628. : ${EGREP="$GREP -E"}
  629. : ${FGREP="$GREP -F"}
  630. : ${LN_S="ln -s"}
  631. : ${MAKE="make"}
  632. : ${MKDIR="mkdir"}
  633. : ${MV="mv -f"}
  634. : ${RM="rm -f"}
  635. : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
  636. ## -------------------- ##
  637. ## Useful sed snippets. ##
  638. ## -------------------- ##
  639. sed_dirname='s|/[^/]*$||'
  640. sed_basename='s|^.*/||'
  641. # Sed substitution that helps us do robust quoting. It backslashifies
  642. # metacharacters that are still active within double-quoted strings.
  643. sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
  644. # Same as above, but do not quote variable references.
  645. sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
  646. # Sed substitution that turns a string into a regex matching for the
  647. # string literally.
  648. sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
  649. # Sed substitution that converts a w32 file name or path
  650. # that contains forward slashes, into one that contains
  651. # (escaped) backslashes. A very naive implementation.
  652. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
  653. # Re-'\' parameter expansions in output of sed_double_quote_subst that
  654. # were '\'-ed in input to the same. If an odd number of '\' preceded a
  655. # '$' in input to sed_double_quote_subst, that '$' was protected from
  656. # expansion. Since each input '\' is now two '\'s, look for any number
  657. # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
  658. _G_bs='\\'
  659. _G_bs2='\\\\'
  660. _G_bs4='\\\\\\\\'
  661. _G_dollar='\$'
  662. sed_double_backslash="\
  663. s/$_G_bs4/&\\
  664. /g
  665. s/^$_G_bs2$_G_dollar/$_G_bs&/
  666. s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
  667. s/\n//g"
  668. ## ----------------- ##
  669. ## Global variables. ##
  670. ## ----------------- ##
  671. # Except for the global variables explicitly listed below, the following
  672. # functions in the '^func_' namespace, and the '^require_' namespace
  673. # variables initialised in the 'Resource management' section, sourcing
  674. # this file will not pollute your global namespace with anything
  675. # else. There's no portable way to scope variables in Bourne shell
  676. # though, so actually running these functions will sometimes place
  677. # results into a variable named after the function, and often use
  678. # temporary variables in the '^_G_' namespace. If you are careful to
  679. # avoid using those namespaces casually in your sourcing script, things
  680. # should continue to work as you expect. And, of course, you can freely
  681. # overwrite any of the functions or variables defined here before
  682. # calling anything to customize them.
  683. EXIT_SUCCESS=0
  684. EXIT_FAILURE=1
  685. EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
  686. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
  687. # Allow overriding, eg assuming that you follow the convention of
  688. # putting '$debug_cmd' at the start of all your functions, you can get
  689. # bash to show function call trace with:
  690. #
  691. # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
  692. debug_cmd=${debug_cmd-":"}
  693. exit_cmd=:
  694. # By convention, finish your script with:
  695. #
  696. # exit $exit_status
  697. #
  698. # so that you can set exit_status to non-zero if you want to indicate
  699. # something went wrong during execution without actually bailing out at
  700. # the point of failure.
  701. exit_status=$EXIT_SUCCESS
  702. # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
  703. # is ksh but when the shell is invoked as "sh" and the current value of
  704. # the _XPG environment variable is not equal to 1 (one), the special
  705. # positional parameter $0, within a function call, is the name of the
  706. # function.
  707. progpath=$0
  708. # The name of this program.
  709. progname=`$ECHO "$progpath" |$SED "$sed_basename"`
  710. # Make sure we have an absolute progpath for reexecution:
  711. case $progpath in
  712. [\\/]*|[A-Za-z]:\\*) ;;
  713. *[\\/]*)
  714. progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
  715. progdir=`cd "$progdir" && pwd`
  716. progpath=$progdir/$progname
  717. ;;
  718. *)
  719. _G_IFS=$IFS
  720. IFS=${PATH_SEPARATOR-:}
  721. for progdir in $PATH; do
  722. IFS=$_G_IFS
  723. test -x "$progdir/$progname" && break
  724. done
  725. IFS=$_G_IFS
  726. test -n "$progdir" || progdir=`pwd`
  727. progpath=$progdir/$progname
  728. ;;
  729. esac
  730. ## ----------------- ##
  731. ## Standard options. ##
  732. ## ----------------- ##
  733. # The following options affect the operation of the functions defined
  734. # below, and should be set appropriately depending on run-time para-
  735. # meters passed on the command line.
  736. opt_dry_run=false
  737. opt_quiet=false
  738. opt_verbose=false
  739. # Categories 'all' and 'none' are always available. Append any others
  740. # you will pass as the first argument to func_warning from your own
  741. # code.
  742. warning_categories=
  743. # By default, display warnings according to 'opt_warning_types'. Set
  744. # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
  745. # treat the next displayed warning as a fatal error.
  746. warning_func=func_warn_and_continue
  747. # Set to 'all' to display all warnings, 'none' to suppress all
  748. # warnings, or a space delimited list of some subset of
  749. # 'warning_categories' to display only the listed warnings.
  750. opt_warning_types=all
  751. ## -------------------- ##
  752. ## Resource management. ##
  753. ## -------------------- ##
  754. # This section contains definitions for functions that each ensure a
  755. # particular resource (a file, or a non-empty configuration variable for
  756. # example) is available, and if appropriate to extract default values
  757. # from pertinent package files. Call them using their associated
  758. # 'require_*' variable to ensure that they are executed, at most, once.
  759. #
  760. # It's entirely deliberate that calling these functions can set
  761. # variables that don't obey the namespace limitations obeyed by the rest
  762. # of this file, in order that that they be as useful as possible to
  763. # callers.
  764. # require_term_colors
  765. # -------------------
  766. # Allow display of bold text on terminals that support it.
  767. require_term_colors=func_require_term_colors
  768. func_require_term_colors ()
  769. {
  770. $debug_cmd
  771. test -t 1 && {
  772. # COLORTERM and USE_ANSI_COLORS environment variables take
  773. # precedence, because most terminfo databases neglect to describe
  774. # whether color sequences are supported.
  775. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
  776. if test 1 = "$USE_ANSI_COLORS"; then
  777. # Standard ANSI escape sequences
  778. tc_reset=''
  779. tc_bold=''; tc_standout=''
  780. tc_red=''; tc_green=''
  781. tc_blue=''; tc_cyan=''
  782. else
  783. # Otherwise trust the terminfo database after all.
  784. test -n "`tput sgr0 2>/dev/null`" && {
  785. tc_reset=`tput sgr0`
  786. test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
  787. tc_standout=$tc_bold
  788. test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
  789. test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
  790. test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
  791. test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
  792. test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
  793. }
  794. fi
  795. }
  796. require_term_colors=:
  797. }
  798. ## ----------------- ##
  799. ## Function library. ##
  800. ## ----------------- ##
  801. # This section contains a variety of useful functions to call in your
  802. # scripts. Take note of the portable wrappers for features provided by
  803. # some modern shells, which will fall back to slower equivalents on
  804. # less featureful shells.
  805. # func_append VAR VALUE
  806. # ---------------------
  807. # Append VALUE onto the existing contents of VAR.
  808. # We should try to minimise forks, especially on Windows where they are
  809. # unreasonably slow, so skip the feature probes when bash or zsh are
  810. # being used:
  811. if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
  812. : ${_G_HAVE_ARITH_OP="yes"}
  813. : ${_G_HAVE_XSI_OPS="yes"}
  814. # The += operator was introduced in bash 3.1
  815. case $BASH_VERSION in
  816. [12].* | 3.0 | 3.0*) ;;
  817. *)
  818. : ${_G_HAVE_PLUSEQ_OP="yes"}
  819. ;;
  820. esac
  821. fi
  822. # _G_HAVE_PLUSEQ_OP
  823. # Can be empty, in which case the shell is probed, "yes" if += is
  824. # useable or anything else if it does not work.
  825. test -z "$_G_HAVE_PLUSEQ_OP" \
  826. && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
  827. && _G_HAVE_PLUSEQ_OP=yes
  828. if test yes = "$_G_HAVE_PLUSEQ_OP"
  829. then
  830. # This is an XSI compatible shell, allowing a faster implementation...
  831. eval 'func_append ()
  832. {
  833. $debug_cmd
  834. eval "$1+=\$2"
  835. }'
  836. else
  837. # ...otherwise fall back to using expr, which is often a shell builtin.
  838. func_append ()
  839. {
  840. $debug_cmd
  841. eval "$1=\$$1\$2"
  842. }
  843. fi
  844. # func_append_quoted VAR VALUE
  845. # ----------------------------
  846. # Quote VALUE and append to the end of shell variable VAR, separated
  847. # by a space.
  848. if test yes = "$_G_HAVE_PLUSEQ_OP"; then
  849. eval 'func_append_quoted ()
  850. {
  851. $debug_cmd
  852. func_quote_for_eval "$2"
  853. eval "$1+=\\ \$func_quote_for_eval_result"
  854. }'
  855. else
  856. func_append_quoted ()
  857. {
  858. $debug_cmd
  859. func_quote_for_eval "$2"
  860. eval "$1=\$$1\\ \$func_quote_for_eval_result"
  861. }
  862. fi
  863. # func_append_uniq VAR VALUE
  864. # --------------------------
  865. # Append unique VALUE onto the existing contents of VAR, assuming
  866. # entries are delimited by the first character of VALUE. For example:
  867. #
  868. # func_append_uniq options " --another-option option-argument"
  869. #
  870. # will only append to $options if " --another-option option-argument "
  871. # is not already present somewhere in $options already (note spaces at
  872. # each end implied by leading space in second argument).
  873. func_append_uniq ()
  874. {
  875. $debug_cmd
  876. eval _G_current_value='`$ECHO $'$1'`'
  877. _G_delim=`expr "$2" : '\(.\)'`
  878. case $_G_delim$_G_current_value$_G_delim in
  879. *"$2$_G_delim"*) ;;
  880. *) func_append "$@" ;;
  881. esac
  882. }
  883. # func_arith TERM...
  884. # ------------------
  885. # Set func_arith_result to the result of evaluating TERMs.
  886. test -z "$_G_HAVE_ARITH_OP" \
  887. && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
  888. && _G_HAVE_ARITH_OP=yes
  889. if test yes = "$_G_HAVE_ARITH_OP"; then
  890. eval 'func_arith ()
  891. {
  892. $debug_cmd
  893. func_arith_result=$(( $* ))
  894. }'
  895. else
  896. func_arith ()
  897. {
  898. $debug_cmd
  899. func_arith_result=`expr "$@"`
  900. }
  901. fi
  902. # func_basename FILE
  903. # ------------------
  904. # Set func_basename_result to FILE with everything up to and including
  905. # the last / stripped.
  906. if test yes = "$_G_HAVE_XSI_OPS"; then
  907. # If this shell supports suffix pattern removal, then use it to avoid
  908. # forking. Hide the definitions single quotes in case the shell chokes
  909. # on unsupported syntax...
  910. _b='func_basename_result=${1##*/}'
  911. _d='case $1 in
  912. */*) func_dirname_result=${1%/*}$2 ;;
  913. * ) func_dirname_result=$3 ;;
  914. esac'
  915. else
  916. # ...otherwise fall back to using sed.
  917. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
  918. _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
  919. if test "X$func_dirname_result" = "X$1"; then
  920. func_dirname_result=$3
  921. else
  922. func_append func_dirname_result "$2"
  923. fi'
  924. fi
  925. eval 'func_basename ()
  926. {
  927. $debug_cmd
  928. '"$_b"'
  929. }'
  930. # func_dirname FILE APPEND NONDIR_REPLACEMENT
  931. # -------------------------------------------
  932. # Compute the dirname of FILE. If nonempty, add APPEND to the result,
  933. # otherwise set result to NONDIR_REPLACEMENT.
  934. eval 'func_dirname ()
  935. {
  936. $debug_cmd
  937. '"$_d"'
  938. }'
  939. # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
  940. # --------------------------------------------------------
  941. # Perform func_basename and func_dirname in a single function
  942. # call:
  943. # dirname: Compute the dirname of FILE. If nonempty,
  944. # add APPEND to the result, otherwise set result
  945. # to NONDIR_REPLACEMENT.
  946. # value returned in "$func_dirname_result"
  947. # basename: Compute filename of FILE.
  948. # value retuned in "$func_basename_result"
  949. # For efficiency, we do not delegate to the functions above but instead
  950. # duplicate the functionality here.
  951. eval 'func_dirname_and_basename ()
  952. {
  953. $debug_cmd
  954. '"$_b"'
  955. '"$_d"'
  956. }'
  957. # func_echo ARG...
  958. # ----------------
  959. # Echo program name prefixed message.
  960. func_echo ()
  961. {
  962. $debug_cmd
  963. _G_message=$*
  964. func_echo_IFS=$IFS
  965. IFS=$nl
  966. for _G_line in $_G_message; do
  967. IFS=$func_echo_IFS
  968. $ECHO "$progname: $_G_line"
  969. done
  970. IFS=$func_echo_IFS
  971. }
  972. # func_echo_all ARG...
  973. # --------------------
  974. # Invoke $ECHO with all args, space-separated.
  975. func_echo_all ()
  976. {
  977. $ECHO "$*"
  978. }
  979. # func_echo_infix_1 INFIX ARG...
  980. # ------------------------------
  981. # Echo program name, followed by INFIX on the first line, with any
  982. # additional lines not showing INFIX.
  983. func_echo_infix_1 ()
  984. {
  985. $debug_cmd
  986. $require_term_colors
  987. _G_infix=$1; shift
  988. _G_indent=$_G_infix
  989. _G_prefix="$progname: $_G_infix: "
  990. _G_message=$*
  991. # Strip color escape sequences before counting printable length
  992. for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
  993. do
  994. test -n "$_G_tc" && {
  995. _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
  996. _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
  997. }
  998. done
  999. _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
  1000. func_echo_infix_1_IFS=$IFS
  1001. IFS=$nl
  1002. for _G_line in $_G_message; do
  1003. IFS=$func_echo_infix_1_IFS
  1004. $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
  1005. _G_prefix=$_G_indent
  1006. done
  1007. IFS=$func_echo_infix_1_IFS
  1008. }
  1009. # func_error ARG...
  1010. # -----------------
  1011. # Echo program name prefixed message to standard error.
  1012. func_error ()
  1013. {
  1014. $debug_cmd
  1015. $require_term_colors
  1016. func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
  1017. }
  1018. # func_fatal_error ARG...
  1019. # -----------------------
  1020. # Echo program name prefixed message to standard error, and exit.
  1021. func_fatal_error ()
  1022. {
  1023. $debug_cmd
  1024. func_error "$*"
  1025. exit $EXIT_FAILURE
  1026. }
  1027. # func_grep EXPRESSION FILENAME
  1028. # -----------------------------
  1029. # Check whether EXPRESSION matches any line of FILENAME, without output.
  1030. func_grep ()
  1031. {
  1032. $debug_cmd
  1033. $GREP "$1" "$2" >/dev/null 2>&1
  1034. }
  1035. # func_len STRING
  1036. # ---------------
  1037. # Set func_len_result to the length of STRING. STRING may not
  1038. # start with a hyphen.
  1039. test -z "$_G_HAVE_XSI_OPS" \
  1040. && (eval 'x=a/b/c;
  1041. test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
  1042. && _G_HAVE_XSI_OPS=yes
  1043. if test yes = "$_G_HAVE_XSI_OPS"; then
  1044. eval 'func_len ()
  1045. {
  1046. $debug_cmd
  1047. func_len_result=${#1}
  1048. }'
  1049. else
  1050. func_len ()
  1051. {
  1052. $debug_cmd
  1053. func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
  1054. }
  1055. fi
  1056. # func_mkdir_p DIRECTORY-PATH
  1057. # ---------------------------
  1058. # Make sure the entire path to DIRECTORY-PATH is available.
  1059. func_mkdir_p ()
  1060. {
  1061. $debug_cmd
  1062. _G_directory_path=$1
  1063. _G_dir_list=
  1064. if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
  1065. # Protect directory names starting with '-'
  1066. case $_G_directory_path in
  1067. -*) _G_directory_path=./$_G_directory_path ;;
  1068. esac
  1069. # While some portion of DIR does not yet exist...
  1070. while test ! -d "$_G_directory_path"; do
  1071. # ...make a list in topmost first order. Use a colon delimited
  1072. # list incase some portion of path contains whitespace.
  1073. _G_dir_list=$_G_directory_path:$_G_dir_list
  1074. # If the last portion added has no slash in it, the list is done
  1075. case $_G_directory_path in */*) ;; *) break ;; esac
  1076. # ...otherwise throw away the child directory and loop
  1077. _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
  1078. done
  1079. _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
  1080. func_mkdir_p_IFS=$IFS; IFS=:
  1081. for _G_dir in $_G_dir_list; do
  1082. IFS=$func_mkdir_p_IFS
  1083. # mkdir can fail with a 'File exist' error if two processes
  1084. # try to create one of the directories concurrently. Don't
  1085. # stop in that case!
  1086. $MKDIR "$_G_dir" 2>/dev/null || :
  1087. done
  1088. IFS=$func_mkdir_p_IFS
  1089. # Bail out if we (or some other process) failed to create a directory.
  1090. test -d "$_G_directory_path" || \
  1091. func_fatal_error "Failed to create '$1'"
  1092. fi
  1093. }
  1094. # func_mktempdir [BASENAME]
  1095. # -------------------------
  1096. # Make a temporary directory that won't clash with other running
  1097. # libtool processes, and avoids race conditions if possible. If
  1098. # given, BASENAME is the basename for that directory.
  1099. func_mktempdir ()
  1100. {
  1101. $debug_cmd
  1102. _G_template=${TMPDIR-/tmp}/${1-$progname}
  1103. if test : = "$opt_dry_run"; then
  1104. # Return a directory name, but don't create it in dry-run mode
  1105. _G_tmpdir=$_G_template-$$
  1106. else
  1107. # If mktemp works, use that first and foremost
  1108. _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
  1109. if test ! -d "$_G_tmpdir"; then
  1110. # Failing that, at least try and use $RANDOM to avoid a race
  1111. _G_tmpdir=$_G_template-${RANDOM-0}$$
  1112. func_mktempdir_umask=`umask`
  1113. umask 0077
  1114. $MKDIR "$_G_tmpdir"
  1115. umask $func_mktempdir_umask
  1116. fi
  1117. # If we're not in dry-run mode, bomb out on failure
  1118. test -d "$_G_tmpdir" || \
  1119. func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
  1120. fi
  1121. $ECHO "$_G_tmpdir"
  1122. }
  1123. # func_normal_abspath PATH
  1124. # ------------------------
  1125. # Remove doubled-up and trailing slashes, "." path components,
  1126. # and cancel out any ".." path components in PATH after making
  1127. # it an absolute path.
  1128. func_normal_abspath ()
  1129. {
  1130. $debug_cmd
  1131. # These SED scripts presuppose an absolute path with a trailing slash.
  1132. _G_pathcar='s|^/\([^/]*\).*$|\1|'
  1133. _G_pathcdr='s|^/[^/]*||'
  1134. _G_removedotparts=':dotsl
  1135. s|/\./|/|g
  1136. t dotsl
  1137. s|/\.$|/|'
  1138. _G_collapseslashes='s|/\{1,\}|/|g'
  1139. _G_finalslash='s|/*$|/|'
  1140. # Start from root dir and reassemble the path.
  1141. func_normal_abspath_result=
  1142. func_normal_abspath_tpath=$1
  1143. func_normal_abspath_altnamespace=
  1144. case $func_normal_abspath_tpath in
  1145. "")
  1146. # Empty path, that just means $cwd.
  1147. func_stripname '' '/' "`pwd`"
  1148. func_normal_abspath_result=$func_stripname_result
  1149. return
  1150. ;;
  1151. # The next three entries are used to spot a run of precisely
  1152. # two leading slashes without using negated character classes;
  1153. # we take advantage of case's first-match behaviour.
  1154. ///*)
  1155. # Unusual form of absolute path, do nothing.
  1156. ;;
  1157. //*)
  1158. # Not necessarily an ordinary path; POSIX reserves leading '//'
  1159. # and for example Cygwin uses it to access remote file shares
  1160. # over CIFS/SMB, so we conserve a leading double slash if found.
  1161. func_normal_abspath_altnamespace=/
  1162. ;;
  1163. /*)
  1164. # Absolute path, do nothing.
  1165. ;;
  1166. *)
  1167. # Relative path, prepend $cwd.
  1168. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
  1169. ;;
  1170. esac
  1171. # Cancel out all the simple stuff to save iterations. We also want
  1172. # the path to end with a slash for ease of parsing, so make sure
  1173. # there is one (and only one) here.
  1174. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  1175. -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
  1176. while :; do
  1177. # Processed it all yet?
  1178. if test / = "$func_normal_abspath_tpath"; then
  1179. # If we ascended to the root using ".." the result may be empty now.
  1180. if test -z "$func_normal_abspath_result"; then
  1181. func_normal_abspath_result=/
  1182. fi
  1183. break
  1184. fi
  1185. func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
  1186. -e "$_G_pathcar"`
  1187. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  1188. -e "$_G_pathcdr"`
  1189. # Figure out what to do with it
  1190. case $func_normal_abspath_tcomponent in
  1191. "")
  1192. # Trailing empty path component, ignore it.
  1193. ;;
  1194. ..)
  1195. # Parent dir; strip last assembled component from result.
  1196. func_dirname "$func_normal_abspath_result"
  1197. func_normal_abspath_result=$func_dirname_result
  1198. ;;
  1199. *)
  1200. # Actual path component, append it.
  1201. func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
  1202. ;;
  1203. esac
  1204. done
  1205. # Restore leading double-slash if one was found on entry.
  1206. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
  1207. }
  1208. # func_notquiet ARG...
  1209. # --------------------
  1210. # Echo program name prefixed message only when not in quiet mode.
  1211. func_notquiet ()
  1212. {
  1213. $debug_cmd
  1214. $opt_quiet || func_echo ${1+"$@"}
  1215. # A bug in bash halts the script if the last line of a function
  1216. # fails when set -e is in force, so we need another command to
  1217. # work around that:
  1218. :
  1219. }
  1220. # func_relative_path SRCDIR DSTDIR
  1221. # --------------------------------
  1222. # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
  1223. func_relative_path ()
  1224. {
  1225. $debug_cmd
  1226. func_relative_path_result=
  1227. func_normal_abspath "$1"
  1228. func_relative_path_tlibdir=$func_normal_abspath_result
  1229. func_normal_abspath "$2"
  1230. func_relative_path_tbindir=$func_normal_abspath_result
  1231. # Ascend the tree starting from libdir
  1232. while :; do
  1233. # check if we have found a prefix of bindir
  1234. case $func_relative_path_tbindir in
  1235. $func_relative_path_tlibdir)
  1236. # found an exact match
  1237. func_relative_path_tcancelled=
  1238. break
  1239. ;;
  1240. $func_relative_path_tlibdir*)
  1241. # found a matching prefix
  1242. func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
  1243. func_relative_path_tcancelled=$func_stripname_result
  1244. if test -z "$func_relative_path_result"; then
  1245. func_relative_path_result=.
  1246. fi
  1247. break
  1248. ;;
  1249. *)
  1250. func_dirname $func_relative_path_tlibdir
  1251. func_relative_path_tlibdir=$func_dirname_result
  1252. if test -z "$func_relative_path_tlibdir"; then
  1253. # Have to descend all the way to the root!
  1254. func_relative_path_result=../$func_relative_path_result
  1255. func_relative_path_tcancelled=$func_relative_path_tbindir
  1256. break
  1257. fi
  1258. func_relative_path_result=../$func_relative_path_result
  1259. ;;
  1260. esac
  1261. done
  1262. # Now calculate path; take care to avoid doubling-up slashes.
  1263. func_stripname '' '/' "$func_relative_path_result"
  1264. func_relative_path_result=$func_stripname_result
  1265. func_stripname '/' '/' "$func_relative_path_tcancelled"
  1266. if test -n "$func_stripname_result"; then
  1267. func_append func_relative_path_result "/$func_stripname_result"
  1268. fi
  1269. # Normalisation. If bindir is libdir, return '.' else relative path.
  1270. if test -n "$func_relative_path_result"; then
  1271. func_stripname './' '' "$func_relative_path_result"
  1272. func_relative_path_result=$func_stripname_result
  1273. fi
  1274. test -n "$func_relative_path_result" || func_relative_path_result=.
  1275. :
  1276. }
  1277. # func_quote_for_eval ARG...
  1278. # --------------------------
  1279. # Aesthetically quote ARGs to be evaled later.
  1280. # This function returns two values:
  1281. # i) func_quote_for_eval_result
  1282. # double-quoted, suitable for a subsequent eval
  1283. # ii) func_quote_for_eval_unquoted_result
  1284. # has all characters that are still active within double
  1285. # quotes backslashified.
  1286. func_quote_for_eval ()
  1287. {
  1288. $debug_cmd
  1289. func_quote_for_eval_unquoted_result=
  1290. func_quote_for_eval_result=
  1291. while test 0 -lt $#; do
  1292. case $1 in
  1293. *[\\\`\"\$]*)
  1294. _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
  1295. *)
  1296. _G_unquoted_arg=$1 ;;
  1297. esac
  1298. if test -n "$func_quote_for_eval_unquoted_result"; then
  1299. func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
  1300. else
  1301. func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
  1302. fi
  1303. case $_G_unquoted_arg in
  1304. # Double-quote args containing shell metacharacters to delay
  1305. # word splitting, command substitution and variable expansion
  1306. # for a subsequent eval.
  1307. # Many Bourne shells cannot handle close brackets correctly
  1308. # in scan sets, so we specify it separately.
  1309. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1310. _G_quoted_arg=\"$_G_unquoted_arg\"
  1311. ;;
  1312. *)
  1313. _G_quoted_arg=$_G_unquoted_arg
  1314. ;;
  1315. esac
  1316. if test -n "$func_quote_for_eval_result"; then
  1317. func_append func_quote_for_eval_result " $_G_quoted_arg"
  1318. else
  1319. func_append func_quote_for_eval_result "$_G_quoted_arg"
  1320. fi
  1321. shift
  1322. done
  1323. }
  1324. # func_quote_for_expand ARG
  1325. # -------------------------
  1326. # Aesthetically quote ARG to be evaled later; same as above,
  1327. # but do not quote variable references.
  1328. func_quote_for_expand ()
  1329. {
  1330. $debug_cmd
  1331. case $1 in
  1332. *[\\\`\"]*)
  1333. _G_arg=`$ECHO "$1" | $SED \
  1334. -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
  1335. *)
  1336. _G_arg=$1 ;;
  1337. esac
  1338. case $_G_arg in
  1339. # Double-quote args containing shell metacharacters to delay
  1340. # word splitting and command substitution for a subsequent eval.
  1341. # Many Bourne shells cannot handle close brackets correctly
  1342. # in scan sets, so we specify it separately.
  1343. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1344. _G_arg=\"$_G_arg\"
  1345. ;;
  1346. esac
  1347. func_quote_for_expand_result=$_G_arg
  1348. }
  1349. # func_stripname PREFIX SUFFIX NAME
  1350. # ---------------------------------
  1351. # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
  1352. # PREFIX and SUFFIX must not contain globbing or regex special
  1353. # characters, hashes, percent signs, but SUFFIX may contain a leading
  1354. # dot (in which case that matches only a dot).
  1355. if test yes = "$_G_HAVE_XSI_OPS"; then
  1356. eval 'func_stripname ()
  1357. {
  1358. $debug_cmd
  1359. # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
  1360. # positional parameters, so assign one to ordinary variable first.
  1361. func_stripname_result=$3
  1362. func_stripname_result=${func_stripname_result#"$1"}
  1363. func_stripname_result=${func_stripname_result%"$2"}
  1364. }'
  1365. else
  1366. func_stripname ()
  1367. {
  1368. $debug_cmd
  1369. case $2 in
  1370. .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
  1371. *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
  1372. esac
  1373. }
  1374. fi
  1375. # func_show_eval CMD [FAIL_EXP]
  1376. # -----------------------------
  1377. # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
  1378. # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
  1379. # is given, then evaluate it.
  1380. func_show_eval ()
  1381. {
  1382. $debug_cmd
  1383. _G_cmd=$1
  1384. _G_fail_exp=${2-':'}
  1385. func_quote_for_expand "$_G_cmd"
  1386. eval "func_notquiet $func_quote_for_expand_result"
  1387. $opt_dry_run || {
  1388. eval "$_G_cmd"
  1389. _G_status=$?
  1390. if test 0 -ne "$_G_status"; then
  1391. eval "(exit $_G_status); $_G_fail_exp"
  1392. fi
  1393. }
  1394. }
  1395. # func_show_eval_locale CMD [FAIL_EXP]
  1396. # ------------------------------------
  1397. # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
  1398. # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
  1399. # is given, then evaluate it. Use the saved locale for evaluation.
  1400. func_show_eval_locale ()
  1401. {
  1402. $debug_cmd
  1403. _G_cmd=$1
  1404. _G_fail_exp=${2-':'}
  1405. $opt_quiet || {
  1406. func_quote_for_expand "$_G_cmd"
  1407. eval "func_echo $func_quote_for_expand_result"
  1408. }
  1409. $opt_dry_run || {
  1410. eval "$_G_user_locale
  1411. $_G_cmd"
  1412. _G_status=$?
  1413. eval "$_G_safe_locale"
  1414. if test 0 -ne "$_G_status"; then
  1415. eval "(exit $_G_status); $_G_fail_exp"
  1416. fi
  1417. }
  1418. }
  1419. # func_tr_sh
  1420. # ----------
  1421. # Turn $1 into a string suitable for a shell variable name.
  1422. # Result is stored in $func_tr_sh_result. All characters
  1423. # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
  1424. # if $1 begins with a digit, a '_' is prepended as well.
  1425. func_tr_sh ()
  1426. {
  1427. $debug_cmd
  1428. case $1 in
  1429. [0-9]* | *[!a-zA-Z0-9_]*)
  1430. func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
  1431. ;;
  1432. * )
  1433. func_tr_sh_result=$1
  1434. ;;
  1435. esac
  1436. }
  1437. # func_verbose ARG...
  1438. # -------------------
  1439. # Echo program name prefixed message in verbose mode only.
  1440. func_verbose ()
  1441. {
  1442. $debug_cmd
  1443. $opt_verbose && func_echo "$*"
  1444. :
  1445. }
  1446. # func_warn_and_continue ARG...
  1447. # -----------------------------
  1448. # Echo program name prefixed warning message to standard error.
  1449. func_warn_and_continue ()
  1450. {
  1451. $debug_cmd
  1452. $require_term_colors
  1453. func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
  1454. }
  1455. # func_warning CATEGORY ARG...
  1456. # ----------------------------
  1457. # Echo program name prefixed warning message to standard error. Warning
  1458. # messages can be filtered according to CATEGORY, where this function
  1459. # elides messages where CATEGORY is not listed in the global variable
  1460. # 'opt_warning_types'.
  1461. func_warning ()
  1462. {
  1463. $debug_cmd
  1464. # CATEGORY must be in the warning_categories list!
  1465. case " $warning_categories " in
  1466. *" $1 "*) ;;
  1467. *) func_internal_error "invalid warning category '$1'" ;;
  1468. esac
  1469. _G_category=$1
  1470. shift
  1471. case " $opt_warning_types " in
  1472. *" $_G_category "*) $warning_func ${1+"$@"} ;;
  1473. esac
  1474. }
  1475. # func_sort_ver VER1 VER2
  1476. # -----------------------
  1477. # 'sort -V' is not generally available.
  1478. # Note this deviates from the version comparison in automake
  1479. # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
  1480. # but this should suffice as we won't be specifying old
  1481. # version formats or redundant trailing .0 in bootstrap.conf.
  1482. # If we did want full compatibility then we should probably
  1483. # use m4_version_compare from autoconf.
  1484. func_sort_ver ()
  1485. {
  1486. $debug_cmd
  1487. printf '%s\n%s\n' "$1" "$2" \
  1488. | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
  1489. }
  1490. # func_lt_ver PREV CURR
  1491. # ---------------------
  1492. # Return true if PREV and CURR are in the correct order according to
  1493. # func_sort_ver, otherwise false. Use it like this:
  1494. #
  1495. # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
  1496. func_lt_ver ()
  1497. {
  1498. $debug_cmd
  1499. test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
  1500. }
  1501. # Local variables:
  1502. # mode: shell-script
  1503. # sh-indentation: 2
  1504. # eval: (add-hook 'before-save-hook 'time-stamp)
  1505. # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
  1506. # time-stamp-time-zone: "UTC"
  1507. # End:
  1508. #! /bin/sh
  1509. # Set a version string for this script.
  1510. scriptversion=2014-01-07.03; # UTC
  1511. # A portable, pluggable option parser for Bourne shell.
  1512. # Written by Gary V. Vaughan, 2010
  1513. # Copyright (C) 2010-2015 Free Software Foundation, Inc.
  1514. # This is free software; see the source for copying conditions. There is NO
  1515. # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  1516. # This program is free software: you can redistribute it and/or modify
  1517. # it under the terms of the GNU General Public License as published by
  1518. # the Free Software Foundation, either version 3 of the License, or
  1519. # (at your option) any later version.
  1520. # This program is distributed in the hope that it will be useful,
  1521. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  1522. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1523. # GNU General Public License for more details.
  1524. # You should have received a copy of the GNU General Public License
  1525. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  1526. # Please report bugs or propose patches to gary@gnu.org.
  1527. ## ------ ##
  1528. ## Usage. ##
  1529. ## ------ ##
  1530. # This file is a library for parsing options in your shell scripts along
  1531. # with assorted other useful supporting features that you can make use
  1532. # of too.
  1533. #
  1534. # For the simplest scripts you might need only:
  1535. #
  1536. # #!/bin/sh
  1537. # . relative/path/to/funclib.sh
  1538. # . relative/path/to/options-parser
  1539. # scriptversion=1.0
  1540. # func_options ${1+"$@"}
  1541. # eval set dummy "$func_options_result"; shift
  1542. # ...rest of your script...
  1543. #
  1544. # In order for the '--version' option to work, you will need to have a
  1545. # suitably formatted comment like the one at the top of this file
  1546. # starting with '# Written by ' and ending with '# warranty; '.
  1547. #
  1548. # For '-h' and '--help' to work, you will also need a one line
  1549. # description of your script's purpose in a comment directly above the
  1550. # '# Written by ' line, like the one at the top of this file.
  1551. #
  1552. # The default options also support '--debug', which will turn on shell
  1553. # execution tracing (see the comment above debug_cmd below for another
  1554. # use), and '--verbose' and the func_verbose function to allow your script
  1555. # to display verbose messages only when your user has specified
  1556. # '--verbose'.
  1557. #
  1558. # After sourcing this file, you can plug processing for additional
  1559. # options by amending the variables from the 'Configuration' section
  1560. # below, and following the instructions in the 'Option parsing'
  1561. # section further down.
  1562. ## -------------- ##
  1563. ## Configuration. ##
  1564. ## -------------- ##
  1565. # You should override these variables in your script after sourcing this
  1566. # file so that they reflect the customisations you have added to the
  1567. # option parser.
  1568. # The usage line for option parsing errors and the start of '-h' and
  1569. # '--help' output messages. You can embed shell variables for delayed
  1570. # expansion at the time the message is displayed, but you will need to
  1571. # quote other shell meta-characters carefully to prevent them being
  1572. # expanded when the contents are evaled.
  1573. usage='$progpath [OPTION]...'
  1574. # Short help message in response to '-h' and '--help'. Add to this or
  1575. # override it after sourcing this library to reflect the full set of
  1576. # options your script accepts.
  1577. usage_message="\
  1578. --debug enable verbose shell tracing
  1579. -W, --warnings=CATEGORY
  1580. report the warnings falling in CATEGORY [all]
  1581. -v, --verbose verbosely report processing
  1582. --version print version information and exit
  1583. -h, --help print short or long help message and exit
  1584. "
  1585. # Additional text appended to 'usage_message' in response to '--help'.
  1586. long_help_message="
  1587. Warning categories include:
  1588. 'all' show all warnings
  1589. 'none' turn off all the warnings
  1590. 'error' warnings are treated as fatal errors"
  1591. # Help message printed before fatal option parsing errors.
  1592. fatal_help="Try '\$progname --help' for more information."
  1593. ## ------------------------- ##
  1594. ## Hook function management. ##
  1595. ## ------------------------- ##
  1596. # This section contains functions for adding, removing, and running hooks
  1597. # to the main code. A hook is just a named list of of function, that can
  1598. # be run in order later on.
  1599. # func_hookable FUNC_NAME
  1600. # -----------------------
  1601. # Declare that FUNC_NAME will run hooks added with
  1602. # 'func_add_hook FUNC_NAME ...'.
  1603. func_hookable ()
  1604. {
  1605. $debug_cmd
  1606. func_append hookable_fns " $1"
  1607. }
  1608. # func_add_hook FUNC_NAME HOOK_FUNC
  1609. # ---------------------------------
  1610. # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
  1611. # first have been declared "hookable" by a call to 'func_hookable'.
  1612. func_add_hook ()
  1613. {
  1614. $debug_cmd
  1615. case " $hookable_fns " in
  1616. *" $1 "*) ;;
  1617. *) func_fatal_error "'$1' does not accept hook functions." ;;
  1618. esac
  1619. eval func_append ${1}_hooks '" $2"'
  1620. }
  1621. # func_remove_hook FUNC_NAME HOOK_FUNC
  1622. # ------------------------------------
  1623. # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
  1624. func_remove_hook ()
  1625. {
  1626. $debug_cmd
  1627. eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
  1628. }
  1629. # func_run_hooks FUNC_NAME [ARG]...
  1630. # ---------------------------------
  1631. # Run all hook functions registered to FUNC_NAME.
  1632. # It is assumed that the list of hook functions contains nothing more
  1633. # than a whitespace-delimited list of legal shell function names, and
  1634. # no effort is wasted trying to catch shell meta-characters or preserve
  1635. # whitespace.
  1636. func_run_hooks ()
  1637. {
  1638. $debug_cmd
  1639. case " $hookable_fns " in
  1640. *" $1 "*) ;;
  1641. *) func_fatal_error "'$1' does not support hook funcions.n" ;;
  1642. esac
  1643. eval _G_hook_fns=\$$1_hooks; shift
  1644. for _G_hook in $_G_hook_fns; do
  1645. eval $_G_hook '"$@"'
  1646. # store returned options list back into positional
  1647. # parameters for next 'cmd' execution.
  1648. eval _G_hook_result=\$${_G_hook}_result
  1649. eval set dummy "$_G_hook_result"; shift
  1650. done
  1651. func_quote_for_eval ${1+"$@"}
  1652. func_run_hooks_result=$func_quote_for_eval_result
  1653. }
  1654. ## --------------- ##
  1655. ## Option parsing. ##
  1656. ## --------------- ##
  1657. # In order to add your own option parsing hooks, you must accept the
  1658. # full positional parameter list in your hook function, remove any
  1659. # options that you action, and then pass back the remaining unprocessed
  1660. # options in '<hooked_function_name>_result', escaped suitably for
  1661. # 'eval'. Like this:
  1662. #
  1663. # my_options_prep ()
  1664. # {
  1665. # $debug_cmd
  1666. #
  1667. # # Extend the existing usage message.
  1668. # usage_message=$usage_message'
  1669. # -s, --silent don'\''t print informational messages
  1670. # '
  1671. #
  1672. # func_quote_for_eval ${1+"$@"}
  1673. # my_options_prep_result=$func_quote_for_eval_result
  1674. # }
  1675. # func_add_hook func_options_prep my_options_prep
  1676. #
  1677. #
  1678. # my_silent_option ()
  1679. # {
  1680. # $debug_cmd
  1681. #
  1682. # # Note that for efficiency, we parse as many options as we can
  1683. # # recognise in a loop before passing the remainder back to the
  1684. # # caller on the first unrecognised argument we encounter.
  1685. # while test $# -gt 0; do
  1686. # opt=$1; shift
  1687. # case $opt in
  1688. # --silent|-s) opt_silent=: ;;
  1689. # # Separate non-argument short options:
  1690. # -s*) func_split_short_opt "$_G_opt"
  1691. # set dummy "$func_split_short_opt_name" \
  1692. # "-$func_split_short_opt_arg" ${1+"$@"}
  1693. # shift
  1694. # ;;
  1695. # *) set dummy "$_G_opt" "$*"; shift; break ;;
  1696. # esac
  1697. # done
  1698. #
  1699. # func_quote_for_eval ${1+"$@"}
  1700. # my_silent_option_result=$func_quote_for_eval_result
  1701. # }
  1702. # func_add_hook func_parse_options my_silent_option
  1703. #
  1704. #
  1705. # my_option_validation ()
  1706. # {
  1707. # $debug_cmd
  1708. #
  1709. # $opt_silent && $opt_verbose && func_fatal_help "\
  1710. # '--silent' and '--verbose' options are mutually exclusive."
  1711. #
  1712. # func_quote_for_eval ${1+"$@"}
  1713. # my_option_validation_result=$func_quote_for_eval_result
  1714. # }
  1715. # func_add_hook func_validate_options my_option_validation
  1716. #
  1717. # You'll alse need to manually amend $usage_message to reflect the extra
  1718. # options you parse. It's preferable to append if you can, so that
  1719. # multiple option parsing hooks can be added safely.
  1720. # func_options [ARG]...
  1721. # ---------------------
  1722. # All the functions called inside func_options are hookable. See the
  1723. # individual implementations for details.
  1724. func_hookable func_options
  1725. func_options ()
  1726. {
  1727. $debug_cmd
  1728. func_options_prep ${1+"$@"}
  1729. eval func_parse_options \
  1730. ${func_options_prep_result+"$func_options_prep_result"}
  1731. eval func_validate_options \
  1732. ${func_parse_options_result+"$func_parse_options_result"}
  1733. eval func_run_hooks func_options \
  1734. ${func_validate_options_result+"$func_validate_options_result"}
  1735. # save modified positional parameters for caller
  1736. func_options_result=$func_run_hooks_result
  1737. }
  1738. # func_options_prep [ARG]...
  1739. # --------------------------
  1740. # All initialisations required before starting the option parse loop.
  1741. # Note that when calling hook functions, we pass through the list of
  1742. # positional parameters. If a hook function modifies that list, and
  1743. # needs to propogate that back to rest of this script, then the complete
  1744. # modified list must be put in 'func_run_hooks_result' before
  1745. # returning.
  1746. func_hookable func_options_prep
  1747. func_options_prep ()
  1748. {
  1749. $debug_cmd
  1750. # Option defaults:
  1751. opt_verbose=false
  1752. opt_warning_types=
  1753. func_run_hooks func_options_prep ${1+"$@"}
  1754. # save modified positional parameters for caller
  1755. func_options_prep_result=$func_run_hooks_result
  1756. }
  1757. # func_parse_options [ARG]...
  1758. # ---------------------------
  1759. # The main option parsing loop.
  1760. func_hookable func_parse_options
  1761. func_parse_options ()
  1762. {
  1763. $debug_cmd
  1764. func_parse_options_result=
  1765. # this just eases exit handling
  1766. while test $# -gt 0; do
  1767. # Defer to hook functions for initial option parsing, so they
  1768. # get priority in the event of reusing an option name.
  1769. func_run_hooks func_parse_options ${1+"$@"}
  1770. # Adjust func_parse_options positional parameters to match
  1771. eval set dummy "$func_run_hooks_result"; shift
  1772. # Break out of the loop if we already parsed every option.
  1773. test $# -gt 0 || break
  1774. _G_opt=$1
  1775. shift
  1776. case $_G_opt in
  1777. --debug|-x) debug_cmd='set -x'
  1778. func_echo "enabling shell trace mode"
  1779. $debug_cmd
  1780. ;;
  1781. --no-warnings|--no-warning|--no-warn)
  1782. set dummy --warnings none ${1+"$@"}
  1783. shift
  1784. ;;
  1785. --warnings|--warning|-W)
  1786. test $# = 0 && func_missing_arg $_G_opt && break
  1787. case " $warning_categories $1" in
  1788. *" $1 "*)
  1789. # trailing space prevents matching last $1 above
  1790. func_append_uniq opt_warning_types " $1"
  1791. ;;
  1792. *all)
  1793. opt_warning_types=$warning_categories
  1794. ;;
  1795. *none)
  1796. opt_warning_types=none
  1797. warning_func=:
  1798. ;;
  1799. *error)
  1800. opt_warning_types=$warning_categories
  1801. warning_func=func_fatal_error
  1802. ;;
  1803. *)
  1804. func_fatal_error \
  1805. "unsupported warning category: '$1'"
  1806. ;;
  1807. esac
  1808. shift
  1809. ;;
  1810. --verbose|-v) opt_verbose=: ;;
  1811. --version) func_version ;;
  1812. -\?|-h) func_usage ;;
  1813. --help) func_help ;;
  1814. # Separate optargs to long options (plugins may need this):
  1815. --*=*) func_split_equals "$_G_opt"
  1816. set dummy "$func_split_equals_lhs" \
  1817. "$func_split_equals_rhs" ${1+"$@"}
  1818. shift
  1819. ;;
  1820. # Separate optargs to short options:
  1821. -W*)
  1822. func_split_short_opt "$_G_opt"
  1823. set dummy "$func_split_short_opt_name" \
  1824. "$func_split_short_opt_arg" ${1+"$@"}
  1825. shift
  1826. ;;
  1827. # Separate non-argument short options:
  1828. -\?*|-h*|-v*|-x*)
  1829. func_split_short_opt "$_G_opt"
  1830. set dummy "$func_split_short_opt_name" \
  1831. "-$func_split_short_opt_arg" ${1+"$@"}
  1832. shift
  1833. ;;
  1834. --) break ;;
  1835. -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
  1836. *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
  1837. esac
  1838. done
  1839. # save modified positional parameters for caller
  1840. func_quote_for_eval ${1+"$@"}
  1841. func_parse_options_result=$func_quote_for_eval_result
  1842. }
  1843. # func_validate_options [ARG]...
  1844. # ------------------------------
  1845. # Perform any sanity checks on option settings and/or unconsumed
  1846. # arguments.
  1847. func_hookable func_validate_options
  1848. func_validate_options ()
  1849. {
  1850. $debug_cmd
  1851. # Display all warnings if -W was not given.
  1852. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
  1853. func_run_hooks func_validate_options ${1+"$@"}
  1854. # Bail if the options were screwed!
  1855. $exit_cmd $EXIT_FAILURE
  1856. # save modified positional parameters for caller
  1857. func_validate_options_result=$func_run_hooks_result
  1858. }
  1859. ## ----------------- ##
  1860. ## Helper functions. ##
  1861. ## ----------------- ##
  1862. # This section contains the helper functions used by the rest of the
  1863. # hookable option parser framework in ascii-betical order.
  1864. # func_fatal_help ARG...
  1865. # ----------------------
  1866. # Echo program name prefixed message to standard error, followed by
  1867. # a help hint, and exit.
  1868. func_fatal_help ()
  1869. {
  1870. $debug_cmd
  1871. eval \$ECHO \""Usage: $usage"\"
  1872. eval \$ECHO \""$fatal_help"\"
  1873. func_error ${1+"$@"}
  1874. exit $EXIT_FAILURE
  1875. }
  1876. # func_help
  1877. # ---------
  1878. # Echo long help message to standard output and exit.
  1879. func_help ()
  1880. {
  1881. $debug_cmd
  1882. func_usage_message
  1883. $ECHO "$long_help_message"
  1884. exit 0
  1885. }
  1886. # func_missing_arg ARGNAME
  1887. # ------------------------
  1888. # Echo program name prefixed message to standard error and set global
  1889. # exit_cmd.
  1890. func_missing_arg ()
  1891. {
  1892. $debug_cmd
  1893. func_error "Missing argument for '$1'."
  1894. exit_cmd=exit
  1895. }
  1896. # func_split_equals STRING
  1897. # ------------------------
  1898. # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
  1899. # splitting STRING at the '=' sign.
  1900. test -z "$_G_HAVE_XSI_OPS" \
  1901. && (eval 'x=a/b/c;
  1902. test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
  1903. && _G_HAVE_XSI_OPS=yes
  1904. if test yes = "$_G_HAVE_XSI_OPS"
  1905. then
  1906. # This is an XSI compatible shell, allowing a faster implementation...
  1907. eval 'func_split_equals ()
  1908. {
  1909. $debug_cmd
  1910. func_split_equals_lhs=${1%%=*}
  1911. func_split_equals_rhs=${1#*=}
  1912. test "x$func_split_equals_lhs" = "x$1" \
  1913. && func_split_equals_rhs=
  1914. }'
  1915. else
  1916. # ...otherwise fall back to using expr, which is often a shell builtin.
  1917. func_split_equals ()
  1918. {
  1919. $debug_cmd
  1920. func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
  1921. func_split_equals_rhs=
  1922. test "x$func_split_equals_lhs" = "x$1" \
  1923. || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
  1924. }
  1925. fi #func_split_equals
  1926. # func_split_short_opt SHORTOPT
  1927. # -----------------------------
  1928. # Set func_split_short_opt_name and func_split_short_opt_arg shell
  1929. # variables after splitting SHORTOPT after the 2nd character.
  1930. if test yes = "$_G_HAVE_XSI_OPS"
  1931. then
  1932. # This is an XSI compatible shell, allowing a faster implementation...
  1933. eval 'func_split_short_opt ()
  1934. {
  1935. $debug_cmd
  1936. func_split_short_opt_arg=${1#??}
  1937. func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
  1938. }'
  1939. else
  1940. # ...otherwise fall back to using expr, which is often a shell builtin.
  1941. func_split_short_opt ()
  1942. {
  1943. $debug_cmd
  1944. func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
  1945. func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
  1946. }
  1947. fi #func_split_short_opt
  1948. # func_usage
  1949. # ----------
  1950. # Echo short help message to standard output and exit.
  1951. func_usage ()
  1952. {
  1953. $debug_cmd
  1954. func_usage_message
  1955. $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
  1956. exit 0
  1957. }
  1958. # func_usage_message
  1959. # ------------------
  1960. # Echo short help message to standard output.
  1961. func_usage_message ()
  1962. {
  1963. $debug_cmd
  1964. eval \$ECHO \""Usage: $usage"\"
  1965. echo
  1966. $SED -n 's|^# ||
  1967. /^Written by/{
  1968. x;p;x
  1969. }
  1970. h
  1971. /^Written by/q' < "$progpath"
  1972. echo
  1973. eval \$ECHO \""$usage_message"\"
  1974. }
  1975. # func_version
  1976. # ------------
  1977. # Echo version message to standard output and exit.
  1978. func_version ()
  1979. {
  1980. $debug_cmd
  1981. printf '%s\n' "$progname $scriptversion"
  1982. $SED -n '
  1983. /(C)/!b go
  1984. :more
  1985. /\./!{
  1986. N
  1987. s|\n# | |
  1988. b more
  1989. }
  1990. :go
  1991. /^# Written by /,/# warranty; / {
  1992. s|^# ||
  1993. s|^# *$||
  1994. s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
  1995. p
  1996. }
  1997. /^# Written by / {
  1998. s|^# ||
  1999. p
  2000. }
  2001. /^warranty; /q' < "$progpath"
  2002. exit $?
  2003. }
  2004. # Local variables:
  2005. # mode: shell-script
  2006. # sh-indentation: 2
  2007. # eval: (add-hook 'before-save-hook 'time-stamp)
  2008. # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
  2009. # time-stamp-time-zone: "UTC"
  2010. # End:
  2011. # Set a version string.
  2012. scriptversion='(GNU libtool) 2.4.6'
  2013. # func_echo ARG...
  2014. # ----------------
  2015. # Libtool also displays the current mode in messages, so override
  2016. # funclib.sh func_echo with this custom definition.
  2017. func_echo ()
  2018. {
  2019. $debug_cmd
  2020. _G_message=$*
  2021. func_echo_IFS=$IFS
  2022. IFS=$nl
  2023. for _G_line in $_G_message; do
  2024. IFS=$func_echo_IFS
  2025. $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
  2026. done
  2027. IFS=$func_echo_IFS
  2028. }
  2029. # func_warning ARG...
  2030. # -------------------
  2031. # Libtool warnings are not categorized, so override funclib.sh
  2032. # func_warning with this simpler definition.
  2033. func_warning ()
  2034. {
  2035. $debug_cmd
  2036. $warning_func ${1+"$@"}
  2037. }
  2038. ## ---------------- ##
  2039. ## Options parsing. ##
  2040. ## ---------------- ##
  2041. # Hook in the functions to make sure our own options are parsed during
  2042. # the option parsing loop.
  2043. usage='$progpath [OPTION]... [MODE-ARG]...'
  2044. # Short help message in response to '-h'.
  2045. usage_message="Options:
  2046. --config show all configuration variables
  2047. --debug enable verbose shell tracing
  2048. -n, --dry-run display commands without modifying any files
  2049. --features display basic configuration information and exit
  2050. --mode=MODE use operation mode MODE
  2051. --no-warnings equivalent to '-Wnone'
  2052. --preserve-dup-deps don't remove duplicate dependency libraries
  2053. --quiet, --silent don't print informational messages
  2054. --tag=TAG use configuration variables from tag TAG
  2055. -v, --verbose print more informational messages than default
  2056. --version print version information
  2057. -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
  2058. -h, --help, --help-all print short, long, or detailed help message
  2059. "
  2060. # Additional text appended to 'usage_message' in response to '--help'.
  2061. func_help ()
  2062. {
  2063. $debug_cmd
  2064. func_usage_message
  2065. $ECHO "$long_help_message
  2066. MODE must be one of the following:
  2067. clean remove files from the build directory
  2068. compile compile a source file into a libtool object
  2069. execute automatically set library path, then run a program
  2070. finish complete the installation of libtool libraries
  2071. install install libraries or executables
  2072. link create a library or an executable
  2073. uninstall remove libraries from an installed directory
  2074. MODE-ARGS vary depending on the MODE. When passed as first option,
  2075. '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
  2076. Try '$progname --help --mode=MODE' for a more detailed description of MODE.
  2077. When reporting a bug, please describe a test case to reproduce it and
  2078. include the following information:
  2079. host-triplet: $host
  2080. shell: $SHELL
  2081. compiler: $LTCC
  2082. compiler flags: $LTCFLAGS
  2083. linker: $LD (gnu? $with_gnu_ld)
  2084. version: $progname (GNU libtool) 2.4.6
  2085. automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
  2086. autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
  2087. Report bugs to <bug-libtool@gnu.org>.
  2088. GNU libtool home page: <http://www.gnu.org/software/libtool/>.
  2089. General help using GNU software: <http://www.gnu.org/gethelp/>."
  2090. exit 0
  2091. }
  2092. # func_lo2o OBJECT-NAME
  2093. # ---------------------
  2094. # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
  2095. # object suffix.
  2096. lo2o=s/\\.lo\$/.$objext/
  2097. o2lo=s/\\.$objext\$/.lo/
  2098. if test yes = "$_G_HAVE_XSI_OPS"; then
  2099. eval 'func_lo2o ()
  2100. {
  2101. case $1 in
  2102. *.lo) func_lo2o_result=${1%.lo}.$objext ;;
  2103. * ) func_lo2o_result=$1 ;;
  2104. esac
  2105. }'
  2106. # func_xform LIBOBJ-OR-SOURCE
  2107. # ---------------------------
  2108. # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
  2109. # suffix to a '.lo' libtool-object suffix.
  2110. eval 'func_xform ()
  2111. {
  2112. func_xform_result=${1%.*}.lo
  2113. }'
  2114. else
  2115. # ...otherwise fall back to using sed.
  2116. func_lo2o ()
  2117. {
  2118. func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
  2119. }
  2120. func_xform ()
  2121. {
  2122. func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
  2123. }
  2124. fi
  2125. # func_fatal_configuration ARG...
  2126. # -------------------------------
  2127. # Echo program name prefixed message to standard error, followed by
  2128. # a configuration failure hint, and exit.
  2129. func_fatal_configuration ()
  2130. {
  2131. func__fatal_error ${1+"$@"} \
  2132. "See the $PACKAGE documentation for more information." \
  2133. "Fatal configuration error."
  2134. }
  2135. # func_config
  2136. # -----------
  2137. # Display the configuration for all the tags in this script.
  2138. func_config ()
  2139. {
  2140. re_begincf='^# ### BEGIN LIBTOOL'
  2141. re_endcf='^# ### END LIBTOOL'
  2142. # Default configuration.
  2143. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
  2144. # Now print the configurations for the tags.
  2145. for tagname in $taglist; do
  2146. $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
  2147. done
  2148. exit $?
  2149. }
  2150. # func_features
  2151. # -------------
  2152. # Display the features supported by this script.
  2153. func_features ()
  2154. {
  2155. echo "host: $host"
  2156. if test yes = "$build_libtool_libs"; then
  2157. echo "enable shared libraries"
  2158. else
  2159. echo "disable shared libraries"
  2160. fi
  2161. if test yes = "$build_old_libs"; then
  2162. echo "enable static libraries"
  2163. else
  2164. echo "disable static libraries"
  2165. fi
  2166. exit $?
  2167. }
  2168. # func_enable_tag TAGNAME
  2169. # -----------------------
  2170. # Verify that TAGNAME is valid, and either flag an error and exit, or
  2171. # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
  2172. # variable here.
  2173. func_enable_tag ()
  2174. {
  2175. # Global variable:
  2176. tagname=$1
  2177. re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
  2178. re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
  2179. sed_extractcf=/$re_begincf/,/$re_endcf/p
  2180. # Validate tagname.
  2181. case $tagname in
  2182. *[!-_A-Za-z0-9,/]*)
  2183. func_fatal_error "invalid tag name: $tagname"
  2184. ;;
  2185. esac
  2186. # Don't test for the "default" C tag, as we know it's
  2187. # there but not specially marked.
  2188. case $tagname in
  2189. CC) ;;
  2190. *)
  2191. if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
  2192. taglist="$taglist $tagname"
  2193. # Evaluate the configuration. Be careful to quote the path
  2194. # and the sed script, to avoid splitting on whitespace, but
  2195. # also don't use non-portable quotes within backquotes within
  2196. # quotes we have to do it in 2 steps:
  2197. extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
  2198. eval "$extractedcf"
  2199. else
  2200. func_error "ignoring unknown tag $tagname"
  2201. fi
  2202. ;;
  2203. esac
  2204. }
  2205. # func_check_version_match
  2206. # ------------------------
  2207. # Ensure that we are using m4 macros, and libtool script from the same
  2208. # release of libtool.
  2209. func_check_version_match ()
  2210. {
  2211. if test "$package_revision" != "$macro_revision"; then
  2212. if test "$VERSION" != "$macro_version"; then
  2213. if test -z "$macro_version"; then
  2214. cat >&2 <<_LT_EOF
  2215. $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
  2216. $progname: definition of this LT_INIT comes from an older release.
  2217. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  2218. $progname: and run autoconf again.
  2219. _LT_EOF
  2220. else
  2221. cat >&2 <<_LT_EOF
  2222. $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
  2223. $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
  2224. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  2225. $progname: and run autoconf again.
  2226. _LT_EOF
  2227. fi
  2228. else
  2229. cat >&2 <<_LT_EOF
  2230. $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
  2231. $progname: but the definition of this LT_INIT comes from revision $macro_revision.
  2232. $progname: You should recreate aclocal.m4 with macros from revision $package_revision
  2233. $progname: of $PACKAGE $VERSION and run autoconf again.
  2234. _LT_EOF
  2235. fi
  2236. exit $EXIT_MISMATCH
  2237. fi
  2238. }
  2239. # libtool_options_prep [ARG]...
  2240. # -----------------------------
  2241. # Preparation for options parsed by libtool.
  2242. libtool_options_prep ()
  2243. {
  2244. $debug_mode
  2245. # Option defaults:
  2246. opt_config=false
  2247. opt_dlopen=
  2248. opt_dry_run=false
  2249. opt_help=false
  2250. opt_mode=
  2251. opt_preserve_dup_deps=false
  2252. opt_quiet=false
  2253. nonopt=
  2254. preserve_args=
  2255. # Shorthand for --mode=foo, only valid as the first argument
  2256. case $1 in
  2257. clean|clea|cle|cl)
  2258. shift; set dummy --mode clean ${1+"$@"}; shift
  2259. ;;
  2260. compile|compil|compi|comp|com|co|c)
  2261. shift; set dummy --mode compile ${1+"$@"}; shift
  2262. ;;
  2263. execute|execut|execu|exec|exe|ex|e)
  2264. shift; set dummy --mode execute ${1+"$@"}; shift
  2265. ;;
  2266. finish|finis|fini|fin|fi|f)
  2267. shift; set dummy --mode finish ${1+"$@"}; shift
  2268. ;;
  2269. install|instal|insta|inst|ins|in|i)
  2270. shift; set dummy --mode install ${1+"$@"}; shift
  2271. ;;
  2272. link|lin|li|l)
  2273. shift; set dummy --mode link ${1+"$@"}; shift
  2274. ;;
  2275. uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
  2276. shift; set dummy --mode uninstall ${1+"$@"}; shift
  2277. ;;
  2278. esac
  2279. # Pass back the list of options.
  2280. func_quote_for_eval ${1+"$@"}
  2281. libtool_options_prep_result=$func_quote_for_eval_result
  2282. }
  2283. func_add_hook func_options_prep libtool_options_prep
  2284. # libtool_parse_options [ARG]...
  2285. # ---------------------------------
  2286. # Provide handling for libtool specific options.
  2287. libtool_parse_options ()
  2288. {
  2289. $debug_cmd
  2290. # Perform our own loop to consume as many options as possible in
  2291. # each iteration.
  2292. while test $# -gt 0; do
  2293. _G_opt=$1
  2294. shift
  2295. case $_G_opt in
  2296. --dry-run|--dryrun|-n)
  2297. opt_dry_run=:
  2298. ;;
  2299. --config) func_config ;;
  2300. --dlopen|-dlopen)
  2301. opt_dlopen="${opt_dlopen+$opt_dlopen
  2302. }$1"
  2303. shift
  2304. ;;
  2305. --preserve-dup-deps)
  2306. opt_preserve_dup_deps=: ;;
  2307. --features) func_features ;;
  2308. --finish) set dummy --mode finish ${1+"$@"}; shift ;;
  2309. --help) opt_help=: ;;
  2310. --help-all) opt_help=': help-all' ;;
  2311. --mode) test $# = 0 && func_missing_arg $_G_opt && break
  2312. opt_mode=$1
  2313. case $1 in
  2314. # Valid mode arguments:
  2315. clean|compile|execute|finish|install|link|relink|uninstall) ;;
  2316. # Catch anything else as an error
  2317. *) func_error "invalid argument for $_G_opt"
  2318. exit_cmd=exit
  2319. break
  2320. ;;
  2321. esac
  2322. shift
  2323. ;;
  2324. --no-silent|--no-quiet)
  2325. opt_quiet=false
  2326. func_append preserve_args " $_G_opt"
  2327. ;;
  2328. --no-warnings|--no-warning|--no-warn)
  2329. opt_warning=false
  2330. func_append preserve_args " $_G_opt"
  2331. ;;
  2332. --no-verbose)
  2333. opt_verbose=false
  2334. func_append preserve_args " $_G_opt"
  2335. ;;
  2336. --silent|--quiet)
  2337. opt_quiet=:
  2338. opt_verbose=false
  2339. func_append preserve_args " $_G_opt"
  2340. ;;
  2341. --tag) test $# = 0 && func_missing_arg $_G_opt && break
  2342. opt_tag=$1
  2343. func_append preserve_args " $_G_opt $1"
  2344. func_enable_tag "$1"
  2345. shift
  2346. ;;
  2347. --verbose|-v) opt_quiet=false
  2348. opt_verbose=:
  2349. func_append preserve_args " $_G_opt"
  2350. ;;
  2351. # An option not handled by this hook function:
  2352. *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
  2353. esac
  2354. done
  2355. # save modified positional parameters for caller
  2356. func_quote_for_eval ${1+"$@"}
  2357. libtool_parse_options_result=$func_quote_for_eval_result
  2358. }
  2359. func_add_hook func_parse_options libtool_parse_options
  2360. # libtool_validate_options [ARG]...
  2361. # ---------------------------------
  2362. # Perform any sanity checks on option settings and/or unconsumed
  2363. # arguments.
  2364. libtool_validate_options ()
  2365. {
  2366. # save first non-option argument
  2367. if test 0 -lt $#; then
  2368. nonopt=$1
  2369. shift
  2370. fi
  2371. # preserve --debug
  2372. test : = "$debug_cmd" || func_append preserve_args " --debug"
  2373. case $host in
  2374. # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
  2375. # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
  2376. *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
  2377. # don't eliminate duplications in $postdeps and $predeps
  2378. opt_duplicate_compiler_generated_deps=:
  2379. ;;
  2380. *)
  2381. opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
  2382. ;;
  2383. esac
  2384. $opt_help || {
  2385. # Sanity checks first:
  2386. func_check_version_match
  2387. test yes != "$build_libtool_libs" \
  2388. && test yes != "$build_old_libs" \
  2389. && func_fatal_configuration "not configured to build any kind of library"
  2390. # Darwin sucks
  2391. eval std_shrext=\"$shrext_cmds\"
  2392. # Only execute mode is allowed to have -dlopen flags.
  2393. if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
  2394. func_error "unrecognized option '-dlopen'"
  2395. $ECHO "$help" 1>&2
  2396. exit $EXIT_FAILURE
  2397. fi
  2398. # Change the help message to a mode-specific one.
  2399. generic_help=$help
  2400. help="Try '$progname --help --mode=$opt_mode' for more information."
  2401. }
  2402. # Pass back the unparsed argument list
  2403. func_quote_for_eval ${1+"$@"}
  2404. libtool_validate_options_result=$func_quote_for_eval_result
  2405. }
  2406. func_add_hook func_validate_options libtool_validate_options
  2407. # Process options as early as possible so that --help and --version
  2408. # can return quickly.
  2409. func_options ${1+"$@"}
  2410. eval set dummy "$func_options_result"; shift
  2411. ## ----------- ##
  2412. ## Main. ##
  2413. ## ----------- ##
  2414. magic='%%%MAGIC variable%%%'
  2415. magic_exe='%%%MAGIC EXE variable%%%'
  2416. # Global variables.
  2417. extracted_archives=
  2418. extracted_serial=0
  2419. # If this variable is set in any of the actions, the command in it
  2420. # will be execed at the end. This prevents here-documents from being
  2421. # left over by shells.
  2422. exec_cmd=
  2423. # A function that is used when there is no print builtin or printf.
  2424. func_fallback_echo ()
  2425. {
  2426. eval 'cat <<_LTECHO_EOF
  2427. $1
  2428. _LTECHO_EOF'
  2429. }
  2430. # func_generated_by_libtool
  2431. # True iff stdin has been generated by Libtool. This function is only
  2432. # a basic sanity check; it will hardly flush out determined imposters.
  2433. func_generated_by_libtool_p ()
  2434. {
  2435. $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
  2436. }
  2437. # func_lalib_p file
  2438. # True iff FILE is a libtool '.la' library or '.lo' object file.
  2439. # This function is only a basic sanity check; it will hardly flush out
  2440. # determined imposters.
  2441. func_lalib_p ()
  2442. {
  2443. test -f "$1" &&
  2444. $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
  2445. }
  2446. # func_lalib_unsafe_p file
  2447. # True iff FILE is a libtool '.la' library or '.lo' object file.
  2448. # This function implements the same check as func_lalib_p without
  2449. # resorting to external programs. To this end, it redirects stdin and
  2450. # closes it afterwards, without saving the original file descriptor.
  2451. # As a safety measure, use it only where a negative result would be
  2452. # fatal anyway. Works if 'file' does not exist.
  2453. func_lalib_unsafe_p ()
  2454. {
  2455. lalib_p=no
  2456. if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
  2457. for lalib_p_l in 1 2 3 4
  2458. do
  2459. read lalib_p_line
  2460. case $lalib_p_line in
  2461. \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
  2462. esac
  2463. done
  2464. exec 0<&5 5<&-
  2465. fi
  2466. test yes = "$lalib_p"
  2467. }
  2468. # func_ltwrapper_script_p file
  2469. # True iff FILE is a libtool wrapper script
  2470. # This function is only a basic sanity check; it will hardly flush out
  2471. # determined imposters.
  2472. func_ltwrapper_script_p ()
  2473. {
  2474. test -f "$1" &&
  2475. $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
  2476. }
  2477. # func_ltwrapper_executable_p file
  2478. # True iff FILE is a libtool wrapper executable
  2479. # This function is only a basic sanity check; it will hardly flush out
  2480. # determined imposters.
  2481. func_ltwrapper_executable_p ()
  2482. {
  2483. func_ltwrapper_exec_suffix=
  2484. case $1 in
  2485. *.exe) ;;
  2486. *) func_ltwrapper_exec_suffix=.exe ;;
  2487. esac
  2488. $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
  2489. }
  2490. # func_ltwrapper_scriptname file
  2491. # Assumes file is an ltwrapper_executable
  2492. # uses $file to determine the appropriate filename for a
  2493. # temporary ltwrapper_script.
  2494. func_ltwrapper_scriptname ()
  2495. {
  2496. func_dirname_and_basename "$1" "" "."
  2497. func_stripname '' '.exe' "$func_basename_result"
  2498. func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
  2499. }
  2500. # func_ltwrapper_p file
  2501. # True iff FILE is a libtool wrapper script or wrapper executable
  2502. # This function is only a basic sanity check; it will hardly flush out
  2503. # determined imposters.
  2504. func_ltwrapper_p ()
  2505. {
  2506. func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
  2507. }
  2508. # func_execute_cmds commands fail_cmd
  2509. # Execute tilde-delimited COMMANDS.
  2510. # If FAIL_CMD is given, eval that upon failure.
  2511. # FAIL_CMD may read-access the current command in variable CMD!
  2512. func_execute_cmds ()
  2513. {
  2514. $debug_cmd
  2515. save_ifs=$IFS; IFS='~'
  2516. for cmd in $1; do
  2517. IFS=$sp$nl
  2518. eval cmd=\"$cmd\"
  2519. IFS=$save_ifs
  2520. func_show_eval "$cmd" "${2-:}"
  2521. done
  2522. IFS=$save_ifs
  2523. }
  2524. # func_source file
  2525. # Source FILE, adding directory component if necessary.
  2526. # Note that it is not necessary on cygwin/mingw to append a dot to
  2527. # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
  2528. # behavior happens only for exec(3), not for open(2)! Also, sourcing
  2529. # 'FILE.' does not work on cygwin managed mounts.
  2530. func_source ()
  2531. {
  2532. $debug_cmd
  2533. case $1 in
  2534. */* | *\\*) . "$1" ;;
  2535. *) . "./$1" ;;
  2536. esac
  2537. }
  2538. # func_resolve_sysroot PATH
  2539. # Replace a leading = in PATH with a sysroot. Store the result into
  2540. # func_resolve_sysroot_result
  2541. func_resolve_sysroot ()
  2542. {
  2543. func_resolve_sysroot_result=$1
  2544. case $func_resolve_sysroot_result in
  2545. =*)
  2546. func_stripname '=' '' "$func_resolve_sysroot_result"
  2547. func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
  2548. ;;
  2549. esac
  2550. }
  2551. # func_replace_sysroot PATH
  2552. # If PATH begins with the sysroot, replace it with = and
  2553. # store the result into func_replace_sysroot_result.
  2554. func_replace_sysroot ()
  2555. {
  2556. case $lt_sysroot:$1 in
  2557. ?*:"$lt_sysroot"*)
  2558. func_stripname "$lt_sysroot" '' "$1"
  2559. func_replace_sysroot_result='='$func_stripname_result
  2560. ;;
  2561. *)
  2562. # Including no sysroot.
  2563. func_replace_sysroot_result=$1
  2564. ;;
  2565. esac
  2566. }
  2567. # func_infer_tag arg
  2568. # Infer tagged configuration to use if any are available and
  2569. # if one wasn't chosen via the "--tag" command line option.
  2570. # Only attempt this if the compiler in the base compile
  2571. # command doesn't match the default compiler.
  2572. # arg is usually of the form 'gcc ...'
  2573. func_infer_tag ()
  2574. {
  2575. $debug_cmd
  2576. if test -n "$available_tags" && test -z "$tagname"; then
  2577. CC_quoted=
  2578. for arg in $CC; do
  2579. func_append_quoted CC_quoted "$arg"
  2580. done
  2581. CC_expanded=`func_echo_all $CC`
  2582. CC_quoted_expanded=`func_echo_all $CC_quoted`
  2583. case $@ in
  2584. # Blanks in the command may have been stripped by the calling shell,
  2585. # but not from the CC environment variable when configure was run.
  2586. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
  2587. " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
  2588. # Blanks at the start of $base_compile will cause this to fail
  2589. # if we don't check for them as well.
  2590. *)
  2591. for z in $available_tags; do
  2592. if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
  2593. # Evaluate the configuration.
  2594. eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
  2595. CC_quoted=
  2596. for arg in $CC; do
  2597. # Double-quote args containing other shell metacharacters.
  2598. func_append_quoted CC_quoted "$arg"
  2599. done
  2600. CC_expanded=`func_echo_all $CC`
  2601. CC_quoted_expanded=`func_echo_all $CC_quoted`
  2602. case "$@ " in
  2603. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
  2604. " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
  2605. # The compiler in the base compile command matches
  2606. # the one in the tagged configuration.
  2607. # Assume this is the tagged configuration we want.
  2608. tagname=$z
  2609. break
  2610. ;;
  2611. esac
  2612. fi
  2613. done
  2614. # If $tagname still isn't set, then no tagged configuration
  2615. # was found and let the user know that the "--tag" command
  2616. # line option must be used.
  2617. if test -z "$tagname"; then
  2618. func_echo "unable to infer tagged configuration"
  2619. func_fatal_error "specify a tag with '--tag'"
  2620. # else
  2621. # func_verbose "using $tagname tagged configuration"
  2622. fi
  2623. ;;
  2624. esac
  2625. fi
  2626. }
  2627. # func_write_libtool_object output_name pic_name nonpic_name
  2628. # Create a libtool object file (analogous to a ".la" file),
  2629. # but don't create it if we're doing a dry run.
  2630. func_write_libtool_object ()
  2631. {
  2632. write_libobj=$1
  2633. if test yes = "$build_libtool_libs"; then
  2634. write_lobj=\'$2\'
  2635. else
  2636. write_lobj=none
  2637. fi
  2638. if test yes = "$build_old_libs"; then
  2639. write_oldobj=\'$3\'
  2640. else
  2641. write_oldobj=none
  2642. fi
  2643. $opt_dry_run || {
  2644. cat >${write_libobj}T <<EOF
  2645. # $write_libobj - a libtool object file
  2646. # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  2647. #
  2648. # Please DO NOT delete this file!
  2649. # It is necessary for linking the library.
  2650. # Name of the PIC object.
  2651. pic_object=$write_lobj
  2652. # Name of the non-PIC object
  2653. non_pic_object=$write_oldobj
  2654. EOF
  2655. $MV "${write_libobj}T" "$write_libobj"
  2656. }
  2657. }
  2658. ##################################################
  2659. # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
  2660. ##################################################
  2661. # func_convert_core_file_wine_to_w32 ARG
  2662. # Helper function used by file name conversion functions when $build is *nix,
  2663. # and $host is mingw, cygwin, or some other w32 environment. Relies on a
  2664. # correctly configured wine environment available, with the winepath program
  2665. # in $build's $PATH.
  2666. #
  2667. # ARG is the $build file name to be converted to w32 format.
  2668. # Result is available in $func_convert_core_file_wine_to_w32_result, and will
  2669. # be empty on error (or when ARG is empty)
  2670. func_convert_core_file_wine_to_w32 ()
  2671. {
  2672. $debug_cmd
  2673. func_convert_core_file_wine_to_w32_result=$1
  2674. if test -n "$1"; then
  2675. # Unfortunately, winepath does not exit with a non-zero error code, so we
  2676. # are forced to check the contents of stdout. On the other hand, if the
  2677. # command is not found, the shell will set an exit code of 127 and print
  2678. # *an error message* to stdout. So we must check for both error code of
  2679. # zero AND non-empty stdout, which explains the odd construction:
  2680. func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
  2681. if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
  2682. func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
  2683. $SED -e "$sed_naive_backslashify"`
  2684. else
  2685. func_convert_core_file_wine_to_w32_result=
  2686. fi
  2687. fi
  2688. }
  2689. # end: func_convert_core_file_wine_to_w32
  2690. # func_convert_core_path_wine_to_w32 ARG
  2691. # Helper function used by path conversion functions when $build is *nix, and
  2692. # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
  2693. # configured wine environment available, with the winepath program in $build's
  2694. # $PATH. Assumes ARG has no leading or trailing path separator characters.
  2695. #
  2696. # ARG is path to be converted from $build format to win32.
  2697. # Result is available in $func_convert_core_path_wine_to_w32_result.
  2698. # Unconvertible file (directory) names in ARG are skipped; if no directory names
  2699. # are convertible, then the result may be empty.
  2700. func_convert_core_path_wine_to_w32 ()
  2701. {
  2702. $debug_cmd
  2703. # unfortunately, winepath doesn't convert paths, only file names
  2704. func_convert_core_path_wine_to_w32_result=
  2705. if test -n "$1"; then
  2706. oldIFS=$IFS
  2707. IFS=:
  2708. for func_convert_core_path_wine_to_w32_f in $1; do
  2709. IFS=$oldIFS
  2710. func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
  2711. if test -n "$func_convert_core_file_wine_to_w32_result"; then
  2712. if test -z "$func_convert_core_path_wine_to_w32_result"; then
  2713. func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
  2714. else
  2715. func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
  2716. fi
  2717. fi
  2718. done
  2719. IFS=$oldIFS
  2720. fi
  2721. }
  2722. # end: func_convert_core_path_wine_to_w32
  2723. # func_cygpath ARGS...
  2724. # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
  2725. # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
  2726. # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
  2727. # (2), returns the Cygwin file name or path in func_cygpath_result (input
  2728. # file name or path is assumed to be in w32 format, as previously converted
  2729. # from $build's *nix or MSYS format). In case (3), returns the w32 file name
  2730. # or path in func_cygpath_result (input file name or path is assumed to be in
  2731. # Cygwin format). Returns an empty string on error.
  2732. #
  2733. # ARGS are passed to cygpath, with the last one being the file name or path to
  2734. # be converted.
  2735. #
  2736. # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
  2737. # environment variable; do not put it in $PATH.
  2738. func_cygpath ()
  2739. {
  2740. $debug_cmd
  2741. if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
  2742. func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
  2743. if test "$?" -ne 0; then
  2744. # on failure, ensure result is empty
  2745. func_cygpath_result=
  2746. fi
  2747. else
  2748. func_cygpath_result=
  2749. func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
  2750. fi
  2751. }
  2752. #end: func_cygpath
  2753. # func_convert_core_msys_to_w32 ARG
  2754. # Convert file name or path ARG from MSYS format to w32 format. Return
  2755. # result in func_convert_core_msys_to_w32_result.
  2756. func_convert_core_msys_to_w32 ()
  2757. {
  2758. $debug_cmd
  2759. # awkward: cmd appends spaces to result
  2760. func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
  2761. $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
  2762. }
  2763. #end: func_convert_core_msys_to_w32
  2764. # func_convert_file_check ARG1 ARG2
  2765. # Verify that ARG1 (a file name in $build format) was converted to $host
  2766. # format in ARG2. Otherwise, emit an error message, but continue (resetting
  2767. # func_to_host_file_result to ARG1).
  2768. func_convert_file_check ()
  2769. {
  2770. $debug_cmd
  2771. if test -z "$2" && test -n "$1"; then
  2772. func_error "Could not determine host file name corresponding to"
  2773. func_error " '$1'"
  2774. func_error "Continuing, but uninstalled executables may not work."
  2775. # Fallback:
  2776. func_to_host_file_result=$1
  2777. fi
  2778. }
  2779. # end func_convert_file_check
  2780. # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
  2781. # Verify that FROM_PATH (a path in $build format) was converted to $host
  2782. # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
  2783. # func_to_host_file_result to a simplistic fallback value (see below).
  2784. func_convert_path_check ()
  2785. {
  2786. $debug_cmd
  2787. if test -z "$4" && test -n "$3"; then
  2788. func_error "Could not determine the host path corresponding to"
  2789. func_error " '$3'"
  2790. func_error "Continuing, but uninstalled executables may not work."
  2791. # Fallback. This is a deliberately simplistic "conversion" and
  2792. # should not be "improved". See libtool.info.
  2793. if test "x$1" != "x$2"; then
  2794. lt_replace_pathsep_chars="s|$1|$2|g"
  2795. func_to_host_path_result=`echo "$3" |
  2796. $SED -e "$lt_replace_pathsep_chars"`
  2797. else
  2798. func_to_host_path_result=$3
  2799. fi
  2800. fi
  2801. }
  2802. # end func_convert_path_check
  2803. # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
  2804. # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
  2805. # and appending REPL if ORIG matches BACKPAT.
  2806. func_convert_path_front_back_pathsep ()
  2807. {
  2808. $debug_cmd
  2809. case $4 in
  2810. $1 ) func_to_host_path_result=$3$func_to_host_path_result
  2811. ;;
  2812. esac
  2813. case $4 in
  2814. $2 ) func_append func_to_host_path_result "$3"
  2815. ;;
  2816. esac
  2817. }
  2818. # end func_convert_path_front_back_pathsep
  2819. ##################################################
  2820. # $build to $host FILE NAME CONVERSION FUNCTIONS #
  2821. ##################################################
  2822. # invoked via '$to_host_file_cmd ARG'
  2823. #
  2824. # In each case, ARG is the path to be converted from $build to $host format.
  2825. # Result will be available in $func_to_host_file_result.
  2826. # func_to_host_file ARG
  2827. # Converts the file name ARG from $build format to $host format. Return result
  2828. # in func_to_host_file_result.
  2829. func_to_host_file ()
  2830. {
  2831. $debug_cmd
  2832. $to_host_file_cmd "$1"
  2833. }
  2834. # end func_to_host_file
  2835. # func_to_tool_file ARG LAZY
  2836. # converts the file name ARG from $build format to toolchain format. Return
  2837. # result in func_to_tool_file_result. If the conversion in use is listed
  2838. # in (the comma separated) LAZY, no conversion takes place.
  2839. func_to_tool_file ()
  2840. {
  2841. $debug_cmd
  2842. case ,$2, in
  2843. *,"$to_tool_file_cmd",*)
  2844. func_to_tool_file_result=$1
  2845. ;;
  2846. *)
  2847. $to_tool_file_cmd "$1"
  2848. func_to_tool_file_result=$func_to_host_file_result
  2849. ;;
  2850. esac
  2851. }
  2852. # end func_to_tool_file
  2853. # func_convert_file_noop ARG
  2854. # Copy ARG to func_to_host_file_result.
  2855. func_convert_file_noop ()
  2856. {
  2857. func_to_host_file_result=$1
  2858. }
  2859. # end func_convert_file_noop
  2860. # func_convert_file_msys_to_w32 ARG
  2861. # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
  2862. # conversion to w32 is not available inside the cwrapper. Returns result in
  2863. # func_to_host_file_result.
  2864. func_convert_file_msys_to_w32 ()
  2865. {
  2866. $debug_cmd
  2867. func_to_host_file_result=$1
  2868. if test -n "$1"; then
  2869. func_convert_core_msys_to_w32 "$1"
  2870. func_to_host_file_result=$func_convert_core_msys_to_w32_result
  2871. fi
  2872. func_convert_file_check "$1" "$func_to_host_file_result"
  2873. }
  2874. # end func_convert_file_msys_to_w32
  2875. # func_convert_file_cygwin_to_w32 ARG
  2876. # Convert file name ARG from Cygwin to w32 format. Returns result in
  2877. # func_to_host_file_result.
  2878. func_convert_file_cygwin_to_w32 ()
  2879. {
  2880. $debug_cmd
  2881. func_to_host_file_result=$1
  2882. if test -n "$1"; then
  2883. # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
  2884. # LT_CYGPATH in this case.
  2885. func_to_host_file_result=`cygpath -m "$1"`
  2886. fi
  2887. func_convert_file_check "$1" "$func_to_host_file_result"
  2888. }
  2889. # end func_convert_file_cygwin_to_w32
  2890. # func_convert_file_nix_to_w32 ARG
  2891. # Convert file name ARG from *nix to w32 format. Requires a wine environment
  2892. # and a working winepath. Returns result in func_to_host_file_result.
  2893. func_convert_file_nix_to_w32 ()
  2894. {
  2895. $debug_cmd
  2896. func_to_host_file_result=$1
  2897. if test -n "$1"; then
  2898. func_convert_core_file_wine_to_w32 "$1"
  2899. func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
  2900. fi
  2901. func_convert_file_check "$1" "$func_to_host_file_result"
  2902. }
  2903. # end func_convert_file_nix_to_w32
  2904. # func_convert_file_msys_to_cygwin ARG
  2905. # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
  2906. # Returns result in func_to_host_file_result.
  2907. func_convert_file_msys_to_cygwin ()
  2908. {
  2909. $debug_cmd
  2910. func_to_host_file_result=$1
  2911. if test -n "$1"; then
  2912. func_convert_core_msys_to_w32 "$1"
  2913. func_cygpath -u "$func_convert_core_msys_to_w32_result"
  2914. func_to_host_file_result=$func_cygpath_result
  2915. fi
  2916. func_convert_file_check "$1" "$func_to_host_file_result"
  2917. }
  2918. # end func_convert_file_msys_to_cygwin
  2919. # func_convert_file_nix_to_cygwin ARG
  2920. # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
  2921. # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
  2922. # in func_to_host_file_result.
  2923. func_convert_file_nix_to_cygwin ()
  2924. {
  2925. $debug_cmd
  2926. func_to_host_file_result=$1
  2927. if test -n "$1"; then
  2928. # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
  2929. func_convert_core_file_wine_to_w32 "$1"
  2930. func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
  2931. func_to_host_file_result=$func_cygpath_result
  2932. fi
  2933. func_convert_file_check "$1" "$func_to_host_file_result"
  2934. }
  2935. # end func_convert_file_nix_to_cygwin
  2936. #############################################
  2937. # $build to $host PATH CONVERSION FUNCTIONS #
  2938. #############################################
  2939. # invoked via '$to_host_path_cmd ARG'
  2940. #
  2941. # In each case, ARG is the path to be converted from $build to $host format.
  2942. # The result will be available in $func_to_host_path_result.
  2943. #
  2944. # Path separators are also converted from $build format to $host format. If
  2945. # ARG begins or ends with a path separator character, it is preserved (but
  2946. # converted to $host format) on output.
  2947. #
  2948. # All path conversion functions are named using the following convention:
  2949. # file name conversion function : func_convert_file_X_to_Y ()
  2950. # path conversion function : func_convert_path_X_to_Y ()
  2951. # where, for any given $build/$host combination the 'X_to_Y' value is the
  2952. # same. If conversion functions are added for new $build/$host combinations,
  2953. # the two new functions must follow this pattern, or func_init_to_host_path_cmd
  2954. # will break.
  2955. # func_init_to_host_path_cmd
  2956. # Ensures that function "pointer" variable $to_host_path_cmd is set to the
  2957. # appropriate value, based on the value of $to_host_file_cmd.
  2958. to_host_path_cmd=
  2959. func_init_to_host_path_cmd ()
  2960. {
  2961. $debug_cmd
  2962. if test -z "$to_host_path_cmd"; then
  2963. func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
  2964. to_host_path_cmd=func_convert_path_$func_stripname_result
  2965. fi
  2966. }
  2967. # func_to_host_path ARG
  2968. # Converts the path ARG from $build format to $host format. Return result
  2969. # in func_to_host_path_result.
  2970. func_to_host_path ()
  2971. {
  2972. $debug_cmd
  2973. func_init_to_host_path_cmd
  2974. $to_host_path_cmd "$1"
  2975. }
  2976. # end func_to_host_path
  2977. # func_convert_path_noop ARG
  2978. # Copy ARG to func_to_host_path_result.
  2979. func_convert_path_noop ()
  2980. {
  2981. func_to_host_path_result=$1
  2982. }
  2983. # end func_convert_path_noop
  2984. # func_convert_path_msys_to_w32 ARG
  2985. # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
  2986. # conversion to w32 is not available inside the cwrapper. Returns result in
  2987. # func_to_host_path_result.
  2988. func_convert_path_msys_to_w32 ()
  2989. {
  2990. $debug_cmd
  2991. func_to_host_path_result=$1
  2992. if test -n "$1"; then
  2993. # Remove leading and trailing path separator characters from ARG. MSYS
  2994. # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
  2995. # and winepath ignores them completely.
  2996. func_stripname : : "$1"
  2997. func_to_host_path_tmp1=$func_stripname_result
  2998. func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
  2999. func_to_host_path_result=$func_convert_core_msys_to_w32_result
  3000. func_convert_path_check : ";" \
  3001. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  3002. func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  3003. fi
  3004. }
  3005. # end func_convert_path_msys_to_w32
  3006. # func_convert_path_cygwin_to_w32 ARG
  3007. # Convert path ARG from Cygwin to w32 format. Returns result in
  3008. # func_to_host_file_result.
  3009. func_convert_path_cygwin_to_w32 ()
  3010. {
  3011. $debug_cmd
  3012. func_to_host_path_result=$1
  3013. if test -n "$1"; then
  3014. # See func_convert_path_msys_to_w32:
  3015. func_stripname : : "$1"
  3016. func_to_host_path_tmp1=$func_stripname_result
  3017. func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
  3018. func_convert_path_check : ";" \
  3019. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  3020. func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  3021. fi
  3022. }
  3023. # end func_convert_path_cygwin_to_w32
  3024. # func_convert_path_nix_to_w32 ARG
  3025. # Convert path ARG from *nix to w32 format. Requires a wine environment and
  3026. # a working winepath. Returns result in func_to_host_file_result.
  3027. func_convert_path_nix_to_w32 ()
  3028. {
  3029. $debug_cmd
  3030. func_to_host_path_result=$1
  3031. if test -n "$1"; then
  3032. # See func_convert_path_msys_to_w32:
  3033. func_stripname : : "$1"
  3034. func_to_host_path_tmp1=$func_stripname_result
  3035. func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
  3036. func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
  3037. func_convert_path_check : ";" \
  3038. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  3039. func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  3040. fi
  3041. }
  3042. # end func_convert_path_nix_to_w32
  3043. # func_convert_path_msys_to_cygwin ARG
  3044. # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
  3045. # Returns result in func_to_host_file_result.
  3046. func_convert_path_msys_to_cygwin ()
  3047. {
  3048. $debug_cmd
  3049. func_to_host_path_result=$1
  3050. if test -n "$1"; then
  3051. # See func_convert_path_msys_to_w32:
  3052. func_stripname : : "$1"
  3053. func_to_host_path_tmp1=$func_stripname_result
  3054. func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
  3055. func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
  3056. func_to_host_path_result=$func_cygpath_result
  3057. func_convert_path_check : : \
  3058. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  3059. func_convert_path_front_back_pathsep ":*" "*:" : "$1"
  3060. fi
  3061. }
  3062. # end func_convert_path_msys_to_cygwin
  3063. # func_convert_path_nix_to_cygwin ARG
  3064. # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
  3065. # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
  3066. # func_to_host_file_result.
  3067. func_convert_path_nix_to_cygwin ()
  3068. {
  3069. $debug_cmd
  3070. func_to_host_path_result=$1
  3071. if test -n "$1"; then
  3072. # Remove leading and trailing path separator characters from
  3073. # ARG. msys behavior is inconsistent here, cygpath turns them
  3074. # into '.;' and ';.', and winepath ignores them completely.
  3075. func_stripname : : "$1"
  3076. func_to_host_path_tmp1=$func_stripname_result
  3077. func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
  3078. func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
  3079. func_to_host_path_result=$func_cygpath_result
  3080. func_convert_path_check : : \
  3081. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  3082. func_convert_path_front_back_pathsep ":*" "*:" : "$1"
  3083. fi
  3084. }
  3085. # end func_convert_path_nix_to_cygwin
  3086. # func_dll_def_p FILE
  3087. # True iff FILE is a Windows DLL '.def' file.
  3088. # Keep in sync with _LT_DLL_DEF_P in libtool.m4
  3089. func_dll_def_p ()
  3090. {
  3091. $debug_cmd
  3092. func_dll_def_p_tmp=`$SED -n \
  3093. -e 's/^[ ]*//' \
  3094. -e '/^\(;.*\)*$/d' \
  3095. -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
  3096. -e q \
  3097. "$1"`
  3098. test DEF = "$func_dll_def_p_tmp"
  3099. }
  3100. # func_mode_compile arg...
  3101. func_mode_compile ()
  3102. {
  3103. $debug_cmd
  3104. # Get the compilation command and the source file.
  3105. base_compile=
  3106. srcfile=$nonopt # always keep a non-empty value in "srcfile"
  3107. suppress_opt=yes
  3108. suppress_output=
  3109. arg_mode=normal
  3110. libobj=
  3111. later=
  3112. pie_flag=
  3113. for arg
  3114. do
  3115. case $arg_mode in
  3116. arg )
  3117. # do not "continue". Instead, add this to base_compile
  3118. lastarg=$arg
  3119. arg_mode=normal
  3120. ;;
  3121. target )
  3122. libobj=$arg
  3123. arg_mode=normal
  3124. continue
  3125. ;;
  3126. normal )
  3127. # Accept any command-line options.
  3128. case $arg in
  3129. -o)
  3130. test -n "$libobj" && \
  3131. func_fatal_error "you cannot specify '-o' more than once"
  3132. arg_mode=target
  3133. continue
  3134. ;;
  3135. -pie | -fpie | -fPIE)
  3136. func_append pie_flag " $arg"
  3137. continue
  3138. ;;
  3139. -shared | -static | -prefer-pic | -prefer-non-pic)
  3140. func_append later " $arg"
  3141. continue
  3142. ;;
  3143. -no-suppress)
  3144. suppress_opt=no
  3145. continue
  3146. ;;
  3147. -Xcompiler)
  3148. arg_mode=arg # the next one goes into the "base_compile" arg list
  3149. continue # The current "srcfile" will either be retained or
  3150. ;; # replaced later. I would guess that would be a bug.
  3151. -Wc,*)
  3152. func_stripname '-Wc,' '' "$arg"
  3153. args=$func_stripname_result
  3154. lastarg=
  3155. save_ifs=$IFS; IFS=,
  3156. for arg in $args; do
  3157. IFS=$save_ifs
  3158. func_append_quoted lastarg "$arg"
  3159. done
  3160. IFS=$save_ifs
  3161. func_stripname ' ' '' "$lastarg"
  3162. lastarg=$func_stripname_result
  3163. # Add the arguments to base_compile.
  3164. func_append base_compile " $lastarg"
  3165. continue
  3166. ;;
  3167. *)
  3168. # Accept the current argument as the source file.
  3169. # The previous "srcfile" becomes the current argument.
  3170. #
  3171. lastarg=$srcfile
  3172. srcfile=$arg
  3173. ;;
  3174. esac # case $arg
  3175. ;;
  3176. esac # case $arg_mode
  3177. # Aesthetically quote the previous argument.
  3178. func_append_quoted base_compile "$lastarg"
  3179. done # for arg
  3180. case $arg_mode in
  3181. arg)
  3182. func_fatal_error "you must specify an argument for -Xcompile"
  3183. ;;
  3184. target)
  3185. func_fatal_error "you must specify a target with '-o'"
  3186. ;;
  3187. *)
  3188. # Get the name of the library object.
  3189. test -z "$libobj" && {
  3190. func_basename "$srcfile"
  3191. libobj=$func_basename_result
  3192. }
  3193. ;;
  3194. esac
  3195. # Recognize several different file suffixes.
  3196. # If the user specifies -o file.o, it is replaced with file.lo
  3197. case $libobj in
  3198. *.[cCFSifmso] | \
  3199. *.ada | *.adb | *.ads | *.asm | \
  3200. *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
  3201. *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
  3202. func_xform "$libobj"
  3203. libobj=$func_xform_result
  3204. ;;
  3205. esac
  3206. case $libobj in
  3207. *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
  3208. *)
  3209. func_fatal_error "cannot determine name of library object from '$libobj'"
  3210. ;;
  3211. esac
  3212. func_infer_tag $base_compile
  3213. for arg in $later; do
  3214. case $arg in
  3215. -shared)
  3216. test yes = "$build_libtool_libs" \
  3217. || func_fatal_configuration "cannot build a shared library"
  3218. build_old_libs=no
  3219. continue
  3220. ;;
  3221. -static)
  3222. build_libtool_libs=no
  3223. build_old_libs=yes
  3224. continue
  3225. ;;
  3226. -prefer-pic)
  3227. pic_mode=yes
  3228. continue
  3229. ;;
  3230. -prefer-non-pic)
  3231. pic_mode=no
  3232. continue
  3233. ;;
  3234. esac
  3235. done
  3236. func_quote_for_eval "$libobj"
  3237. test "X$libobj" != "X$func_quote_for_eval_result" \
  3238. && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
  3239. && func_warning "libobj name '$libobj' may not contain shell special characters."
  3240. func_dirname_and_basename "$obj" "/" ""
  3241. objname=$func_basename_result
  3242. xdir=$func_dirname_result
  3243. lobj=$xdir$objdir/$objname
  3244. test -z "$base_compile" && \
  3245. func_fatal_help "you must specify a compilation command"
  3246. # Delete any leftover library objects.
  3247. if test yes = "$build_old_libs"; then
  3248. removelist="$obj $lobj $libobj ${libobj}T"
  3249. else
  3250. removelist="$lobj $libobj ${libobj}T"
  3251. fi
  3252. # On Cygwin there's no "real" PIC flag so we must build both object types
  3253. case $host_os in
  3254. cygwin* | mingw* | pw32* | os2* | cegcc*)
  3255. pic_mode=default
  3256. ;;
  3257. esac
  3258. if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
  3259. # non-PIC code in shared libraries is not supported
  3260. pic_mode=default
  3261. fi
  3262. # Calculate the filename of the output object if compiler does
  3263. # not support -o with -c
  3264. if test no = "$compiler_c_o"; then
  3265. output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
  3266. lockfile=$output_obj.lock
  3267. else
  3268. output_obj=
  3269. need_locks=no
  3270. lockfile=
  3271. fi
  3272. # Lock this critical section if it is needed
  3273. # We use this script file to make the link, it avoids creating a new file
  3274. if test yes = "$need_locks"; then
  3275. until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
  3276. func_echo "Waiting for $lockfile to be removed"
  3277. sleep 2
  3278. done
  3279. elif test warn = "$need_locks"; then
  3280. if test -f "$lockfile"; then
  3281. $ECHO "\
  3282. *** ERROR, $lockfile exists and contains:
  3283. `cat $lockfile 2>/dev/null`
  3284. This indicates that another process is trying to use the same
  3285. temporary object file, and libtool could not work around it because
  3286. your compiler does not support '-c' and '-o' together. If you
  3287. repeat this compilation, it may succeed, by chance, but you had better
  3288. avoid parallel builds (make -j) in this platform, or get a better
  3289. compiler."
  3290. $opt_dry_run || $RM $removelist
  3291. exit $EXIT_FAILURE
  3292. fi
  3293. func_append removelist " $output_obj"
  3294. $ECHO "$srcfile" > "$lockfile"
  3295. fi
  3296. $opt_dry_run || $RM $removelist
  3297. func_append removelist " $lockfile"
  3298. trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
  3299. func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
  3300. srcfile=$func_to_tool_file_result
  3301. func_quote_for_eval "$srcfile"
  3302. qsrcfile=$func_quote_for_eval_result
  3303. # Only build a PIC object if we are building libtool libraries.
  3304. if test yes = "$build_libtool_libs"; then
  3305. # Without this assignment, base_compile gets emptied.
  3306. fbsd_hideous_sh_bug=$base_compile
  3307. if test no != "$pic_mode"; then
  3308. command="$base_compile $qsrcfile $pic_flag"
  3309. else
  3310. # Don't build PIC code
  3311. command="$base_compile $qsrcfile"
  3312. fi
  3313. func_mkdir_p "$xdir$objdir"
  3314. if test -z "$output_obj"; then
  3315. # Place PIC objects in $objdir
  3316. func_append command " -o $lobj"
  3317. fi
  3318. func_show_eval_locale "$command" \
  3319. 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
  3320. if test warn = "$need_locks" &&
  3321. test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  3322. $ECHO "\
  3323. *** ERROR, $lockfile contains:
  3324. `cat $lockfile 2>/dev/null`
  3325. but it should contain:
  3326. $srcfile
  3327. This indicates that another process is trying to use the same
  3328. temporary object file, and libtool could not work around it because
  3329. your compiler does not support '-c' and '-o' together. If you
  3330. repeat this compilation, it may succeed, by chance, but you had better
  3331. avoid parallel builds (make -j) in this platform, or get a better
  3332. compiler."
  3333. $opt_dry_run || $RM $removelist
  3334. exit $EXIT_FAILURE
  3335. fi
  3336. # Just move the object if needed, then go on to compile the next one
  3337. if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
  3338. func_show_eval '$MV "$output_obj" "$lobj"' \
  3339. 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
  3340. fi
  3341. # Allow error messages only from the first compilation.
  3342. if test yes = "$suppress_opt"; then
  3343. suppress_output=' >/dev/null 2>&1'
  3344. fi
  3345. fi
  3346. # Only build a position-dependent object if we build old libraries.
  3347. if test yes = "$build_old_libs"; then
  3348. if test yes != "$pic_mode"; then
  3349. # Don't build PIC code
  3350. command="$base_compile $qsrcfile$pie_flag"
  3351. else
  3352. command="$base_compile $qsrcfile $pic_flag"
  3353. fi
  3354. if test yes = "$compiler_c_o"; then
  3355. func_append command " -o $obj"
  3356. fi
  3357. # Suppress compiler output if we already did a PIC compilation.
  3358. func_append command "$suppress_output"
  3359. func_show_eval_locale "$command" \
  3360. '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
  3361. if test warn = "$need_locks" &&
  3362. test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  3363. $ECHO "\
  3364. *** ERROR, $lockfile contains:
  3365. `cat $lockfile 2>/dev/null`
  3366. but it should contain:
  3367. $srcfile
  3368. This indicates that another process is trying to use the same
  3369. temporary object file, and libtool could not work around it because
  3370. your compiler does not support '-c' and '-o' together. If you
  3371. repeat this compilation, it may succeed, by chance, but you had better
  3372. avoid parallel builds (make -j) in this platform, or get a better
  3373. compiler."
  3374. $opt_dry_run || $RM $removelist
  3375. exit $EXIT_FAILURE
  3376. fi
  3377. # Just move the object if needed
  3378. if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
  3379. func_show_eval '$MV "$output_obj" "$obj"' \
  3380. 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
  3381. fi
  3382. fi
  3383. $opt_dry_run || {
  3384. func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
  3385. # Unlock the critical section if it was locked
  3386. if test no != "$need_locks"; then
  3387. removelist=$lockfile
  3388. $RM "$lockfile"
  3389. fi
  3390. }
  3391. exit $EXIT_SUCCESS
  3392. }
  3393. $opt_help || {
  3394. test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
  3395. }
  3396. func_mode_help ()
  3397. {
  3398. # We need to display help for each of the modes.
  3399. case $opt_mode in
  3400. "")
  3401. # Generic help is extracted from the usage comments
  3402. # at the start of this file.
  3403. func_help
  3404. ;;
  3405. clean)
  3406. $ECHO \
  3407. "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
  3408. Remove files from the build directory.
  3409. RM is the name of the program to use to delete files associated with each FILE
  3410. (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
  3411. to RM.
  3412. If FILE is a libtool library, object or program, all the files associated
  3413. with it are deleted. Otherwise, only FILE itself is deleted using RM."
  3414. ;;
  3415. compile)
  3416. $ECHO \
  3417. "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
  3418. Compile a source file into a libtool library object.
  3419. This mode accepts the following additional options:
  3420. -o OUTPUT-FILE set the output file name to OUTPUT-FILE
  3421. -no-suppress do not suppress compiler output for multiple passes
  3422. -prefer-pic try to build PIC objects only
  3423. -prefer-non-pic try to build non-PIC objects only
  3424. -shared do not build a '.o' file suitable for static linking
  3425. -static only build a '.o' file suitable for static linking
  3426. -Wc,FLAG pass FLAG directly to the compiler
  3427. COMPILE-COMMAND is a command to be used in creating a 'standard' object file
  3428. from the given SOURCEFILE.
  3429. The output file name is determined by removing the directory component from
  3430. SOURCEFILE, then substituting the C source code suffix '.c' with the
  3431. library object suffix, '.lo'."
  3432. ;;
  3433. execute)
  3434. $ECHO \
  3435. "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
  3436. Automatically set library path, then run a program.
  3437. This mode accepts the following additional options:
  3438. -dlopen FILE add the directory containing FILE to the library path
  3439. This mode sets the library path environment variable according to '-dlopen'
  3440. flags.
  3441. If any of the ARGS are libtool executable wrappers, then they are translated
  3442. into their corresponding uninstalled binary, and any of their required library
  3443. directories are added to the library path.
  3444. Then, COMMAND is executed, with ARGS as arguments."
  3445. ;;
  3446. finish)
  3447. $ECHO \
  3448. "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
  3449. Complete the installation of libtool libraries.
  3450. Each LIBDIR is a directory that contains libtool libraries.
  3451. The commands that this mode executes may require superuser privileges. Use
  3452. the '--dry-run' option if you just want to see what would be executed."
  3453. ;;
  3454. install)
  3455. $ECHO \
  3456. "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
  3457. Install executables or libraries.
  3458. INSTALL-COMMAND is the installation command. The first component should be
  3459. either the 'install' or 'cp' program.
  3460. The following components of INSTALL-COMMAND are treated specially:
  3461. -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
  3462. The rest of the components are interpreted as arguments to that command (only
  3463. BSD-compatible install options are recognized)."
  3464. ;;
  3465. link)
  3466. $ECHO \
  3467. "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
  3468. Link object files or libraries together to form another library, or to
  3469. create an executable program.
  3470. LINK-COMMAND is a command using the C compiler that you would use to create
  3471. a program from several object files.
  3472. The following components of LINK-COMMAND are treated specially:
  3473. -all-static do not do any dynamic linking at all
  3474. -avoid-version do not add a version suffix if possible
  3475. -bindir BINDIR specify path to binaries directory (for systems where
  3476. libraries must be found in the PATH setting at runtime)
  3477. -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
  3478. -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
  3479. -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
  3480. -export-symbols SYMFILE
  3481. try to export only the symbols listed in SYMFILE
  3482. -export-symbols-regex REGEX
  3483. try to export only the symbols matching REGEX
  3484. -LLIBDIR search LIBDIR for required installed libraries
  3485. -lNAME OUTPUT-FILE requires the installed library libNAME
  3486. -module build a library that can dlopened
  3487. -no-fast-install disable the fast-install mode
  3488. -no-install link a not-installable executable
  3489. -no-undefined declare that a library does not refer to external symbols
  3490. -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
  3491. -objectlist FILE use a list of object files found in FILE to specify objects
  3492. -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
  3493. -precious-files-regex REGEX
  3494. don't remove output files matching REGEX
  3495. -release RELEASE specify package release information
  3496. -rpath LIBDIR the created library will eventually be installed in LIBDIR
  3497. -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
  3498. -shared only do dynamic linking of libtool libraries
  3499. -shrext SUFFIX override the standard shared library file extension
  3500. -static do not do any dynamic linking of uninstalled libtool libraries
  3501. -static-libtool-libs
  3502. do not do any dynamic linking of libtool libraries
  3503. -version-info CURRENT[:REVISION[:AGE]]
  3504. specify library version info [each variable defaults to 0]
  3505. -weak LIBNAME declare that the target provides the LIBNAME interface
  3506. -Wc,FLAG
  3507. -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
  3508. -Wl,FLAG
  3509. -Xlinker FLAG pass linker-specific FLAG directly to the linker
  3510. -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
  3511. All other options (arguments beginning with '-') are ignored.
  3512. Every other argument is treated as a filename. Files ending in '.la' are
  3513. treated as uninstalled libtool libraries, other files are standard or library
  3514. object files.
  3515. If the OUTPUT-FILE ends in '.la', then a libtool library is created,
  3516. only library objects ('.lo' files) may be specified, and '-rpath' is
  3517. required, except when creating a convenience library.
  3518. If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
  3519. using 'ar' and 'ranlib', or on Windows using 'lib'.
  3520. If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
  3521. is created, otherwise an executable program is created."
  3522. ;;
  3523. uninstall)
  3524. $ECHO \
  3525. "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
  3526. Remove libraries from an installation directory.
  3527. RM is the name of the program to use to delete files associated with each FILE
  3528. (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
  3529. to RM.
  3530. If FILE is a libtool library, all the files associated with it are deleted.
  3531. Otherwise, only FILE itself is deleted using RM."
  3532. ;;
  3533. *)
  3534. func_fatal_help "invalid operation mode '$opt_mode'"
  3535. ;;
  3536. esac
  3537. echo
  3538. $ECHO "Try '$progname --help' for more information about other modes."
  3539. }
  3540. # Now that we've collected a possible --mode arg, show help if necessary
  3541. if $opt_help; then
  3542. if test : = "$opt_help"; then
  3543. func_mode_help
  3544. else
  3545. {
  3546. func_help noexit
  3547. for opt_mode in compile link execute install finish uninstall clean; do
  3548. func_mode_help
  3549. done
  3550. } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
  3551. {
  3552. func_help noexit
  3553. for opt_mode in compile link execute install finish uninstall clean; do
  3554. echo
  3555. func_mode_help
  3556. done
  3557. } |
  3558. $SED '1d
  3559. /^When reporting/,/^Report/{
  3560. H
  3561. d
  3562. }
  3563. $x
  3564. /information about other modes/d
  3565. /more detailed .*MODE/d
  3566. s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
  3567. fi
  3568. exit $?
  3569. fi
  3570. # func_mode_execute arg...
  3571. func_mode_execute ()
  3572. {
  3573. $debug_cmd
  3574. # The first argument is the command name.
  3575. cmd=$nonopt
  3576. test -z "$cmd" && \
  3577. func_fatal_help "you must specify a COMMAND"
  3578. # Handle -dlopen flags immediately.
  3579. for file in $opt_dlopen; do
  3580. test -f "$file" \
  3581. || func_fatal_help "'$file' is not a file"
  3582. dir=
  3583. case $file in
  3584. *.la)
  3585. func_resolve_sysroot "$file"
  3586. file=$func_resolve_sysroot_result
  3587. # Check to see that this really is a libtool archive.
  3588. func_lalib_unsafe_p "$file" \
  3589. || func_fatal_help "'$lib' is not a valid libtool archive"
  3590. # Read the libtool library.
  3591. dlname=
  3592. library_names=
  3593. func_source "$file"
  3594. # Skip this library if it cannot be dlopened.
  3595. if test -z "$dlname"; then
  3596. # Warn if it was a shared library.
  3597. test -n "$library_names" && \
  3598. func_warning "'$file' was not linked with '-export-dynamic'"
  3599. continue
  3600. fi
  3601. func_dirname "$file" "" "."
  3602. dir=$func_dirname_result
  3603. if test -f "$dir/$objdir/$dlname"; then
  3604. func_append dir "/$objdir"
  3605. else
  3606. if test ! -f "$dir/$dlname"; then
  3607. func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
  3608. fi
  3609. fi
  3610. ;;
  3611. *.lo)
  3612. # Just add the directory containing the .lo file.
  3613. func_dirname "$file" "" "."
  3614. dir=$func_dirname_result
  3615. ;;
  3616. *)
  3617. func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
  3618. continue
  3619. ;;
  3620. esac
  3621. # Get the absolute pathname.
  3622. absdir=`cd "$dir" && pwd`
  3623. test -n "$absdir" && dir=$absdir
  3624. # Now add the directory to shlibpath_var.
  3625. if eval "test -z \"\$$shlibpath_var\""; then
  3626. eval "$shlibpath_var=\"\$dir\""
  3627. else
  3628. eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
  3629. fi
  3630. done
  3631. # This variable tells wrapper scripts just to set shlibpath_var
  3632. # rather than running their programs.
  3633. libtool_execute_magic=$magic
  3634. # Check if any of the arguments is a wrapper script.
  3635. args=
  3636. for file
  3637. do
  3638. case $file in
  3639. -* | *.la | *.lo ) ;;
  3640. *)
  3641. # Do a test to see if this is really a libtool program.
  3642. if func_ltwrapper_script_p "$file"; then
  3643. func_source "$file"
  3644. # Transform arg to wrapped name.
  3645. file=$progdir/$program
  3646. elif func_ltwrapper_executable_p "$file"; then
  3647. func_ltwrapper_scriptname "$file"
  3648. func_source "$func_ltwrapper_scriptname_result"
  3649. # Transform arg to wrapped name.
  3650. file=$progdir/$program
  3651. fi
  3652. ;;
  3653. esac
  3654. # Quote arguments (to preserve shell metacharacters).
  3655. func_append_quoted args "$file"
  3656. done
  3657. if $opt_dry_run; then
  3658. # Display what would be done.
  3659. if test -n "$shlibpath_var"; then
  3660. eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
  3661. echo "export $shlibpath_var"
  3662. fi
  3663. $ECHO "$cmd$args"
  3664. exit $EXIT_SUCCESS
  3665. else
  3666. if test -n "$shlibpath_var"; then
  3667. # Export the shlibpath_var.
  3668. eval "export $shlibpath_var"
  3669. fi
  3670. # Restore saved environment variables
  3671. for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  3672. do
  3673. eval "if test \"\${save_$lt_var+set}\" = set; then
  3674. $lt_var=\$save_$lt_var; export $lt_var
  3675. else
  3676. $lt_unset $lt_var
  3677. fi"
  3678. done
  3679. # Now prepare to actually exec the command.
  3680. exec_cmd=\$cmd$args
  3681. fi
  3682. }
  3683. test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
  3684. # func_mode_finish arg...
  3685. func_mode_finish ()
  3686. {
  3687. $debug_cmd
  3688. libs=
  3689. libdirs=
  3690. admincmds=
  3691. for opt in "$nonopt" ${1+"$@"}
  3692. do
  3693. if test -d "$opt"; then
  3694. func_append libdirs " $opt"
  3695. elif test -f "$opt"; then
  3696. if func_lalib_unsafe_p "$opt"; then
  3697. func_append libs " $opt"
  3698. else
  3699. func_warning "'$opt' is not a valid libtool archive"
  3700. fi
  3701. else
  3702. func_fatal_error "invalid argument '$opt'"
  3703. fi
  3704. done
  3705. if test -n "$libs"; then
  3706. if test -n "$lt_sysroot"; then
  3707. sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
  3708. sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
  3709. else
  3710. sysroot_cmd=
  3711. fi
  3712. # Remove sysroot references
  3713. if $opt_dry_run; then
  3714. for lib in $libs; do
  3715. echo "removing references to $lt_sysroot and '=' prefixes from $lib"
  3716. done
  3717. else
  3718. tmpdir=`func_mktempdir`
  3719. for lib in $libs; do
  3720. $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
  3721. > $tmpdir/tmp-la
  3722. mv -f $tmpdir/tmp-la $lib
  3723. done
  3724. ${RM}r "$tmpdir"
  3725. fi
  3726. fi
  3727. if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
  3728. for libdir in $libdirs; do
  3729. if test -n "$finish_cmds"; then
  3730. # Do each command in the finish commands.
  3731. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
  3732. '"$cmd"'"'
  3733. fi
  3734. if test -n "$finish_eval"; then
  3735. # Do the single finish_eval.
  3736. eval cmds=\"$finish_eval\"
  3737. $opt_dry_run || eval "$cmds" || func_append admincmds "
  3738. $cmds"
  3739. fi
  3740. done
  3741. fi
  3742. # Exit here if they wanted silent mode.
  3743. $opt_quiet && exit $EXIT_SUCCESS
  3744. if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
  3745. echo "----------------------------------------------------------------------"
  3746. echo "Libraries have been installed in:"
  3747. for libdir in $libdirs; do
  3748. $ECHO " $libdir"
  3749. done
  3750. echo
  3751. echo "If you ever happen to want to link against installed libraries"
  3752. echo "in a given directory, LIBDIR, you must either use libtool, and"
  3753. echo "specify the full pathname of the library, or use the '-LLIBDIR'"
  3754. echo "flag during linking and do at least one of the following:"
  3755. if test -n "$shlibpath_var"; then
  3756. echo " - add LIBDIR to the '$shlibpath_var' environment variable"
  3757. echo " during execution"
  3758. fi
  3759. if test -n "$runpath_var"; then
  3760. echo " - add LIBDIR to the '$runpath_var' environment variable"
  3761. echo " during linking"
  3762. fi
  3763. if test -n "$hardcode_libdir_flag_spec"; then
  3764. libdir=LIBDIR
  3765. eval flag=\"$hardcode_libdir_flag_spec\"
  3766. $ECHO " - use the '$flag' linker flag"
  3767. fi
  3768. if test -n "$admincmds"; then
  3769. $ECHO " - have your system administrator run these commands:$admincmds"
  3770. fi
  3771. if test -f /etc/ld.so.conf; then
  3772. echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
  3773. fi
  3774. echo
  3775. echo "See any operating system documentation about shared libraries for"
  3776. case $host in
  3777. solaris2.[6789]|solaris2.1[0-9])
  3778. echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
  3779. echo "pages."
  3780. ;;
  3781. *)
  3782. echo "more information, such as the ld(1) and ld.so(8) manual pages."
  3783. ;;
  3784. esac
  3785. echo "----------------------------------------------------------------------"
  3786. fi
  3787. exit $EXIT_SUCCESS
  3788. }
  3789. test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
  3790. # func_mode_install arg...
  3791. func_mode_install ()
  3792. {
  3793. $debug_cmd
  3794. # There may be an optional sh(1) argument at the beginning of
  3795. # install_prog (especially on Windows NT).
  3796. if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
  3797. # Allow the use of GNU shtool's install command.
  3798. case $nonopt in *shtool*) :;; *) false;; esac
  3799. then
  3800. # Aesthetically quote it.
  3801. func_quote_for_eval "$nonopt"
  3802. install_prog="$func_quote_for_eval_result "
  3803. arg=$1
  3804. shift
  3805. else
  3806. install_prog=
  3807. arg=$nonopt
  3808. fi
  3809. # The real first argument should be the name of the installation program.
  3810. # Aesthetically quote it.
  3811. func_quote_for_eval "$arg"
  3812. func_append install_prog "$func_quote_for_eval_result"
  3813. install_shared_prog=$install_prog
  3814. case " $install_prog " in
  3815. *[\\\ /]cp\ *) install_cp=: ;;
  3816. *) install_cp=false ;;
  3817. esac
  3818. # We need to accept at least all the BSD install flags.
  3819. dest=
  3820. files=
  3821. opts=
  3822. prev=
  3823. install_type=
  3824. isdir=false
  3825. stripme=
  3826. no_mode=:
  3827. for arg
  3828. do
  3829. arg2=
  3830. if test -n "$dest"; then
  3831. func_append files " $dest"
  3832. dest=$arg
  3833. continue
  3834. fi
  3835. case $arg in
  3836. -d) isdir=: ;;
  3837. -f)
  3838. if $install_cp; then :; else
  3839. prev=$arg
  3840. fi
  3841. ;;
  3842. -g | -m | -o)
  3843. prev=$arg
  3844. ;;
  3845. -s)
  3846. stripme=" -s"
  3847. continue
  3848. ;;
  3849. -*)
  3850. ;;
  3851. *)
  3852. # If the previous option needed an argument, then skip it.
  3853. if test -n "$prev"; then
  3854. if test X-m = "X$prev" && test -n "$install_override_mode"; then
  3855. arg2=$install_override_mode
  3856. no_mode=false
  3857. fi
  3858. prev=
  3859. else
  3860. dest=$arg
  3861. continue
  3862. fi
  3863. ;;
  3864. esac
  3865. # Aesthetically quote the argument.
  3866. func_quote_for_eval "$arg"
  3867. func_append install_prog " $func_quote_for_eval_result"
  3868. if test -n "$arg2"; then
  3869. func_quote_for_eval "$arg2"
  3870. fi
  3871. func_append install_shared_prog " $func_quote_for_eval_result"
  3872. done
  3873. test -z "$install_prog" && \
  3874. func_fatal_help "you must specify an install program"
  3875. test -n "$prev" && \
  3876. func_fatal_help "the '$prev' option requires an argument"
  3877. if test -n "$install_override_mode" && $no_mode; then
  3878. if $install_cp; then :; else
  3879. func_quote_for_eval "$install_override_mode"
  3880. func_append install_shared_prog " -m $func_quote_for_eval_result"
  3881. fi
  3882. fi
  3883. if test -z "$files"; then
  3884. if test -z "$dest"; then
  3885. func_fatal_help "no file or destination specified"
  3886. else
  3887. func_fatal_help "you must specify a destination"
  3888. fi
  3889. fi
  3890. # Strip any trailing slash from the destination.
  3891. func_stripname '' '/' "$dest"
  3892. dest=$func_stripname_result
  3893. # Check to see that the destination is a directory.
  3894. test -d "$dest" && isdir=:
  3895. if $isdir; then
  3896. destdir=$dest
  3897. destname=
  3898. else
  3899. func_dirname_and_basename "$dest" "" "."
  3900. destdir=$func_dirname_result
  3901. destname=$func_basename_result
  3902. # Not a directory, so check to see that there is only one file specified.
  3903. set dummy $files; shift
  3904. test "$#" -gt 1 && \
  3905. func_fatal_help "'$dest' is not a directory"
  3906. fi
  3907. case $destdir in
  3908. [\\/]* | [A-Za-z]:[\\/]*) ;;
  3909. *)
  3910. for file in $files; do
  3911. case $file in
  3912. *.lo) ;;
  3913. *)
  3914. func_fatal_help "'$destdir' must be an absolute directory name"
  3915. ;;
  3916. esac
  3917. done
  3918. ;;
  3919. esac
  3920. # This variable tells wrapper scripts just to set variables rather
  3921. # than running their programs.
  3922. libtool_install_magic=$magic
  3923. staticlibs=
  3924. future_libdirs=
  3925. current_libdirs=
  3926. for file in $files; do
  3927. # Do each installation.
  3928. case $file in
  3929. *.$libext)
  3930. # Do the static libraries later.
  3931. func_append staticlibs " $file"
  3932. ;;
  3933. *.la)
  3934. func_resolve_sysroot "$file"
  3935. file=$func_resolve_sysroot_result
  3936. # Check to see that this really is a libtool archive.
  3937. func_lalib_unsafe_p "$file" \
  3938. || func_fatal_help "'$file' is not a valid libtool archive"
  3939. library_names=
  3940. old_library=
  3941. relink_command=
  3942. func_source "$file"
  3943. # Add the libdir to current_libdirs if it is the destination.
  3944. if test "X$destdir" = "X$libdir"; then
  3945. case "$current_libdirs " in
  3946. *" $libdir "*) ;;
  3947. *) func_append current_libdirs " $libdir" ;;
  3948. esac
  3949. else
  3950. # Note the libdir as a future libdir.
  3951. case "$future_libdirs " in
  3952. *" $libdir "*) ;;
  3953. *) func_append future_libdirs " $libdir" ;;
  3954. esac
  3955. fi
  3956. func_dirname "$file" "/" ""
  3957. dir=$func_dirname_result
  3958. func_append dir "$objdir"
  3959. if test -n "$relink_command"; then
  3960. # Determine the prefix the user has applied to our future dir.
  3961. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
  3962. # Don't allow the user to place us outside of our expected
  3963. # location b/c this prevents finding dependent libraries that
  3964. # are installed to the same prefix.
  3965. # At present, this check doesn't affect windows .dll's that
  3966. # are installed into $libdir/../bin (currently, that works fine)
  3967. # but it's something to keep an eye on.
  3968. test "$inst_prefix_dir" = "$destdir" && \
  3969. func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
  3970. if test -n "$inst_prefix_dir"; then
  3971. # Stick the inst_prefix_dir data into the link command.
  3972. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
  3973. else
  3974. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
  3975. fi
  3976. func_warning "relinking '$file'"
  3977. func_show_eval "$relink_command" \
  3978. 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
  3979. fi
  3980. # See the names of the shared library.
  3981. set dummy $library_names; shift
  3982. if test -n "$1"; then
  3983. realname=$1
  3984. shift
  3985. srcname=$realname
  3986. test -n "$relink_command" && srcname=${realname}T
  3987. # Install the shared library and build the symlinks.
  3988. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
  3989. 'exit $?'
  3990. tstripme=$stripme
  3991. case $host_os in
  3992. cygwin* | mingw* | pw32* | cegcc*)
  3993. case $realname in
  3994. *.dll.a)
  3995. tstripme=
  3996. ;;
  3997. esac
  3998. ;;
  3999. os2*)
  4000. case $realname in
  4001. *_dll.a)
  4002. tstripme=
  4003. ;;
  4004. esac
  4005. ;;
  4006. esac
  4007. if test -n "$tstripme" && test -n "$striplib"; then
  4008. func_show_eval "$striplib $destdir/$realname" 'exit $?'
  4009. fi
  4010. if test "$#" -gt 0; then
  4011. # Delete the old symlinks, and create new ones.
  4012. # Try 'ln -sf' first, because the 'ln' binary might depend on
  4013. # the symlink we replace! Solaris /bin/ln does not understand -f,
  4014. # so we also need to try rm && ln -s.
  4015. for linkname
  4016. do
  4017. test "$linkname" != "$realname" \
  4018. && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
  4019. done
  4020. fi
  4021. # Do each command in the postinstall commands.
  4022. lib=$destdir/$realname
  4023. func_execute_cmds "$postinstall_cmds" 'exit $?'
  4024. fi
  4025. # Install the pseudo-library for information purposes.
  4026. func_basename "$file"
  4027. name=$func_basename_result
  4028. instname=$dir/${name}i
  4029. func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
  4030. # Maybe install the static library, too.
  4031. test -n "$old_library" && func_append staticlibs " $dir/$old_library"
  4032. ;;
  4033. *.lo)
  4034. # Install (i.e. copy) a libtool object.
  4035. # Figure out destination file name, if it wasn't already specified.
  4036. if test -n "$destname"; then
  4037. destfile=$destdir/$destname
  4038. else
  4039. func_basename "$file"
  4040. destfile=$func_basename_result
  4041. destfile=$destdir/$destfile
  4042. fi
  4043. # Deduce the name of the destination old-style object file.
  4044. case $destfile in
  4045. *.lo)
  4046. func_lo2o "$destfile"
  4047. staticdest=$func_lo2o_result
  4048. ;;
  4049. *.$objext)
  4050. staticdest=$destfile
  4051. destfile=
  4052. ;;
  4053. *)
  4054. func_fatal_help "cannot copy a libtool object to '$destfile'"
  4055. ;;
  4056. esac
  4057. # Install the libtool object if requested.
  4058. test -n "$destfile" && \
  4059. func_show_eval "$install_prog $file $destfile" 'exit $?'
  4060. # Install the old object if enabled.
  4061. if test yes = "$build_old_libs"; then
  4062. # Deduce the name of the old-style object file.
  4063. func_lo2o "$file"
  4064. staticobj=$func_lo2o_result
  4065. func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
  4066. fi
  4067. exit $EXIT_SUCCESS
  4068. ;;
  4069. *)
  4070. # Figure out destination file name, if it wasn't already specified.
  4071. if test -n "$destname"; then
  4072. destfile=$destdir/$destname
  4073. else
  4074. func_basename "$file"
  4075. destfile=$func_basename_result
  4076. destfile=$destdir/$destfile
  4077. fi
  4078. # If the file is missing, and there is a .exe on the end, strip it
  4079. # because it is most likely a libtool script we actually want to
  4080. # install
  4081. stripped_ext=
  4082. case $file in
  4083. *.exe)
  4084. if test ! -f "$file"; then
  4085. func_stripname '' '.exe' "$file"
  4086. file=$func_stripname_result
  4087. stripped_ext=.exe
  4088. fi
  4089. ;;
  4090. esac
  4091. # Do a test to see if this is really a libtool program.
  4092. case $host in
  4093. *cygwin* | *mingw*)
  4094. if func_ltwrapper_executable_p "$file"; then
  4095. func_ltwrapper_scriptname "$file"
  4096. wrapper=$func_ltwrapper_scriptname_result
  4097. else
  4098. func_stripname '' '.exe' "$file"
  4099. wrapper=$func_stripname_result
  4100. fi
  4101. ;;
  4102. *)
  4103. wrapper=$file
  4104. ;;
  4105. esac
  4106. if func_ltwrapper_script_p "$wrapper"; then
  4107. notinst_deplibs=
  4108. relink_command=
  4109. func_source "$wrapper"
  4110. # Check the variables that should have been set.
  4111. test -z "$generated_by_libtool_version" && \
  4112. func_fatal_error "invalid libtool wrapper script '$wrapper'"
  4113. finalize=:
  4114. for lib in $notinst_deplibs; do
  4115. # Check to see that each library is installed.
  4116. libdir=
  4117. if test -f "$lib"; then
  4118. func_source "$lib"
  4119. fi
  4120. libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
  4121. if test -n "$libdir" && test ! -f "$libfile"; then
  4122. func_warning "'$lib' has not been installed in '$libdir'"
  4123. finalize=false
  4124. fi
  4125. done
  4126. relink_command=
  4127. func_source "$wrapper"
  4128. outputname=
  4129. if test no = "$fast_install" && test -n "$relink_command"; then
  4130. $opt_dry_run || {
  4131. if $finalize; then
  4132. tmpdir=`func_mktempdir`
  4133. func_basename "$file$stripped_ext"
  4134. file=$func_basename_result
  4135. outputname=$tmpdir/$file
  4136. # Replace the output file specification.
  4137. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
  4138. $opt_quiet || {
  4139. func_quote_for_expand "$relink_command"
  4140. eval "func_echo $func_quote_for_expand_result"
  4141. }
  4142. if eval "$relink_command"; then :
  4143. else
  4144. func_error "error: relink '$file' with the above command before installing it"
  4145. $opt_dry_run || ${RM}r "$tmpdir"
  4146. continue
  4147. fi
  4148. file=$outputname
  4149. else
  4150. func_warning "cannot relink '$file'"
  4151. fi
  4152. }
  4153. else
  4154. # Install the binary that we compiled earlier.
  4155. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
  4156. fi
  4157. fi
  4158. # remove .exe since cygwin /usr/bin/install will append another
  4159. # one anyway
  4160. case $install_prog,$host in
  4161. */usr/bin/install*,*cygwin*)
  4162. case $file:$destfile in
  4163. *.exe:*.exe)
  4164. # this is ok
  4165. ;;
  4166. *.exe:*)
  4167. destfile=$destfile.exe
  4168. ;;
  4169. *:*.exe)
  4170. func_stripname '' '.exe' "$destfile"
  4171. destfile=$func_stripname_result
  4172. ;;
  4173. esac
  4174. ;;
  4175. esac
  4176. func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
  4177. $opt_dry_run || if test -n "$outputname"; then
  4178. ${RM}r "$tmpdir"
  4179. fi
  4180. ;;
  4181. esac
  4182. done
  4183. for file in $staticlibs; do
  4184. func_basename "$file"
  4185. name=$func_basename_result
  4186. # Set up the ranlib parameters.
  4187. oldlib=$destdir/$name
  4188. func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
  4189. tool_oldlib=$func_to_tool_file_result
  4190. func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
  4191. if test -n "$stripme" && test -n "$old_striplib"; then
  4192. func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
  4193. fi
  4194. # Do each command in the postinstall commands.
  4195. func_execute_cmds "$old_postinstall_cmds" 'exit $?'
  4196. done
  4197. test -n "$future_libdirs" && \
  4198. func_warning "remember to run '$progname --finish$future_libdirs'"
  4199. if test -n "$current_libdirs"; then
  4200. # Maybe just do a dry run.
  4201. $opt_dry_run && current_libdirs=" -n$current_libdirs"
  4202. exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
  4203. else
  4204. exit $EXIT_SUCCESS
  4205. fi
  4206. }
  4207. test install = "$opt_mode" && func_mode_install ${1+"$@"}
  4208. # func_generate_dlsyms outputname originator pic_p
  4209. # Extract symbols from dlprefiles and create ${outputname}S.o with
  4210. # a dlpreopen symbol table.
  4211. func_generate_dlsyms ()
  4212. {
  4213. $debug_cmd
  4214. my_outputname=$1
  4215. my_originator=$2
  4216. my_pic_p=${3-false}
  4217. my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
  4218. my_dlsyms=
  4219. if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
  4220. if test -n "$NM" && test -n "$global_symbol_pipe"; then
  4221. my_dlsyms=${my_outputname}S.c
  4222. else
  4223. func_error "not configured to extract global symbols from dlpreopened files"
  4224. fi
  4225. fi
  4226. if test -n "$my_dlsyms"; then
  4227. case $my_dlsyms in
  4228. "") ;;
  4229. *.c)
  4230. # Discover the nlist of each of the dlfiles.
  4231. nlist=$output_objdir/$my_outputname.nm
  4232. func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
  4233. # Parse the name list into a source file.
  4234. func_verbose "creating $output_objdir/$my_dlsyms"
  4235. $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
  4236. /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
  4237. /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
  4238. #ifdef __cplusplus
  4239. extern \"C\" {
  4240. #endif
  4241. #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
  4242. #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
  4243. #endif
  4244. /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
  4245. #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
  4246. /* DATA imports from DLLs on WIN32 can't be const, because runtime
  4247. relocations are performed -- see ld's documentation on pseudo-relocs. */
  4248. # define LT_DLSYM_CONST
  4249. #elif defined __osf__
  4250. /* This system does not cope well with relocations in const data. */
  4251. # define LT_DLSYM_CONST
  4252. #else
  4253. # define LT_DLSYM_CONST const
  4254. #endif
  4255. #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
  4256. /* External symbol declarations for the compiler. */\
  4257. "
  4258. if test yes = "$dlself"; then
  4259. func_verbose "generating symbol list for '$output'"
  4260. $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
  4261. # Add our own program objects to the symbol list.
  4262. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
  4263. for progfile in $progfiles; do
  4264. func_to_tool_file "$progfile" func_convert_file_msys_to_w32
  4265. func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
  4266. $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
  4267. done
  4268. if test -n "$exclude_expsyms"; then
  4269. $opt_dry_run || {
  4270. eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
  4271. eval '$MV "$nlist"T "$nlist"'
  4272. }
  4273. fi
  4274. if test -n "$export_symbols_regex"; then
  4275. $opt_dry_run || {
  4276. eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
  4277. eval '$MV "$nlist"T "$nlist"'
  4278. }
  4279. fi
  4280. # Prepare the list of exported symbols
  4281. if test -z "$export_symbols"; then
  4282. export_symbols=$output_objdir/$outputname.exp
  4283. $opt_dry_run || {
  4284. $RM $export_symbols
  4285. eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
  4286. case $host in
  4287. *cygwin* | *mingw* | *cegcc* )
  4288. eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
  4289. eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
  4290. ;;
  4291. esac
  4292. }
  4293. else
  4294. $opt_dry_run || {
  4295. eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
  4296. eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
  4297. eval '$MV "$nlist"T "$nlist"'
  4298. case $host in
  4299. *cygwin* | *mingw* | *cegcc* )
  4300. eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
  4301. eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
  4302. ;;
  4303. esac
  4304. }
  4305. fi
  4306. fi
  4307. for dlprefile in $dlprefiles; do
  4308. func_verbose "extracting global C symbols from '$dlprefile'"
  4309. func_basename "$dlprefile"
  4310. name=$func_basename_result
  4311. case $host in
  4312. *cygwin* | *mingw* | *cegcc* )
  4313. # if an import library, we need to obtain dlname
  4314. if func_win32_import_lib_p "$dlprefile"; then
  4315. func_tr_sh "$dlprefile"
  4316. eval "curr_lafile=\$libfile_$func_tr_sh_result"
  4317. dlprefile_dlbasename=
  4318. if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
  4319. # Use subshell, to avoid clobbering current variable values
  4320. dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
  4321. if test -n "$dlprefile_dlname"; then
  4322. func_basename "$dlprefile_dlname"
  4323. dlprefile_dlbasename=$func_basename_result
  4324. else
  4325. # no lafile. user explicitly requested -dlpreopen <import library>.
  4326. $sharedlib_from_linklib_cmd "$dlprefile"
  4327. dlprefile_dlbasename=$sharedlib_from_linklib_result
  4328. fi
  4329. fi
  4330. $opt_dry_run || {
  4331. if test -n "$dlprefile_dlbasename"; then
  4332. eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
  4333. else
  4334. func_warning "Could not compute DLL name from $name"
  4335. eval '$ECHO ": $name " >> "$nlist"'
  4336. fi
  4337. func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  4338. eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
  4339. $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
  4340. }
  4341. else # not an import lib
  4342. $opt_dry_run || {
  4343. eval '$ECHO ": $name " >> "$nlist"'
  4344. func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  4345. eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
  4346. }
  4347. fi
  4348. ;;
  4349. *)
  4350. $opt_dry_run || {
  4351. eval '$ECHO ": $name " >> "$nlist"'
  4352. func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  4353. eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
  4354. }
  4355. ;;
  4356. esac
  4357. done
  4358. $opt_dry_run || {
  4359. # Make sure we have at least an empty file.
  4360. test -f "$nlist" || : > "$nlist"
  4361. if test -n "$exclude_expsyms"; then
  4362. $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
  4363. $MV "$nlist"T "$nlist"
  4364. fi
  4365. # Try sorting and uniquifying the output.
  4366. if $GREP -v "^: " < "$nlist" |
  4367. if sort -k 3 </dev/null >/dev/null 2>&1; then
  4368. sort -k 3
  4369. else
  4370. sort +2
  4371. fi |
  4372. uniq > "$nlist"S; then
  4373. :
  4374. else
  4375. $GREP -v "^: " < "$nlist" > "$nlist"S
  4376. fi
  4377. if test -f "$nlist"S; then
  4378. eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
  4379. else
  4380. echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
  4381. fi
  4382. func_show_eval '$RM "${nlist}I"'
  4383. if test -n "$global_symbol_to_import"; then
  4384. eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
  4385. fi
  4386. echo >> "$output_objdir/$my_dlsyms" "\
  4387. /* The mapping between symbol names and symbols. */
  4388. typedef struct {
  4389. const char *name;
  4390. void *address;
  4391. } lt_dlsymlist;
  4392. extern LT_DLSYM_CONST lt_dlsymlist
  4393. lt_${my_prefix}_LTX_preloaded_symbols[];\
  4394. "
  4395. if test -s "$nlist"I; then
  4396. echo >> "$output_objdir/$my_dlsyms" "\
  4397. static void lt_syminit(void)
  4398. {
  4399. LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
  4400. for (; symbol->name; ++symbol)
  4401. {"
  4402. $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
  4403. echo >> "$output_objdir/$my_dlsyms" "\
  4404. }
  4405. }"
  4406. fi
  4407. echo >> "$output_objdir/$my_dlsyms" "\
  4408. LT_DLSYM_CONST lt_dlsymlist
  4409. lt_${my_prefix}_LTX_preloaded_symbols[] =
  4410. { {\"$my_originator\", (void *) 0},"
  4411. if test -s "$nlist"I; then
  4412. echo >> "$output_objdir/$my_dlsyms" "\
  4413. {\"@INIT@\", (void *) &lt_syminit},"
  4414. fi
  4415. case $need_lib_prefix in
  4416. no)
  4417. eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
  4418. ;;
  4419. *)
  4420. eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
  4421. ;;
  4422. esac
  4423. echo >> "$output_objdir/$my_dlsyms" "\
  4424. {0, (void *) 0}
  4425. };
  4426. /* This works around a problem in FreeBSD linker */
  4427. #ifdef FREEBSD_WORKAROUND
  4428. static const void *lt_preloaded_setup() {
  4429. return lt_${my_prefix}_LTX_preloaded_symbols;
  4430. }
  4431. #endif
  4432. #ifdef __cplusplus
  4433. }
  4434. #endif\
  4435. "
  4436. } # !$opt_dry_run
  4437. pic_flag_for_symtable=
  4438. case "$compile_command " in
  4439. *" -static "*) ;;
  4440. *)
  4441. case $host in
  4442. # compiling the symbol table file with pic_flag works around
  4443. # a FreeBSD bug that causes programs to crash when -lm is
  4444. # linked before any other PIC object. But we must not use
  4445. # pic_flag when linking with -static. The problem exists in
  4446. # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
  4447. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
  4448. pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
  4449. *-*-hpux*)
  4450. pic_flag_for_symtable=" $pic_flag" ;;
  4451. *)
  4452. $my_pic_p && pic_flag_for_symtable=" $pic_flag"
  4453. ;;
  4454. esac
  4455. ;;
  4456. esac
  4457. symtab_cflags=
  4458. for arg in $LTCFLAGS; do
  4459. case $arg in
  4460. -pie | -fpie | -fPIE) ;;
  4461. *) func_append symtab_cflags " $arg" ;;
  4462. esac
  4463. done
  4464. # Now compile the dynamic symbol file.
  4465. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
  4466. # Clean up the generated files.
  4467. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
  4468. # Transform the symbol file into the correct name.
  4469. symfileobj=$output_objdir/${my_outputname}S.$objext
  4470. case $host in
  4471. *cygwin* | *mingw* | *cegcc* )
  4472. if test -f "$output_objdir/$my_outputname.def"; then
  4473. compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
  4474. finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
  4475. else
  4476. compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4477. finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4478. fi
  4479. ;;
  4480. *)
  4481. compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4482. finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4483. ;;
  4484. esac
  4485. ;;
  4486. *)
  4487. func_fatal_error "unknown suffix for '$my_dlsyms'"
  4488. ;;
  4489. esac
  4490. else
  4491. # We keep going just in case the user didn't refer to
  4492. # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
  4493. # really was required.
  4494. # Nullify the symbol file.
  4495. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
  4496. finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
  4497. fi
  4498. }
  4499. # func_cygming_gnu_implib_p ARG
  4500. # This predicate returns with zero status (TRUE) if
  4501. # ARG is a GNU/binutils-style import library. Returns
  4502. # with nonzero status (FALSE) otherwise.
  4503. func_cygming_gnu_implib_p ()
  4504. {
  4505. $debug_cmd
  4506. func_to_tool_file "$1" func_convert_file_msys_to_w32
  4507. func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
  4508. test -n "$func_cygming_gnu_implib_tmp"
  4509. }
  4510. # func_cygming_ms_implib_p ARG
  4511. # This predicate returns with zero status (TRUE) if
  4512. # ARG is an MS-style import library. Returns
  4513. # with nonzero status (FALSE) otherwise.
  4514. func_cygming_ms_implib_p ()
  4515. {
  4516. $debug_cmd
  4517. func_to_tool_file "$1" func_convert_file_msys_to_w32
  4518. func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
  4519. test -n "$func_cygming_ms_implib_tmp"
  4520. }
  4521. # func_win32_libid arg
  4522. # return the library type of file 'arg'
  4523. #
  4524. # Need a lot of goo to handle *both* DLLs and import libs
  4525. # Has to be a shell function in order to 'eat' the argument
  4526. # that is supplied when $file_magic_command is called.
  4527. # Despite the name, also deal with 64 bit binaries.
  4528. func_win32_libid ()
  4529. {
  4530. $debug_cmd
  4531. win32_libid_type=unknown
  4532. win32_fileres=`file -L $1 2>/dev/null`
  4533. case $win32_fileres in
  4534. *ar\ archive\ import\ library*) # definitely import
  4535. win32_libid_type="x86 archive import"
  4536. ;;
  4537. *ar\ archive*) # could be an import, or static
  4538. # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
  4539. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
  4540. $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
  4541. case $nm_interface in
  4542. "MS dumpbin")
  4543. if func_cygming_ms_implib_p "$1" ||
  4544. func_cygming_gnu_implib_p "$1"
  4545. then
  4546. win32_nmres=import
  4547. else
  4548. win32_nmres=
  4549. fi
  4550. ;;
  4551. *)
  4552. func_to_tool_file "$1" func_convert_file_msys_to_w32
  4553. win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
  4554. $SED -n -e '
  4555. 1,100{
  4556. / I /{
  4557. s|.*|import|
  4558. p
  4559. q
  4560. }
  4561. }'`
  4562. ;;
  4563. esac
  4564. case $win32_nmres in
  4565. import*) win32_libid_type="x86 archive import";;
  4566. *) win32_libid_type="x86 archive static";;
  4567. esac
  4568. fi
  4569. ;;
  4570. *DLL*)
  4571. win32_libid_type="x86 DLL"
  4572. ;;
  4573. *executable*) # but shell scripts are "executable" too...
  4574. case $win32_fileres in
  4575. *MS\ Windows\ PE\ Intel*)
  4576. win32_libid_type="x86 DLL"
  4577. ;;
  4578. esac
  4579. ;;
  4580. esac
  4581. $ECHO "$win32_libid_type"
  4582. }
  4583. # func_cygming_dll_for_implib ARG
  4584. #
  4585. # Platform-specific function to extract the
  4586. # name of the DLL associated with the specified
  4587. # import library ARG.
  4588. # Invoked by eval'ing the libtool variable
  4589. # $sharedlib_from_linklib_cmd
  4590. # Result is available in the variable
  4591. # $sharedlib_from_linklib_result
  4592. func_cygming_dll_for_implib ()
  4593. {
  4594. $debug_cmd
  4595. sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
  4596. }
  4597. # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
  4598. #
  4599. # The is the core of a fallback implementation of a
  4600. # platform-specific function to extract the name of the
  4601. # DLL associated with the specified import library LIBNAME.
  4602. #
  4603. # SECTION_NAME is either .idata$6 or .idata$7, depending
  4604. # on the platform and compiler that created the implib.
  4605. #
  4606. # Echos the name of the DLL associated with the
  4607. # specified import library.
  4608. func_cygming_dll_for_implib_fallback_core ()
  4609. {
  4610. $debug_cmd
  4611. match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
  4612. $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
  4613. $SED '/^Contents of section '"$match_literal"':/{
  4614. # Place marker at beginning of archive member dllname section
  4615. s/.*/====MARK====/
  4616. p
  4617. d
  4618. }
  4619. # These lines can sometimes be longer than 43 characters, but
  4620. # are always uninteresting
  4621. /:[ ]*file format pe[i]\{,1\}-/d
  4622. /^In archive [^:]*:/d
  4623. # Ensure marker is printed
  4624. /^====MARK====/p
  4625. # Remove all lines with less than 43 characters
  4626. /^.\{43\}/!d
  4627. # From remaining lines, remove first 43 characters
  4628. s/^.\{43\}//' |
  4629. $SED -n '
  4630. # Join marker and all lines until next marker into a single line
  4631. /^====MARK====/ b para
  4632. H
  4633. $ b para
  4634. b
  4635. :para
  4636. x
  4637. s/\n//g
  4638. # Remove the marker
  4639. s/^====MARK====//
  4640. # Remove trailing dots and whitespace
  4641. s/[\. \t]*$//
  4642. # Print
  4643. /./p' |
  4644. # we now have a list, one entry per line, of the stringified
  4645. # contents of the appropriate section of all members of the
  4646. # archive that possess that section. Heuristic: eliminate
  4647. # all those that have a first or second character that is
  4648. # a '.' (that is, objdump's representation of an unprintable
  4649. # character.) This should work for all archives with less than
  4650. # 0x302f exports -- but will fail for DLLs whose name actually
  4651. # begins with a literal '.' or a single character followed by
  4652. # a '.'.
  4653. #
  4654. # Of those that remain, print the first one.
  4655. $SED -e '/^\./d;/^.\./d;q'
  4656. }
  4657. # func_cygming_dll_for_implib_fallback ARG
  4658. # Platform-specific function to extract the
  4659. # name of the DLL associated with the specified
  4660. # import library ARG.
  4661. #
  4662. # This fallback implementation is for use when $DLLTOOL
  4663. # does not support the --identify-strict option.
  4664. # Invoked by eval'ing the libtool variable
  4665. # $sharedlib_from_linklib_cmd
  4666. # Result is available in the variable
  4667. # $sharedlib_from_linklib_result
  4668. func_cygming_dll_for_implib_fallback ()
  4669. {
  4670. $debug_cmd
  4671. if func_cygming_gnu_implib_p "$1"; then
  4672. # binutils import library
  4673. sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
  4674. elif func_cygming_ms_implib_p "$1"; then
  4675. # ms-generated import library
  4676. sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
  4677. else
  4678. # unknown
  4679. sharedlib_from_linklib_result=
  4680. fi
  4681. }
  4682. # func_extract_an_archive dir oldlib
  4683. func_extract_an_archive ()
  4684. {
  4685. $debug_cmd
  4686. f_ex_an_ar_dir=$1; shift
  4687. f_ex_an_ar_oldlib=$1
  4688. if test yes = "$lock_old_archive_extraction"; then
  4689. lockfile=$f_ex_an_ar_oldlib.lock
  4690. until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
  4691. func_echo "Waiting for $lockfile to be removed"
  4692. sleep 2
  4693. done
  4694. fi
  4695. func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
  4696. 'stat=$?; rm -f "$lockfile"; exit $stat'
  4697. if test yes = "$lock_old_archive_extraction"; then
  4698. $opt_dry_run || rm -f "$lockfile"
  4699. fi
  4700. if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
  4701. :
  4702. else
  4703. func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
  4704. fi
  4705. }
  4706. # func_extract_archives gentop oldlib ...
  4707. func_extract_archives ()
  4708. {
  4709. $debug_cmd
  4710. my_gentop=$1; shift
  4711. my_oldlibs=${1+"$@"}
  4712. my_oldobjs=
  4713. my_xlib=
  4714. my_xabs=
  4715. my_xdir=
  4716. for my_xlib in $my_oldlibs; do
  4717. # Extract the objects.
  4718. case $my_xlib in
  4719. [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
  4720. *) my_xabs=`pwd`"/$my_xlib" ;;
  4721. esac
  4722. func_basename "$my_xlib"
  4723. my_xlib=$func_basename_result
  4724. my_xlib_u=$my_xlib
  4725. while :; do
  4726. case " $extracted_archives " in
  4727. *" $my_xlib_u "*)
  4728. func_arith $extracted_serial + 1
  4729. extracted_serial=$func_arith_result
  4730. my_xlib_u=lt$extracted_serial-$my_xlib ;;
  4731. *) break ;;
  4732. esac
  4733. done
  4734. extracted_archives="$extracted_archives $my_xlib_u"
  4735. my_xdir=$my_gentop/$my_xlib_u
  4736. func_mkdir_p "$my_xdir"
  4737. case $host in
  4738. *-darwin*)
  4739. func_verbose "Extracting $my_xabs"
  4740. # Do not bother doing anything if just a dry run
  4741. $opt_dry_run || {
  4742. darwin_orig_dir=`pwd`
  4743. cd $my_xdir || exit $?
  4744. darwin_archive=$my_xabs
  4745. darwin_curdir=`pwd`
  4746. func_basename "$darwin_archive"
  4747. darwin_base_archive=$func_basename_result
  4748. darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
  4749. if test -n "$darwin_arches"; then
  4750. darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
  4751. darwin_arch=
  4752. func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
  4753. for darwin_arch in $darwin_arches; do
  4754. func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
  4755. $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
  4756. cd "unfat-$$/$darwin_base_archive-$darwin_arch"
  4757. func_extract_an_archive "`pwd`" "$darwin_base_archive"
  4758. cd "$darwin_curdir"
  4759. $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
  4760. done # $darwin_arches
  4761. ## Okay now we've a bunch of thin objects, gotta fatten them up :)
  4762. darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
  4763. darwin_file=
  4764. darwin_files=
  4765. for darwin_file in $darwin_filelist; do
  4766. darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
  4767. $LIPO -create -output "$darwin_file" $darwin_files
  4768. done # $darwin_filelist
  4769. $RM -rf unfat-$$
  4770. cd "$darwin_orig_dir"
  4771. else
  4772. cd $darwin_orig_dir
  4773. func_extract_an_archive "$my_xdir" "$my_xabs"
  4774. fi # $darwin_arches
  4775. } # !$opt_dry_run
  4776. ;;
  4777. *)
  4778. func_extract_an_archive "$my_xdir" "$my_xabs"
  4779. ;;
  4780. esac
  4781. my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
  4782. done
  4783. func_extract_archives_result=$my_oldobjs
  4784. }
  4785. # func_emit_wrapper [arg=no]
  4786. #
  4787. # Emit a libtool wrapper script on stdout.
  4788. # Don't directly open a file because we may want to
  4789. # incorporate the script contents within a cygwin/mingw
  4790. # wrapper executable. Must ONLY be called from within
  4791. # func_mode_link because it depends on a number of variables
  4792. # set therein.
  4793. #
  4794. # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
  4795. # variable will take. If 'yes', then the emitted script
  4796. # will assume that the directory where it is stored is
  4797. # the $objdir directory. This is a cygwin/mingw-specific
  4798. # behavior.
  4799. func_emit_wrapper ()
  4800. {
  4801. func_emit_wrapper_arg1=${1-no}
  4802. $ECHO "\
  4803. #! $SHELL
  4804. # $output - temporary wrapper script for $objdir/$outputname
  4805. # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  4806. #
  4807. # The $output program cannot be directly executed until all the libtool
  4808. # libraries that it depends on are installed.
  4809. #
  4810. # This wrapper script should never be moved out of the build directory.
  4811. # If it is, it will not operate correctly.
  4812. # Sed substitution that helps us do robust quoting. It backslashifies
  4813. # metacharacters that are still active within double-quoted strings.
  4814. sed_quote_subst='$sed_quote_subst'
  4815. # Be Bourne compatible
  4816. if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
  4817. emulate sh
  4818. NULLCMD=:
  4819. # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
  4820. # is contrary to our usage. Disable this feature.
  4821. alias -g '\${1+\"\$@\"}'='\"\$@\"'
  4822. setopt NO_GLOB_SUBST
  4823. else
  4824. case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
  4825. fi
  4826. BIN_SH=xpg4; export BIN_SH # for Tru64
  4827. DUALCASE=1; export DUALCASE # for MKS sh
  4828. # The HP-UX ksh and POSIX shell print the target directory to stdout
  4829. # if CDPATH is set.
  4830. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  4831. relink_command=\"$relink_command\"
  4832. # This environment variable determines our operation mode.
  4833. if test \"\$libtool_install_magic\" = \"$magic\"; then
  4834. # install mode needs the following variables:
  4835. generated_by_libtool_version='$macro_version'
  4836. notinst_deplibs='$notinst_deplibs'
  4837. else
  4838. # When we are sourced in execute mode, \$file and \$ECHO are already set.
  4839. if test \"\$libtool_execute_magic\" != \"$magic\"; then
  4840. file=\"\$0\""
  4841. qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
  4842. $ECHO "\
  4843. # A function that is used when there is no print builtin or printf.
  4844. func_fallback_echo ()
  4845. {
  4846. eval 'cat <<_LTECHO_EOF
  4847. \$1
  4848. _LTECHO_EOF'
  4849. }
  4850. ECHO=\"$qECHO\"
  4851. fi
  4852. # Very basic option parsing. These options are (a) specific to
  4853. # the libtool wrapper, (b) are identical between the wrapper
  4854. # /script/ and the wrapper /executable/ that is used only on
  4855. # windows platforms, and (c) all begin with the string "--lt-"
  4856. # (application programs are unlikely to have options that match
  4857. # this pattern).
  4858. #
  4859. # There are only two supported options: --lt-debug and
  4860. # --lt-dump-script. There is, deliberately, no --lt-help.
  4861. #
  4862. # The first argument to this parsing function should be the
  4863. # script's $0 value, followed by "$@".
  4864. lt_option_debug=
  4865. func_parse_lt_options ()
  4866. {
  4867. lt_script_arg0=\$0
  4868. shift
  4869. for lt_opt
  4870. do
  4871. case \"\$lt_opt\" in
  4872. --lt-debug) lt_option_debug=1 ;;
  4873. --lt-dump-script)
  4874. lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
  4875. test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
  4876. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
  4877. cat \"\$lt_dump_D/\$lt_dump_F\"
  4878. exit 0
  4879. ;;
  4880. --lt-*)
  4881. \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
  4882. exit 1
  4883. ;;
  4884. esac
  4885. done
  4886. # Print the debug banner immediately:
  4887. if test -n \"\$lt_option_debug\"; then
  4888. echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
  4889. fi
  4890. }
  4891. # Used when --lt-debug. Prints its arguments to stdout
  4892. # (redirection is the responsibility of the caller)
  4893. func_lt_dump_args ()
  4894. {
  4895. lt_dump_args_N=1;
  4896. for lt_arg
  4897. do
  4898. \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
  4899. lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
  4900. done
  4901. }
  4902. # Core function for launching the target application
  4903. func_exec_program_core ()
  4904. {
  4905. "
  4906. case $host in
  4907. # Backslashes separate directories on plain windows
  4908. *-*-mingw | *-*-os2* | *-cegcc*)
  4909. $ECHO "\
  4910. if test -n \"\$lt_option_debug\"; then
  4911. \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
  4912. func_lt_dump_args \${1+\"\$@\"} 1>&2
  4913. fi
  4914. exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
  4915. "
  4916. ;;
  4917. *)
  4918. $ECHO "\
  4919. if test -n \"\$lt_option_debug\"; then
  4920. \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
  4921. func_lt_dump_args \${1+\"\$@\"} 1>&2
  4922. fi
  4923. exec \"\$progdir/\$program\" \${1+\"\$@\"}
  4924. "
  4925. ;;
  4926. esac
  4927. $ECHO "\
  4928. \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
  4929. exit 1
  4930. }
  4931. # A function to encapsulate launching the target application
  4932. # Strips options in the --lt-* namespace from \$@ and
  4933. # launches target application with the remaining arguments.
  4934. func_exec_program ()
  4935. {
  4936. case \" \$* \" in
  4937. *\\ --lt-*)
  4938. for lt_wr_arg
  4939. do
  4940. case \$lt_wr_arg in
  4941. --lt-*) ;;
  4942. *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
  4943. esac
  4944. shift
  4945. done ;;
  4946. esac
  4947. func_exec_program_core \${1+\"\$@\"}
  4948. }
  4949. # Parse options
  4950. func_parse_lt_options \"\$0\" \${1+\"\$@\"}
  4951. # Find the directory that this script lives in.
  4952. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
  4953. test \"x\$thisdir\" = \"x\$file\" && thisdir=.
  4954. # Follow symbolic links until we get to the real thisdir.
  4955. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
  4956. while test -n \"\$file\"; do
  4957. destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
  4958. # If there was a directory component, then change thisdir.
  4959. if test \"x\$destdir\" != \"x\$file\"; then
  4960. case \"\$destdir\" in
  4961. [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
  4962. *) thisdir=\"\$thisdir/\$destdir\" ;;
  4963. esac
  4964. fi
  4965. file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
  4966. file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
  4967. done
  4968. # Usually 'no', except on cygwin/mingw when embedded into
  4969. # the cwrapper.
  4970. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
  4971. if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
  4972. # special case for '.'
  4973. if test \"\$thisdir\" = \".\"; then
  4974. thisdir=\`pwd\`
  4975. fi
  4976. # remove .libs from thisdir
  4977. case \"\$thisdir\" in
  4978. *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
  4979. $objdir ) thisdir=. ;;
  4980. esac
  4981. fi
  4982. # Try to get the absolute directory name.
  4983. absdir=\`cd \"\$thisdir\" && pwd\`
  4984. test -n \"\$absdir\" && thisdir=\"\$absdir\"
  4985. "
  4986. if test yes = "$fast_install"; then
  4987. $ECHO "\
  4988. program=lt-'$outputname'$exeext
  4989. progdir=\"\$thisdir/$objdir\"
  4990. if test ! -f \"\$progdir/\$program\" ||
  4991. { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
  4992. test \"X\$file\" != \"X\$progdir/\$program\"; }; then
  4993. file=\"\$\$-\$program\"
  4994. if test ! -d \"\$progdir\"; then
  4995. $MKDIR \"\$progdir\"
  4996. else
  4997. $RM \"\$progdir/\$file\"
  4998. fi"
  4999. $ECHO "\
  5000. # relink executable if necessary
  5001. if test -n \"\$relink_command\"; then
  5002. if relink_command_output=\`eval \$relink_command 2>&1\`; then :
  5003. else
  5004. \$ECHO \"\$relink_command_output\" >&2
  5005. $RM \"\$progdir/\$file\"
  5006. exit 1
  5007. fi
  5008. fi
  5009. $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
  5010. { $RM \"\$progdir/\$program\";
  5011. $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
  5012. $RM \"\$progdir/\$file\"
  5013. fi"
  5014. else
  5015. $ECHO "\
  5016. program='$outputname'
  5017. progdir=\"\$thisdir/$objdir\"
  5018. "
  5019. fi
  5020. $ECHO "\
  5021. if test -f \"\$progdir/\$program\"; then"
  5022. # fixup the dll searchpath if we need to.
  5023. #
  5024. # Fix the DLL searchpath if we need to. Do this before prepending
  5025. # to shlibpath, because on Windows, both are PATH and uninstalled
  5026. # libraries must come first.
  5027. if test -n "$dllsearchpath"; then
  5028. $ECHO "\
  5029. # Add the dll search path components to the executable PATH
  5030. PATH=$dllsearchpath:\$PATH
  5031. "
  5032. fi
  5033. # Export our shlibpath_var if we have one.
  5034. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
  5035. $ECHO "\
  5036. # Add our own library path to $shlibpath_var
  5037. $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
  5038. # Some systems cannot cope with colon-terminated $shlibpath_var
  5039. # The second colon is a workaround for a bug in BeOS R4 sed
  5040. $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
  5041. export $shlibpath_var
  5042. "
  5043. fi
  5044. $ECHO "\
  5045. if test \"\$libtool_execute_magic\" != \"$magic\"; then
  5046. # Run the actual program with our arguments.
  5047. func_exec_program \${1+\"\$@\"}
  5048. fi
  5049. else
  5050. # The program doesn't exist.
  5051. \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
  5052. \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
  5053. \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
  5054. exit 1
  5055. fi
  5056. fi\
  5057. "
  5058. }
  5059. # func_emit_cwrapperexe_src
  5060. # emit the source code for a wrapper executable on stdout
  5061. # Must ONLY be called from within func_mode_link because
  5062. # it depends on a number of variable set therein.
  5063. func_emit_cwrapperexe_src ()
  5064. {
  5065. cat <<EOF
  5066. /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
  5067. Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  5068. The $output program cannot be directly executed until all the libtool
  5069. libraries that it depends on are installed.
  5070. This wrapper executable should never be moved out of the build directory.
  5071. If it is, it will not operate correctly.
  5072. */
  5073. EOF
  5074. cat <<"EOF"
  5075. #ifdef _MSC_VER
  5076. # define _CRT_SECURE_NO_DEPRECATE 1
  5077. #endif
  5078. #include <stdio.h>
  5079. #include <stdlib.h>
  5080. #ifdef _MSC_VER
  5081. # include <direct.h>
  5082. # include <process.h>
  5083. # include <io.h>
  5084. #else
  5085. # include <unistd.h>
  5086. # include <stdint.h>
  5087. # ifdef __CYGWIN__
  5088. # include <io.h>
  5089. # endif
  5090. #endif
  5091. #include <malloc.h>
  5092. #include <stdarg.h>
  5093. #include <assert.h>
  5094. #include <string.h>
  5095. #include <ctype.h>
  5096. #include <errno.h>
  5097. #include <fcntl.h>
  5098. #include <sys/stat.h>
  5099. #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
  5100. /* declarations of non-ANSI functions */
  5101. #if defined __MINGW32__
  5102. # ifdef __STRICT_ANSI__
  5103. int _putenv (const char *);
  5104. # endif
  5105. #elif defined __CYGWIN__
  5106. # ifdef __STRICT_ANSI__
  5107. char *realpath (const char *, char *);
  5108. int putenv (char *);
  5109. int setenv (const char *, const char *, int);
  5110. # endif
  5111. /* #elif defined other_platform || defined ... */
  5112. #endif
  5113. /* portability defines, excluding path handling macros */
  5114. #if defined _MSC_VER
  5115. # define setmode _setmode
  5116. # define stat _stat
  5117. # define chmod _chmod
  5118. # define getcwd _getcwd
  5119. # define putenv _putenv
  5120. # define S_IXUSR _S_IEXEC
  5121. #elif defined __MINGW32__
  5122. # define setmode _setmode
  5123. # define stat _stat
  5124. # define chmod _chmod
  5125. # define getcwd _getcwd
  5126. # define putenv _putenv
  5127. #elif defined __CYGWIN__
  5128. # define HAVE_SETENV
  5129. # define FOPEN_WB "wb"
  5130. /* #elif defined other platforms ... */
  5131. #endif
  5132. #if defined PATH_MAX
  5133. # define LT_PATHMAX PATH_MAX
  5134. #elif defined MAXPATHLEN
  5135. # define LT_PATHMAX MAXPATHLEN
  5136. #else
  5137. # define LT_PATHMAX 1024
  5138. #endif
  5139. #ifndef S_IXOTH
  5140. # define S_IXOTH 0
  5141. #endif
  5142. #ifndef S_IXGRP
  5143. # define S_IXGRP 0
  5144. #endif
  5145. /* path handling portability macros */
  5146. #ifndef DIR_SEPARATOR
  5147. # define DIR_SEPARATOR '/'
  5148. # define PATH_SEPARATOR ':'
  5149. #endif
  5150. #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
  5151. defined __OS2__
  5152. # define HAVE_DOS_BASED_FILE_SYSTEM
  5153. # define FOPEN_WB "wb"
  5154. # ifndef DIR_SEPARATOR_2
  5155. # define DIR_SEPARATOR_2 '\\'
  5156. # endif
  5157. # ifndef PATH_SEPARATOR_2
  5158. # define PATH_SEPARATOR_2 ';'
  5159. # endif
  5160. #endif
  5161. #ifndef DIR_SEPARATOR_2
  5162. # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
  5163. #else /* DIR_SEPARATOR_2 */
  5164. # define IS_DIR_SEPARATOR(ch) \
  5165. (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
  5166. #endif /* DIR_SEPARATOR_2 */
  5167. #ifndef PATH_SEPARATOR_2
  5168. # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
  5169. #else /* PATH_SEPARATOR_2 */
  5170. # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
  5171. #endif /* PATH_SEPARATOR_2 */
  5172. #ifndef FOPEN_WB
  5173. # define FOPEN_WB "w"
  5174. #endif
  5175. #ifndef _O_BINARY
  5176. # define _O_BINARY 0
  5177. #endif
  5178. #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
  5179. #define XFREE(stale) do { \
  5180. if (stale) { free (stale); stale = 0; } \
  5181. } while (0)
  5182. #if defined LT_DEBUGWRAPPER
  5183. static int lt_debug = 1;
  5184. #else
  5185. static int lt_debug = 0;
  5186. #endif
  5187. const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
  5188. void *xmalloc (size_t num);
  5189. char *xstrdup (const char *string);
  5190. const char *base_name (const char *name);
  5191. char *find_executable (const char *wrapper);
  5192. char *chase_symlinks (const char *pathspec);
  5193. int make_executable (const char *path);
  5194. int check_executable (const char *path);
  5195. char *strendzap (char *str, const char *pat);
  5196. void lt_debugprintf (const char *file, int line, const char *fmt, ...);
  5197. void lt_fatal (const char *file, int line, const char *message, ...);
  5198. static const char *nonnull (const char *s);
  5199. static const char *nonempty (const char *s);
  5200. void lt_setenv (const char *name, const char *value);
  5201. char *lt_extend_str (const char *orig_value, const char *add, int to_end);
  5202. void lt_update_exe_path (const char *name, const char *value);
  5203. void lt_update_lib_path (const char *name, const char *value);
  5204. char **prepare_spawn (char **argv);
  5205. void lt_dump_script (FILE *f);
  5206. EOF
  5207. cat <<EOF
  5208. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
  5209. # define externally_visible volatile
  5210. #else
  5211. # define externally_visible __attribute__((externally_visible)) volatile
  5212. #endif
  5213. externally_visible const char * MAGIC_EXE = "$magic_exe";
  5214. const char * LIB_PATH_VARNAME = "$shlibpath_var";
  5215. EOF
  5216. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
  5217. func_to_host_path "$temp_rpath"
  5218. cat <<EOF
  5219. const char * LIB_PATH_VALUE = "$func_to_host_path_result";
  5220. EOF
  5221. else
  5222. cat <<"EOF"
  5223. const char * LIB_PATH_VALUE = "";
  5224. EOF
  5225. fi
  5226. if test -n "$dllsearchpath"; then
  5227. func_to_host_path "$dllsearchpath:"
  5228. cat <<EOF
  5229. const char * EXE_PATH_VARNAME = "PATH";
  5230. const char * EXE_PATH_VALUE = "$func_to_host_path_result";
  5231. EOF
  5232. else
  5233. cat <<"EOF"
  5234. const char * EXE_PATH_VARNAME = "";
  5235. const char * EXE_PATH_VALUE = "";
  5236. EOF
  5237. fi
  5238. if test yes = "$fast_install"; then
  5239. cat <<EOF
  5240. const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
  5241. EOF
  5242. else
  5243. cat <<EOF
  5244. const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
  5245. EOF
  5246. fi
  5247. cat <<"EOF"
  5248. #define LTWRAPPER_OPTION_PREFIX "--lt-"
  5249. static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
  5250. static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
  5251. static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
  5252. int
  5253. main (int argc, char *argv[])
  5254. {
  5255. char **newargz;
  5256. int newargc;
  5257. char *tmp_pathspec;
  5258. char *actual_cwrapper_path;
  5259. char *actual_cwrapper_name;
  5260. char *target_name;
  5261. char *lt_argv_zero;
  5262. int rval = 127;
  5263. int i;
  5264. program_name = (char *) xstrdup (base_name (argv[0]));
  5265. newargz = XMALLOC (char *, (size_t) argc + 1);
  5266. /* very simple arg parsing; don't want to rely on getopt
  5267. * also, copy all non cwrapper options to newargz, except
  5268. * argz[0], which is handled differently
  5269. */
  5270. newargc=0;
  5271. for (i = 1; i < argc; i++)
  5272. {
  5273. if (STREQ (argv[i], dumpscript_opt))
  5274. {
  5275. EOF
  5276. case $host in
  5277. *mingw* | *cygwin* )
  5278. # make stdout use "unix" line endings
  5279. echo " setmode(1,_O_BINARY);"
  5280. ;;
  5281. esac
  5282. cat <<"EOF"
  5283. lt_dump_script (stdout);
  5284. return 0;
  5285. }
  5286. if (STREQ (argv[i], debug_opt))
  5287. {
  5288. lt_debug = 1;
  5289. continue;
  5290. }
  5291. if (STREQ (argv[i], ltwrapper_option_prefix))
  5292. {
  5293. /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
  5294. namespace, but it is not one of the ones we know about and
  5295. have already dealt with, above (inluding dump-script), then
  5296. report an error. Otherwise, targets might begin to believe
  5297. they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
  5298. namespace. The first time any user complains about this, we'll
  5299. need to make LTWRAPPER_OPTION_PREFIX a configure-time option
  5300. or a configure.ac-settable value.
  5301. */
  5302. lt_fatal (__FILE__, __LINE__,
  5303. "unrecognized %s option: '%s'",
  5304. ltwrapper_option_prefix, argv[i]);
  5305. }
  5306. /* otherwise ... */
  5307. newargz[++newargc] = xstrdup (argv[i]);
  5308. }
  5309. newargz[++newargc] = NULL;
  5310. EOF
  5311. cat <<EOF
  5312. /* The GNU banner must be the first non-error debug message */
  5313. lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
  5314. EOF
  5315. cat <<"EOF"
  5316. lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
  5317. lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
  5318. tmp_pathspec = find_executable (argv[0]);
  5319. if (tmp_pathspec == NULL)
  5320. lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
  5321. lt_debugprintf (__FILE__, __LINE__,
  5322. "(main) found exe (before symlink chase) at: %s\n",
  5323. tmp_pathspec);
  5324. actual_cwrapper_path = chase_symlinks (tmp_pathspec);
  5325. lt_debugprintf (__FILE__, __LINE__,
  5326. "(main) found exe (after symlink chase) at: %s\n",
  5327. actual_cwrapper_path);
  5328. XFREE (tmp_pathspec);
  5329. actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
  5330. strendzap (actual_cwrapper_path, actual_cwrapper_name);
  5331. /* wrapper name transforms */
  5332. strendzap (actual_cwrapper_name, ".exe");
  5333. tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
  5334. XFREE (actual_cwrapper_name);
  5335. actual_cwrapper_name = tmp_pathspec;
  5336. tmp_pathspec = 0;
  5337. /* target_name transforms -- use actual target program name; might have lt- prefix */
  5338. target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
  5339. strendzap (target_name, ".exe");
  5340. tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
  5341. XFREE (target_name);
  5342. target_name = tmp_pathspec;
  5343. tmp_pathspec = 0;
  5344. lt_debugprintf (__FILE__, __LINE__,
  5345. "(main) libtool target name: %s\n",
  5346. target_name);
  5347. EOF
  5348. cat <<EOF
  5349. newargz[0] =
  5350. XMALLOC (char, (strlen (actual_cwrapper_path) +
  5351. strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
  5352. strcpy (newargz[0], actual_cwrapper_path);
  5353. strcat (newargz[0], "$objdir");
  5354. strcat (newargz[0], "/");
  5355. EOF
  5356. cat <<"EOF"
  5357. /* stop here, and copy so we don't have to do this twice */
  5358. tmp_pathspec = xstrdup (newargz[0]);
  5359. /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
  5360. strcat (newargz[0], actual_cwrapper_name);
  5361. /* DO want the lt- prefix here if it exists, so use target_name */
  5362. lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
  5363. XFREE (tmp_pathspec);
  5364. tmp_pathspec = NULL;
  5365. EOF
  5366. case $host_os in
  5367. mingw*)
  5368. cat <<"EOF"
  5369. {
  5370. char* p;
  5371. while ((p = strchr (newargz[0], '\\')) != NULL)
  5372. {
  5373. *p = '/';
  5374. }
  5375. while ((p = strchr (lt_argv_zero, '\\')) != NULL)
  5376. {
  5377. *p = '/';
  5378. }
  5379. }
  5380. EOF
  5381. ;;
  5382. esac
  5383. cat <<"EOF"
  5384. XFREE (target_name);
  5385. XFREE (actual_cwrapper_path);
  5386. XFREE (actual_cwrapper_name);
  5387. lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
  5388. lt_setenv ("DUALCASE", "1"); /* for MSK sh */
  5389. /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
  5390. be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
  5391. because on Windows, both *_VARNAMEs are PATH but uninstalled
  5392. libraries must come first. */
  5393. lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
  5394. lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
  5395. lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
  5396. nonnull (lt_argv_zero));
  5397. for (i = 0; i < newargc; i++)
  5398. {
  5399. lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
  5400. i, nonnull (newargz[i]));
  5401. }
  5402. EOF
  5403. case $host_os in
  5404. mingw*)
  5405. cat <<"EOF"
  5406. /* execv doesn't actually work on mingw as expected on unix */
  5407. newargz = prepare_spawn (newargz);
  5408. rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
  5409. if (rval == -1)
  5410. {
  5411. /* failed to start process */
  5412. lt_debugprintf (__FILE__, __LINE__,
  5413. "(main) failed to launch target \"%s\": %s\n",
  5414. lt_argv_zero, nonnull (strerror (errno)));
  5415. return 127;
  5416. }
  5417. return rval;
  5418. EOF
  5419. ;;
  5420. *)
  5421. cat <<"EOF"
  5422. execv (lt_argv_zero, newargz);
  5423. return rval; /* =127, but avoids unused variable warning */
  5424. EOF
  5425. ;;
  5426. esac
  5427. cat <<"EOF"
  5428. }
  5429. void *
  5430. xmalloc (size_t num)
  5431. {
  5432. void *p = (void *) malloc (num);
  5433. if (!p)
  5434. lt_fatal (__FILE__, __LINE__, "memory exhausted");
  5435. return p;
  5436. }
  5437. char *
  5438. xstrdup (const char *string)
  5439. {
  5440. return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
  5441. string) : NULL;
  5442. }
  5443. const char *
  5444. base_name (const char *name)
  5445. {
  5446. const char *base;
  5447. #if defined HAVE_DOS_BASED_FILE_SYSTEM
  5448. /* Skip over the disk name in MSDOS pathnames. */
  5449. if (isalpha ((unsigned char) name[0]) && name[1] == ':')
  5450. name += 2;
  5451. #endif
  5452. for (base = name; *name; name++)
  5453. if (IS_DIR_SEPARATOR (*name))
  5454. base = name + 1;
  5455. return base;
  5456. }
  5457. int
  5458. check_executable (const char *path)
  5459. {
  5460. struct stat st;
  5461. lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
  5462. nonempty (path));
  5463. if ((!path) || (!*path))
  5464. return 0;
  5465. if ((stat (path, &st) >= 0)
  5466. && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
  5467. return 1;
  5468. else
  5469. return 0;
  5470. }
  5471. int
  5472. make_executable (const char *path)
  5473. {
  5474. int rval = 0;
  5475. struct stat st;
  5476. lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
  5477. nonempty (path));
  5478. if ((!path) || (!*path))
  5479. return 0;
  5480. if (stat (path, &st) >= 0)
  5481. {
  5482. rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
  5483. }
  5484. return rval;
  5485. }
  5486. /* Searches for the full path of the wrapper. Returns
  5487. newly allocated full path name if found, NULL otherwise
  5488. Does not chase symlinks, even on platforms that support them.
  5489. */
  5490. char *
  5491. find_executable (const char *wrapper)
  5492. {
  5493. int has_slash = 0;
  5494. const char *p;
  5495. const char *p_next;
  5496. /* static buffer for getcwd */
  5497. char tmp[LT_PATHMAX + 1];
  5498. size_t tmp_len;
  5499. char *concat_name;
  5500. lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
  5501. nonempty (wrapper));
  5502. if ((wrapper == NULL) || (*wrapper == '\0'))
  5503. return NULL;
  5504. /* Absolute path? */
  5505. #if defined HAVE_DOS_BASED_FILE_SYSTEM
  5506. if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
  5507. {
  5508. concat_name = xstrdup (wrapper);
  5509. if (check_executable (concat_name))
  5510. return concat_name;
  5511. XFREE (concat_name);
  5512. }
  5513. else
  5514. {
  5515. #endif
  5516. if (IS_DIR_SEPARATOR (wrapper[0]))
  5517. {
  5518. concat_name = xstrdup (wrapper);
  5519. if (check_executable (concat_name))
  5520. return concat_name;
  5521. XFREE (concat_name);
  5522. }
  5523. #if defined HAVE_DOS_BASED_FILE_SYSTEM
  5524. }
  5525. #endif
  5526. for (p = wrapper; *p; p++)
  5527. if (*p == '/')
  5528. {
  5529. has_slash = 1;
  5530. break;
  5531. }
  5532. if (!has_slash)
  5533. {
  5534. /* no slashes; search PATH */
  5535. const char *path = getenv ("PATH");
  5536. if (path != NULL)
  5537. {
  5538. for (p = path; *p; p = p_next)
  5539. {
  5540. const char *q;
  5541. size_t p_len;
  5542. for (q = p; *q; q++)
  5543. if (IS_PATH_SEPARATOR (*q))
  5544. break;
  5545. p_len = (size_t) (q - p);
  5546. p_next = (*q == '\0' ? q : q + 1);
  5547. if (p_len == 0)
  5548. {
  5549. /* empty path: current directory */
  5550. if (getcwd (tmp, LT_PATHMAX) == NULL)
  5551. lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
  5552. nonnull (strerror (errno)));
  5553. tmp_len = strlen (tmp);
  5554. concat_name =
  5555. XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
  5556. memcpy (concat_name, tmp, tmp_len);
  5557. concat_name[tmp_len] = '/';
  5558. strcpy (concat_name + tmp_len + 1, wrapper);
  5559. }
  5560. else
  5561. {
  5562. concat_name =
  5563. XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
  5564. memcpy (concat_name, p, p_len);
  5565. concat_name[p_len] = '/';
  5566. strcpy (concat_name + p_len + 1, wrapper);
  5567. }
  5568. if (check_executable (concat_name))
  5569. return concat_name;
  5570. XFREE (concat_name);
  5571. }
  5572. }
  5573. /* not found in PATH; assume curdir */
  5574. }
  5575. /* Relative path | not found in path: prepend cwd */
  5576. if (getcwd (tmp, LT_PATHMAX) == NULL)
  5577. lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
  5578. nonnull (strerror (errno)));
  5579. tmp_len = strlen (tmp);
  5580. concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
  5581. memcpy (concat_name, tmp, tmp_len);
  5582. concat_name[tmp_len] = '/';
  5583. strcpy (concat_name + tmp_len + 1, wrapper);
  5584. if (check_executable (concat_name))
  5585. return concat_name;
  5586. XFREE (concat_name);
  5587. return NULL;
  5588. }
  5589. char *
  5590. chase_symlinks (const char *pathspec)
  5591. {
  5592. #ifndef S_ISLNK
  5593. return xstrdup (pathspec);
  5594. #else
  5595. char buf[LT_PATHMAX];
  5596. struct stat s;
  5597. char *tmp_pathspec = xstrdup (pathspec);
  5598. char *p;
  5599. int has_symlinks = 0;
  5600. while (strlen (tmp_pathspec) && !has_symlinks)
  5601. {
  5602. lt_debugprintf (__FILE__, __LINE__,
  5603. "checking path component for symlinks: %s\n",
  5604. tmp_pathspec);
  5605. if (lstat (tmp_pathspec, &s) == 0)
  5606. {
  5607. if (S_ISLNK (s.st_mode) != 0)
  5608. {
  5609. has_symlinks = 1;
  5610. break;
  5611. }
  5612. /* search backwards for last DIR_SEPARATOR */
  5613. p = tmp_pathspec + strlen (tmp_pathspec) - 1;
  5614. while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
  5615. p--;
  5616. if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
  5617. {
  5618. /* no more DIR_SEPARATORS left */
  5619. break;
  5620. }
  5621. *p = '\0';
  5622. }
  5623. else
  5624. {
  5625. lt_fatal (__FILE__, __LINE__,
  5626. "error accessing file \"%s\": %s",
  5627. tmp_pathspec, nonnull (strerror (errno)));
  5628. }
  5629. }
  5630. XFREE (tmp_pathspec);
  5631. if (!has_symlinks)
  5632. {
  5633. return xstrdup (pathspec);
  5634. }
  5635. tmp_pathspec = realpath (pathspec, buf);
  5636. if (tmp_pathspec == 0)
  5637. {
  5638. lt_fatal (__FILE__, __LINE__,
  5639. "could not follow symlinks for %s", pathspec);
  5640. }
  5641. return xstrdup (tmp_pathspec);
  5642. #endif
  5643. }
  5644. char *
  5645. strendzap (char *str, const char *pat)
  5646. {
  5647. size_t len, patlen;
  5648. assert (str != NULL);
  5649. assert (pat != NULL);
  5650. len = strlen (str);
  5651. patlen = strlen (pat);
  5652. if (patlen <= len)
  5653. {
  5654. str += len - patlen;
  5655. if (STREQ (str, pat))
  5656. *str = '\0';
  5657. }
  5658. return str;
  5659. }
  5660. void
  5661. lt_debugprintf (const char *file, int line, const char *fmt, ...)
  5662. {
  5663. va_list args;
  5664. if (lt_debug)
  5665. {
  5666. (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
  5667. va_start (args, fmt);
  5668. (void) vfprintf (stderr, fmt, args);
  5669. va_end (args);
  5670. }
  5671. }
  5672. static void
  5673. lt_error_core (int exit_status, const char *file,
  5674. int line, const char *mode,
  5675. const char *message, va_list ap)
  5676. {
  5677. fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
  5678. vfprintf (stderr, message, ap);
  5679. fprintf (stderr, ".\n");
  5680. if (exit_status >= 0)
  5681. exit (exit_status);
  5682. }
  5683. void
  5684. lt_fatal (const char *file, int line, const char *message, ...)
  5685. {
  5686. va_list ap;
  5687. va_start (ap, message);
  5688. lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
  5689. va_end (ap);
  5690. }
  5691. static const char *
  5692. nonnull (const char *s)
  5693. {
  5694. return s ? s : "(null)";
  5695. }
  5696. static const char *
  5697. nonempty (const char *s)
  5698. {
  5699. return (s && !*s) ? "(empty)" : nonnull (s);
  5700. }
  5701. void
  5702. lt_setenv (const char *name, const char *value)
  5703. {
  5704. lt_debugprintf (__FILE__, __LINE__,
  5705. "(lt_setenv) setting '%s' to '%s'\n",
  5706. nonnull (name), nonnull (value));
  5707. {
  5708. #ifdef HAVE_SETENV
  5709. /* always make a copy, for consistency with !HAVE_SETENV */
  5710. char *str = xstrdup (value);
  5711. setenv (name, str, 1);
  5712. #else
  5713. size_t len = strlen (name) + 1 + strlen (value) + 1;
  5714. char *str = XMALLOC (char, len);
  5715. sprintf (str, "%s=%s", name, value);
  5716. if (putenv (str) != EXIT_SUCCESS)
  5717. {
  5718. XFREE (str);
  5719. }
  5720. #endif
  5721. }
  5722. }
  5723. char *
  5724. lt_extend_str (const char *orig_value, const char *add, int to_end)
  5725. {
  5726. char *new_value;
  5727. if (orig_value && *orig_value)
  5728. {
  5729. size_t orig_value_len = strlen (orig_value);
  5730. size_t add_len = strlen (add);
  5731. new_value = XMALLOC (char, add_len + orig_value_len + 1);
  5732. if (to_end)
  5733. {
  5734. strcpy (new_value, orig_value);
  5735. strcpy (new_value + orig_value_len, add);
  5736. }
  5737. else
  5738. {
  5739. strcpy (new_value, add);
  5740. strcpy (new_value + add_len, orig_value);
  5741. }
  5742. }
  5743. else
  5744. {
  5745. new_value = xstrdup (add);
  5746. }
  5747. return new_value;
  5748. }
  5749. void
  5750. lt_update_exe_path (const char *name, const char *value)
  5751. {
  5752. lt_debugprintf (__FILE__, __LINE__,
  5753. "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
  5754. nonnull (name), nonnull (value));
  5755. if (name && *name && value && *value)
  5756. {
  5757. char *new_value = lt_extend_str (getenv (name), value, 0);
  5758. /* some systems can't cope with a ':'-terminated path #' */
  5759. size_t len = strlen (new_value);
  5760. while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
  5761. {
  5762. new_value[--len] = '\0';
  5763. }
  5764. lt_setenv (name, new_value);
  5765. XFREE (new_value);
  5766. }
  5767. }
  5768. void
  5769. lt_update_lib_path (const char *name, const char *value)
  5770. {
  5771. lt_debugprintf (__FILE__, __LINE__,
  5772. "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
  5773. nonnull (name), nonnull (value));
  5774. if (name && *name && value && *value)
  5775. {
  5776. char *new_value = lt_extend_str (getenv (name), value, 0);
  5777. lt_setenv (name, new_value);
  5778. XFREE (new_value);
  5779. }
  5780. }
  5781. EOF
  5782. case $host_os in
  5783. mingw*)
  5784. cat <<"EOF"
  5785. /* Prepares an argument vector before calling spawn().
  5786. Note that spawn() does not by itself call the command interpreter
  5787. (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
  5788. ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  5789. GetVersionEx(&v);
  5790. v.dwPlatformId == VER_PLATFORM_WIN32_NT;
  5791. }) ? "cmd.exe" : "command.com").
  5792. Instead it simply concatenates the arguments, separated by ' ', and calls
  5793. CreateProcess(). We must quote the arguments since Win32 CreateProcess()
  5794. interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
  5795. special way:
  5796. - Space and tab are interpreted as delimiters. They are not treated as
  5797. delimiters if they are surrounded by double quotes: "...".
  5798. - Unescaped double quotes are removed from the input. Their only effect is
  5799. that within double quotes, space and tab are treated like normal
  5800. characters.
  5801. - Backslashes not followed by double quotes are not special.
  5802. - But 2*n+1 backslashes followed by a double quote become
  5803. n backslashes followed by a double quote (n >= 0):
  5804. \" -> "
  5805. \\\" -> \"
  5806. \\\\\" -> \\"
  5807. */
  5808. #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
  5809. #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
  5810. char **
  5811. prepare_spawn (char **argv)
  5812. {
  5813. size_t argc;
  5814. char **new_argv;
  5815. size_t i;
  5816. /* Count number of arguments. */
  5817. for (argc = 0; argv[argc] != NULL; argc++)
  5818. ;
  5819. /* Allocate new argument vector. */
  5820. new_argv = XMALLOC (char *, argc + 1);
  5821. /* Put quoted arguments into the new argument vector. */
  5822. for (i = 0; i < argc; i++)
  5823. {
  5824. const char *string = argv[i];
  5825. if (string[0] == '\0')
  5826. new_argv[i] = xstrdup ("\"\"");
  5827. else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
  5828. {
  5829. int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
  5830. size_t length;
  5831. unsigned int backslashes;
  5832. const char *s;
  5833. char *quoted_string;
  5834. char *p;
  5835. length = 0;
  5836. backslashes = 0;
  5837. if (quote_around)
  5838. length++;
  5839. for (s = string; *s != '\0'; s++)
  5840. {
  5841. char c = *s;
  5842. if (c == '"')
  5843. length += backslashes + 1;
  5844. length++;
  5845. if (c == '\\')
  5846. backslashes++;
  5847. else
  5848. backslashes = 0;
  5849. }
  5850. if (quote_around)
  5851. length += backslashes + 1;
  5852. quoted_string = XMALLOC (char, length + 1);
  5853. p = quoted_string;
  5854. backslashes = 0;
  5855. if (quote_around)
  5856. *p++ = '"';
  5857. for (s = string; *s != '\0'; s++)
  5858. {
  5859. char c = *s;
  5860. if (c == '"')
  5861. {
  5862. unsigned int j;
  5863. for (j = backslashes + 1; j > 0; j--)
  5864. *p++ = '\\';
  5865. }
  5866. *p++ = c;
  5867. if (c == '\\')
  5868. backslashes++;
  5869. else
  5870. backslashes = 0;
  5871. }
  5872. if (quote_around)
  5873. {
  5874. unsigned int j;
  5875. for (j = backslashes; j > 0; j--)
  5876. *p++ = '\\';
  5877. *p++ = '"';
  5878. }
  5879. *p = '\0';
  5880. new_argv[i] = quoted_string;
  5881. }
  5882. else
  5883. new_argv[i] = (char *) string;
  5884. }
  5885. new_argv[argc] = NULL;
  5886. return new_argv;
  5887. }
  5888. EOF
  5889. ;;
  5890. esac
  5891. cat <<"EOF"
  5892. void lt_dump_script (FILE* f)
  5893. {
  5894. EOF
  5895. func_emit_wrapper yes |
  5896. $SED -n -e '
  5897. s/^\(.\{79\}\)\(..*\)/\1\
  5898. \2/
  5899. h
  5900. s/\([\\"]\)/\\\1/g
  5901. s/$/\\n/
  5902. s/\([^\n]*\).*/ fputs ("\1", f);/p
  5903. g
  5904. D'
  5905. cat <<"EOF"
  5906. }
  5907. EOF
  5908. }
  5909. # end: func_emit_cwrapperexe_src
  5910. # func_win32_import_lib_p ARG
  5911. # True if ARG is an import lib, as indicated by $file_magic_cmd
  5912. func_win32_import_lib_p ()
  5913. {
  5914. $debug_cmd
  5915. case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
  5916. *import*) : ;;
  5917. *) false ;;
  5918. esac
  5919. }
  5920. # func_suncc_cstd_abi
  5921. # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
  5922. # Several compiler flags select an ABI that is incompatible with the
  5923. # Cstd library. Avoid specifying it if any are in CXXFLAGS.
  5924. func_suncc_cstd_abi ()
  5925. {
  5926. $debug_cmd
  5927. case " $compile_command " in
  5928. *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
  5929. suncc_use_cstd_abi=no
  5930. ;;
  5931. *)
  5932. suncc_use_cstd_abi=yes
  5933. ;;
  5934. esac
  5935. }
  5936. # func_mode_link arg...
  5937. func_mode_link ()
  5938. {
  5939. $debug_cmd
  5940. case $host in
  5941. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
  5942. # It is impossible to link a dll without this setting, and
  5943. # we shouldn't force the makefile maintainer to figure out
  5944. # what system we are compiling for in order to pass an extra
  5945. # flag for every libtool invocation.
  5946. # allow_undefined=no
  5947. # FIXME: Unfortunately, there are problems with the above when trying
  5948. # to make a dll that has undefined symbols, in which case not
  5949. # even a static library is built. For now, we need to specify
  5950. # -no-undefined on the libtool link line when we can be certain
  5951. # that all symbols are satisfied, otherwise we get a static library.
  5952. allow_undefined=yes
  5953. ;;
  5954. *)
  5955. allow_undefined=yes
  5956. ;;
  5957. esac
  5958. libtool_args=$nonopt
  5959. base_compile="$nonopt $@"
  5960. compile_command=$nonopt
  5961. finalize_command=$nonopt
  5962. compile_rpath=
  5963. finalize_rpath=
  5964. compile_shlibpath=
  5965. finalize_shlibpath=
  5966. convenience=
  5967. old_convenience=
  5968. deplibs=
  5969. old_deplibs=
  5970. compiler_flags=
  5971. linker_flags=
  5972. dllsearchpath=
  5973. lib_search_path=`pwd`
  5974. inst_prefix_dir=
  5975. new_inherited_linker_flags=
  5976. avoid_version=no
  5977. bindir=
  5978. dlfiles=
  5979. dlprefiles=
  5980. dlself=no
  5981. export_dynamic=no
  5982. export_symbols=
  5983. export_symbols_regex=
  5984. generated=
  5985. libobjs=
  5986. ltlibs=
  5987. module=no
  5988. no_install=no
  5989. objs=
  5990. os2dllname=
  5991. non_pic_objects=
  5992. precious_files_regex=
  5993. prefer_static_libs=no
  5994. preload=false
  5995. prev=
  5996. prevarg=
  5997. release=
  5998. rpath=
  5999. xrpath=
  6000. perm_rpath=
  6001. temp_rpath=
  6002. thread_safe=no
  6003. vinfo=
  6004. vinfo_number=no
  6005. weak_libs=
  6006. single_module=$wl-single_module
  6007. func_infer_tag $base_compile
  6008. # We need to know -static, to get the right output filenames.
  6009. for arg
  6010. do
  6011. case $arg in
  6012. -shared)
  6013. test yes != "$build_libtool_libs" \
  6014. && func_fatal_configuration "cannot build a shared library"
  6015. build_old_libs=no
  6016. break
  6017. ;;
  6018. -all-static | -static | -static-libtool-libs)
  6019. case $arg in
  6020. -all-static)
  6021. if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
  6022. func_warning "complete static linking is impossible in this configuration"
  6023. fi
  6024. if test -n "$link_static_flag"; then
  6025. dlopen_self=$dlopen_self_static
  6026. fi
  6027. prefer_static_libs=yes
  6028. ;;
  6029. -static)
  6030. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  6031. dlopen_self=$dlopen_self_static
  6032. fi
  6033. prefer_static_libs=built
  6034. ;;
  6035. -static-libtool-libs)
  6036. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  6037. dlopen_self=$dlopen_self_static
  6038. fi
  6039. prefer_static_libs=yes
  6040. ;;
  6041. esac
  6042. build_libtool_libs=no
  6043. build_old_libs=yes
  6044. break
  6045. ;;
  6046. esac
  6047. done
  6048. # See if our shared archives depend on static archives.
  6049. test -n "$old_archive_from_new_cmds" && build_old_libs=yes
  6050. # Go through the arguments, transforming them on the way.
  6051. while test "$#" -gt 0; do
  6052. arg=$1
  6053. shift
  6054. func_quote_for_eval "$arg"
  6055. qarg=$func_quote_for_eval_unquoted_result
  6056. func_append libtool_args " $func_quote_for_eval_result"
  6057. # If the previous option needs an argument, assign it.
  6058. if test -n "$prev"; then
  6059. case $prev in
  6060. output)
  6061. func_append compile_command " @OUTPUT@"
  6062. func_append finalize_command " @OUTPUT@"
  6063. ;;
  6064. esac
  6065. case $prev in
  6066. bindir)
  6067. bindir=$arg
  6068. prev=
  6069. continue
  6070. ;;
  6071. dlfiles|dlprefiles)
  6072. $preload || {
  6073. # Add the symbol object into the linking commands.
  6074. func_append compile_command " @SYMFILE@"
  6075. func_append finalize_command " @SYMFILE@"
  6076. preload=:
  6077. }
  6078. case $arg in
  6079. *.la | *.lo) ;; # We handle these cases below.
  6080. force)
  6081. if test no = "$dlself"; then
  6082. dlself=needless
  6083. export_dynamic=yes
  6084. fi
  6085. prev=
  6086. continue
  6087. ;;
  6088. self)
  6089. if test dlprefiles = "$prev"; then
  6090. dlself=yes
  6091. elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
  6092. dlself=yes
  6093. else
  6094. dlself=needless
  6095. export_dynamic=yes
  6096. fi
  6097. prev=
  6098. continue
  6099. ;;
  6100. *)
  6101. if test dlfiles = "$prev"; then
  6102. func_append dlfiles " $arg"
  6103. else
  6104. func_append dlprefiles " $arg"
  6105. fi
  6106. prev=
  6107. continue
  6108. ;;
  6109. esac
  6110. ;;
  6111. expsyms)
  6112. export_symbols=$arg
  6113. test -f "$arg" \
  6114. || func_fatal_error "symbol file '$arg' does not exist"
  6115. prev=
  6116. continue
  6117. ;;
  6118. expsyms_regex)
  6119. export_symbols_regex=$arg
  6120. prev=
  6121. continue
  6122. ;;
  6123. framework)
  6124. case $host in
  6125. *-*-darwin*)
  6126. case "$deplibs " in
  6127. *" $qarg.ltframework "*) ;;
  6128. *) func_append deplibs " $qarg.ltframework" # this is fixed later
  6129. ;;
  6130. esac
  6131. ;;
  6132. esac
  6133. prev=
  6134. continue
  6135. ;;
  6136. inst_prefix)
  6137. inst_prefix_dir=$arg
  6138. prev=
  6139. continue
  6140. ;;
  6141. mllvm)
  6142. # Clang does not use LLVM to link, so we can simply discard any
  6143. # '-mllvm $arg' options when doing the link step.
  6144. prev=
  6145. continue
  6146. ;;
  6147. objectlist)
  6148. if test -f "$arg"; then
  6149. save_arg=$arg
  6150. moreargs=
  6151. for fil in `cat "$save_arg"`
  6152. do
  6153. # func_append moreargs " $fil"
  6154. arg=$fil
  6155. # A libtool-controlled object.
  6156. # Check to see that this really is a libtool object.
  6157. if func_lalib_unsafe_p "$arg"; then
  6158. pic_object=
  6159. non_pic_object=
  6160. # Read the .lo file
  6161. func_source "$arg"
  6162. if test -z "$pic_object" ||
  6163. test -z "$non_pic_object" ||
  6164. test none = "$pic_object" &&
  6165. test none = "$non_pic_object"; then
  6166. func_fatal_error "cannot find name of object for '$arg'"
  6167. fi
  6168. # Extract subdirectory from the argument.
  6169. func_dirname "$arg" "/" ""
  6170. xdir=$func_dirname_result
  6171. if test none != "$pic_object"; then
  6172. # Prepend the subdirectory the object is found in.
  6173. pic_object=$xdir$pic_object
  6174. if test dlfiles = "$prev"; then
  6175. if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
  6176. func_append dlfiles " $pic_object"
  6177. prev=
  6178. continue
  6179. else
  6180. # If libtool objects are unsupported, then we need to preload.
  6181. prev=dlprefiles
  6182. fi
  6183. fi
  6184. # CHECK ME: I think I busted this. -Ossama
  6185. if test dlprefiles = "$prev"; then
  6186. # Preload the old-style object.
  6187. func_append dlprefiles " $pic_object"
  6188. prev=
  6189. fi
  6190. # A PIC object.
  6191. func_append libobjs " $pic_object"
  6192. arg=$pic_object
  6193. fi
  6194. # Non-PIC object.
  6195. if test none != "$non_pic_object"; then
  6196. # Prepend the subdirectory the object is found in.
  6197. non_pic_object=$xdir$non_pic_object
  6198. # A standard non-PIC object
  6199. func_append non_pic_objects " $non_pic_object"
  6200. if test -z "$pic_object" || test none = "$pic_object"; then
  6201. arg=$non_pic_object
  6202. fi
  6203. else
  6204. # If the PIC object exists, use it instead.
  6205. # $xdir was prepended to $pic_object above.
  6206. non_pic_object=$pic_object
  6207. func_append non_pic_objects " $non_pic_object"
  6208. fi
  6209. else
  6210. # Only an error if not doing a dry-run.
  6211. if $opt_dry_run; then
  6212. # Extract subdirectory from the argument.
  6213. func_dirname "$arg" "/" ""
  6214. xdir=$func_dirname_result
  6215. func_lo2o "$arg"
  6216. pic_object=$xdir$objdir/$func_lo2o_result
  6217. non_pic_object=$xdir$func_lo2o_result
  6218. func_append libobjs " $pic_object"
  6219. func_append non_pic_objects " $non_pic_object"
  6220. else
  6221. func_fatal_error "'$arg' is not a valid libtool object"
  6222. fi
  6223. fi
  6224. done
  6225. else
  6226. func_fatal_error "link input file '$arg' does not exist"
  6227. fi
  6228. arg=$save_arg
  6229. prev=
  6230. continue
  6231. ;;
  6232. os2dllname)
  6233. os2dllname=$arg
  6234. prev=
  6235. continue
  6236. ;;
  6237. precious_regex)
  6238. precious_files_regex=$arg
  6239. prev=
  6240. continue
  6241. ;;
  6242. release)
  6243. release=-$arg
  6244. prev=
  6245. continue
  6246. ;;
  6247. rpath | xrpath)
  6248. # We need an absolute path.
  6249. case $arg in
  6250. [\\/]* | [A-Za-z]:[\\/]*) ;;
  6251. *)
  6252. func_fatal_error "only absolute run-paths are allowed"
  6253. ;;
  6254. esac
  6255. if test rpath = "$prev"; then
  6256. case "$rpath " in
  6257. *" $arg "*) ;;
  6258. *) func_append rpath " $arg" ;;
  6259. esac
  6260. else
  6261. case "$xrpath " in
  6262. *" $arg "*) ;;
  6263. *) func_append xrpath " $arg" ;;
  6264. esac
  6265. fi
  6266. prev=
  6267. continue
  6268. ;;
  6269. shrext)
  6270. shrext_cmds=$arg
  6271. prev=
  6272. continue
  6273. ;;
  6274. weak)
  6275. func_append weak_libs " $arg"
  6276. prev=
  6277. continue
  6278. ;;
  6279. xcclinker)
  6280. func_append linker_flags " $qarg"
  6281. func_append compiler_flags " $qarg"
  6282. prev=
  6283. func_append compile_command " $qarg"
  6284. func_append finalize_command " $qarg"
  6285. continue
  6286. ;;
  6287. xcompiler)
  6288. func_append compiler_flags " $qarg"
  6289. prev=
  6290. func_append compile_command " $qarg"
  6291. func_append finalize_command " $qarg"
  6292. continue
  6293. ;;
  6294. xlinker)
  6295. func_append linker_flags " $qarg"
  6296. func_append compiler_flags " $wl$qarg"
  6297. prev=
  6298. func_append compile_command " $wl$qarg"
  6299. func_append finalize_command " $wl$qarg"
  6300. continue
  6301. ;;
  6302. *)
  6303. eval "$prev=\"\$arg\""
  6304. prev=
  6305. continue
  6306. ;;
  6307. esac
  6308. fi # test -n "$prev"
  6309. prevarg=$arg
  6310. case $arg in
  6311. -all-static)
  6312. if test -n "$link_static_flag"; then
  6313. # See comment for -static flag below, for more details.
  6314. func_append compile_command " $link_static_flag"
  6315. func_append finalize_command " $link_static_flag"
  6316. fi
  6317. continue
  6318. ;;
  6319. -allow-undefined)
  6320. # FIXME: remove this flag sometime in the future.
  6321. func_fatal_error "'-allow-undefined' must not be used because it is the default"
  6322. ;;
  6323. -avoid-version)
  6324. avoid_version=yes
  6325. continue
  6326. ;;
  6327. -bindir)
  6328. prev=bindir
  6329. continue
  6330. ;;
  6331. -dlopen)
  6332. prev=dlfiles
  6333. continue
  6334. ;;
  6335. -dlpreopen)
  6336. prev=dlprefiles
  6337. continue
  6338. ;;
  6339. -export-dynamic)
  6340. export_dynamic=yes
  6341. continue
  6342. ;;
  6343. -export-symbols | -export-symbols-regex)
  6344. if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  6345. func_fatal_error "more than one -exported-symbols argument is not allowed"
  6346. fi
  6347. if test X-export-symbols = "X$arg"; then
  6348. prev=expsyms
  6349. else
  6350. prev=expsyms_regex
  6351. fi
  6352. continue
  6353. ;;
  6354. -framework)
  6355. prev=framework
  6356. continue
  6357. ;;
  6358. -inst-prefix-dir)
  6359. prev=inst_prefix
  6360. continue
  6361. ;;
  6362. # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
  6363. # so, if we see these flags be careful not to treat them like -L
  6364. -L[A-Z][A-Z]*:*)
  6365. case $with_gcc/$host in
  6366. no/*-*-irix* | /*-*-irix*)
  6367. func_append compile_command " $arg"
  6368. func_append finalize_command " $arg"
  6369. ;;
  6370. esac
  6371. continue
  6372. ;;
  6373. -L*)
  6374. func_stripname "-L" '' "$arg"
  6375. if test -z "$func_stripname_result"; then
  6376. if test "$#" -gt 0; then
  6377. func_fatal_error "require no space between '-L' and '$1'"
  6378. else
  6379. func_fatal_error "need path for '-L' option"
  6380. fi
  6381. fi
  6382. func_resolve_sysroot "$func_stripname_result"
  6383. dir=$func_resolve_sysroot_result
  6384. # We need an absolute path.
  6385. case $dir in
  6386. [\\/]* | [A-Za-z]:[\\/]*) ;;
  6387. *)
  6388. absdir=`cd "$dir" && pwd`
  6389. test -z "$absdir" && \
  6390. func_fatal_error "cannot determine absolute directory name of '$dir'"
  6391. dir=$absdir
  6392. ;;
  6393. esac
  6394. case "$deplibs " in
  6395. *" -L$dir "* | *" $arg "*)
  6396. # Will only happen for absolute or sysroot arguments
  6397. ;;
  6398. *)
  6399. # Preserve sysroot, but never include relative directories
  6400. case $dir in
  6401. [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
  6402. *) func_append deplibs " -L$dir" ;;
  6403. esac
  6404. func_append lib_search_path " $dir"
  6405. ;;
  6406. esac
  6407. case $host in
  6408. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
  6409. testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
  6410. case :$dllsearchpath: in
  6411. *":$dir:"*) ;;
  6412. ::) dllsearchpath=$dir;;
  6413. *) func_append dllsearchpath ":$dir";;
  6414. esac
  6415. case :$dllsearchpath: in
  6416. *":$testbindir:"*) ;;
  6417. ::) dllsearchpath=$testbindir;;
  6418. *) func_append dllsearchpath ":$testbindir";;
  6419. esac
  6420. ;;
  6421. esac
  6422. continue
  6423. ;;
  6424. -l*)
  6425. if test X-lc = "X$arg" || test X-lm = "X$arg"; then
  6426. case $host in
  6427. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
  6428. # These systems don't actually have a C or math library (as such)
  6429. continue
  6430. ;;
  6431. *-*-os2*)
  6432. # These systems don't actually have a C library (as such)
  6433. test X-lc = "X$arg" && continue
  6434. ;;
  6435. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
  6436. # Do not include libc due to us having libc/libc_r.
  6437. test X-lc = "X$arg" && continue
  6438. ;;
  6439. *-*-rhapsody* | *-*-darwin1.[012])
  6440. # Rhapsody C and math libraries are in the System framework
  6441. func_append deplibs " System.ltframework"
  6442. continue
  6443. ;;
  6444. *-*-sco3.2v5* | *-*-sco5v6*)
  6445. # Causes problems with __ctype
  6446. test X-lc = "X$arg" && continue
  6447. ;;
  6448. *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
  6449. # Compiler inserts libc in the correct place for threads to work
  6450. test X-lc = "X$arg" && continue
  6451. ;;
  6452. esac
  6453. elif test X-lc_r = "X$arg"; then
  6454. case $host in
  6455. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
  6456. # Do not include libc_r directly, use -pthread flag.
  6457. continue
  6458. ;;
  6459. esac
  6460. fi
  6461. func_append deplibs " $arg"
  6462. continue
  6463. ;;
  6464. -mllvm)
  6465. prev=mllvm
  6466. continue
  6467. ;;
  6468. -module)
  6469. module=yes
  6470. continue
  6471. ;;
  6472. # Tru64 UNIX uses -model [arg] to determine the layout of C++
  6473. # classes, name mangling, and exception handling.
  6474. # Darwin uses the -arch flag to determine output architecture.
  6475. -model|-arch|-isysroot|--sysroot)
  6476. func_append compiler_flags " $arg"
  6477. func_append compile_command " $arg"
  6478. func_append finalize_command " $arg"
  6479. prev=xcompiler
  6480. continue
  6481. ;;
  6482. -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
  6483. |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
  6484. func_append compiler_flags " $arg"
  6485. func_append compile_command " $arg"
  6486. func_append finalize_command " $arg"
  6487. case "$new_inherited_linker_flags " in
  6488. *" $arg "*) ;;
  6489. * ) func_append new_inherited_linker_flags " $arg" ;;
  6490. esac
  6491. continue
  6492. ;;
  6493. -multi_module)
  6494. single_module=$wl-multi_module
  6495. continue
  6496. ;;
  6497. -no-fast-install)
  6498. fast_install=no
  6499. continue
  6500. ;;
  6501. -no-install)
  6502. case $host in
  6503. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
  6504. # The PATH hackery in wrapper scripts is required on Windows
  6505. # and Darwin in order for the loader to find any dlls it needs.
  6506. func_warning "'-no-install' is ignored for $host"
  6507. func_warning "assuming '-no-fast-install' instead"
  6508. fast_install=no
  6509. ;;
  6510. *) no_install=yes ;;
  6511. esac
  6512. continue
  6513. ;;
  6514. -no-undefined)
  6515. allow_undefined=no
  6516. continue
  6517. ;;
  6518. -objectlist)
  6519. prev=objectlist
  6520. continue
  6521. ;;
  6522. -os2dllname)
  6523. prev=os2dllname
  6524. continue
  6525. ;;
  6526. -o) prev=output ;;
  6527. -precious-files-regex)
  6528. prev=precious_regex
  6529. continue
  6530. ;;
  6531. -release)
  6532. prev=release
  6533. continue
  6534. ;;
  6535. -rpath)
  6536. prev=rpath
  6537. continue
  6538. ;;
  6539. -R)
  6540. prev=xrpath
  6541. continue
  6542. ;;
  6543. -R*)
  6544. func_stripname '-R' '' "$arg"
  6545. dir=$func_stripname_result
  6546. # We need an absolute path.
  6547. case $dir in
  6548. [\\/]* | [A-Za-z]:[\\/]*) ;;
  6549. =*)
  6550. func_stripname '=' '' "$dir"
  6551. dir=$lt_sysroot$func_stripname_result
  6552. ;;
  6553. *)
  6554. func_fatal_error "only absolute run-paths are allowed"
  6555. ;;
  6556. esac
  6557. case "$xrpath " in
  6558. *" $dir "*) ;;
  6559. *) func_append xrpath " $dir" ;;
  6560. esac
  6561. continue
  6562. ;;
  6563. -shared)
  6564. # The effects of -shared are defined in a previous loop.
  6565. continue
  6566. ;;
  6567. -shrext)
  6568. prev=shrext
  6569. continue
  6570. ;;
  6571. -static | -static-libtool-libs)
  6572. # The effects of -static are defined in a previous loop.
  6573. # We used to do the same as -all-static on platforms that
  6574. # didn't have a PIC flag, but the assumption that the effects
  6575. # would be equivalent was wrong. It would break on at least
  6576. # Digital Unix and AIX.
  6577. continue
  6578. ;;
  6579. -thread-safe)
  6580. thread_safe=yes
  6581. continue
  6582. ;;
  6583. -version-info)
  6584. prev=vinfo
  6585. continue
  6586. ;;
  6587. -version-number)
  6588. prev=vinfo
  6589. vinfo_number=yes
  6590. continue
  6591. ;;
  6592. -weak)
  6593. prev=weak
  6594. continue
  6595. ;;
  6596. -Wc,*)
  6597. func_stripname '-Wc,' '' "$arg"
  6598. args=$func_stripname_result
  6599. arg=
  6600. save_ifs=$IFS; IFS=,
  6601. for flag in $args; do
  6602. IFS=$save_ifs
  6603. func_quote_for_eval "$flag"
  6604. func_append arg " $func_quote_for_eval_result"
  6605. func_append compiler_flags " $func_quote_for_eval_result"
  6606. done
  6607. IFS=$save_ifs
  6608. func_stripname ' ' '' "$arg"
  6609. arg=$func_stripname_result
  6610. ;;
  6611. -Wl,*)
  6612. func_stripname '-Wl,' '' "$arg"
  6613. args=$func_stripname_result
  6614. arg=
  6615. save_ifs=$IFS; IFS=,
  6616. for flag in $args; do
  6617. IFS=$save_ifs
  6618. func_quote_for_eval "$flag"
  6619. func_append arg " $wl$func_quote_for_eval_result"
  6620. func_append compiler_flags " $wl$func_quote_for_eval_result"
  6621. func_append linker_flags " $func_quote_for_eval_result"
  6622. done
  6623. IFS=$save_ifs
  6624. func_stripname ' ' '' "$arg"
  6625. arg=$func_stripname_result
  6626. ;;
  6627. -Xcompiler)
  6628. prev=xcompiler
  6629. continue
  6630. ;;
  6631. -Xlinker)
  6632. prev=xlinker
  6633. continue
  6634. ;;
  6635. -XCClinker)
  6636. prev=xcclinker
  6637. continue
  6638. ;;
  6639. # -msg_* for osf cc
  6640. -msg_*)
  6641. func_quote_for_eval "$arg"
  6642. arg=$func_quote_for_eval_result
  6643. ;;
  6644. # Flags to be passed through unchanged, with rationale:
  6645. # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
  6646. # -r[0-9][0-9]* specify processor for the SGI compiler
  6647. # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
  6648. # +DA*, +DD* enable 64-bit mode for the HP compiler
  6649. # -q* compiler args for the IBM compiler
  6650. # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
  6651. # -F/path path to uninstalled frameworks, gcc on darwin
  6652. # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
  6653. # -fstack-protector* stack protector flags for GCC
  6654. # @file GCC response files
  6655. # -tp=* Portland pgcc target processor selection
  6656. # --sysroot=* for sysroot support
  6657. # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
  6658. # -stdlib=* select c++ std lib with clang
  6659. -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
  6660. -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
  6661. -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
  6662. func_quote_for_eval "$arg"
  6663. arg=$func_quote_for_eval_result
  6664. func_append compile_command " $arg"
  6665. func_append finalize_command " $arg"
  6666. func_append compiler_flags " $arg"
  6667. continue
  6668. ;;
  6669. -Z*)
  6670. if test os2 = "`expr $host : '.*\(os2\)'`"; then
  6671. # OS/2 uses -Zxxx to specify OS/2-specific options
  6672. compiler_flags="$compiler_flags $arg"
  6673. func_append compile_command " $arg"
  6674. func_append finalize_command " $arg"
  6675. case $arg in
  6676. -Zlinker | -Zstack)
  6677. prev=xcompiler
  6678. ;;
  6679. esac
  6680. continue
  6681. else
  6682. # Otherwise treat like 'Some other compiler flag' below
  6683. func_quote_for_eval "$arg"
  6684. arg=$func_quote_for_eval_result
  6685. fi
  6686. ;;
  6687. # Some other compiler flag.
  6688. -* | +*)
  6689. func_quote_for_eval "$arg"
  6690. arg=$func_quote_for_eval_result
  6691. ;;
  6692. *.$objext)
  6693. # A standard object.
  6694. func_append objs " $arg"
  6695. ;;
  6696. *.lo)
  6697. # A libtool-controlled object.
  6698. # Check to see that this really is a libtool object.
  6699. if func_lalib_unsafe_p "$arg"; then
  6700. pic_object=
  6701. non_pic_object=
  6702. # Read the .lo file
  6703. func_source "$arg"
  6704. if test -z "$pic_object" ||
  6705. test -z "$non_pic_object" ||
  6706. test none = "$pic_object" &&
  6707. test none = "$non_pic_object"; then
  6708. func_fatal_error "cannot find name of object for '$arg'"
  6709. fi
  6710. # Extract subdirectory from the argument.
  6711. func_dirname "$arg" "/" ""
  6712. xdir=$func_dirname_result
  6713. test none = "$pic_object" || {
  6714. # Prepend the subdirectory the object is found in.
  6715. pic_object=$xdir$pic_object
  6716. if test dlfiles = "$prev"; then
  6717. if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
  6718. func_append dlfiles " $pic_object"
  6719. prev=
  6720. continue
  6721. else
  6722. # If libtool objects are unsupported, then we need to preload.
  6723. prev=dlprefiles
  6724. fi
  6725. fi
  6726. # CHECK ME: I think I busted this. -Ossama
  6727. if test dlprefiles = "$prev"; then
  6728. # Preload the old-style object.
  6729. func_append dlprefiles " $pic_object"
  6730. prev=
  6731. fi
  6732. # A PIC object.
  6733. func_append libobjs " $pic_object"
  6734. arg=$pic_object
  6735. }
  6736. # Non-PIC object.
  6737. if test none != "$non_pic_object"; then
  6738. # Prepend the subdirectory the object is found in.
  6739. non_pic_object=$xdir$non_pic_object
  6740. # A standard non-PIC object
  6741. func_append non_pic_objects " $non_pic_object"
  6742. if test -z "$pic_object" || test none = "$pic_object"; then
  6743. arg=$non_pic_object
  6744. fi
  6745. else
  6746. # If the PIC object exists, use it instead.
  6747. # $xdir was prepended to $pic_object above.
  6748. non_pic_object=$pic_object
  6749. func_append non_pic_objects " $non_pic_object"
  6750. fi
  6751. else
  6752. # Only an error if not doing a dry-run.
  6753. if $opt_dry_run; then
  6754. # Extract subdirectory from the argument.
  6755. func_dirname "$arg" "/" ""
  6756. xdir=$func_dirname_result
  6757. func_lo2o "$arg"
  6758. pic_object=$xdir$objdir/$func_lo2o_result
  6759. non_pic_object=$xdir$func_lo2o_result
  6760. func_append libobjs " $pic_object"
  6761. func_append non_pic_objects " $non_pic_object"
  6762. else
  6763. func_fatal_error "'$arg' is not a valid libtool object"
  6764. fi
  6765. fi
  6766. ;;
  6767. *.$libext)
  6768. # An archive.
  6769. func_append deplibs " $arg"
  6770. func_append old_deplibs " $arg"
  6771. continue
  6772. ;;
  6773. *.la)
  6774. # A libtool-controlled library.
  6775. func_resolve_sysroot "$arg"
  6776. if test dlfiles = "$prev"; then
  6777. # This library was specified with -dlopen.
  6778. func_append dlfiles " $func_resolve_sysroot_result"
  6779. prev=
  6780. elif test dlprefiles = "$prev"; then
  6781. # The library was specified with -dlpreopen.
  6782. func_append dlprefiles " $func_resolve_sysroot_result"
  6783. prev=
  6784. else
  6785. func_append deplibs " $func_resolve_sysroot_result"
  6786. fi
  6787. continue
  6788. ;;
  6789. # Some other compiler argument.
  6790. *)
  6791. # Unknown arguments in both finalize_command and compile_command need
  6792. # to be aesthetically quoted because they are evaled later.
  6793. func_quote_for_eval "$arg"
  6794. arg=$func_quote_for_eval_result
  6795. ;;
  6796. esac # arg
  6797. # Now actually substitute the argument into the commands.
  6798. if test -n "$arg"; then
  6799. func_append compile_command " $arg"
  6800. func_append finalize_command " $arg"
  6801. fi
  6802. done # argument parsing loop
  6803. test -n "$prev" && \
  6804. func_fatal_help "the '$prevarg' option requires an argument"
  6805. if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
  6806. eval arg=\"$export_dynamic_flag_spec\"
  6807. func_append compile_command " $arg"
  6808. func_append finalize_command " $arg"
  6809. fi
  6810. oldlibs=
  6811. # calculate the name of the file, without its directory
  6812. func_basename "$output"
  6813. outputname=$func_basename_result
  6814. libobjs_save=$libobjs
  6815. if test -n "$shlibpath_var"; then
  6816. # get the directories listed in $shlibpath_var
  6817. eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
  6818. else
  6819. shlib_search_path=
  6820. fi
  6821. eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
  6822. eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
  6823. # Definition is injected by LT_CONFIG during libtool generation.
  6824. func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
  6825. func_dirname "$output" "/" ""
  6826. output_objdir=$func_dirname_result$objdir
  6827. func_to_tool_file "$output_objdir/"
  6828. tool_output_objdir=$func_to_tool_file_result
  6829. # Create the object directory.
  6830. func_mkdir_p "$output_objdir"
  6831. # Determine the type of output
  6832. case $output in
  6833. "")
  6834. func_fatal_help "you must specify an output file"
  6835. ;;
  6836. *.$libext) linkmode=oldlib ;;
  6837. *.lo | *.$objext) linkmode=obj ;;
  6838. *.la) linkmode=lib ;;
  6839. *) linkmode=prog ;; # Anything else should be a program.
  6840. esac
  6841. specialdeplibs=
  6842. libs=
  6843. # Find all interdependent deplibs by searching for libraries
  6844. # that are linked more than once (e.g. -la -lb -la)
  6845. for deplib in $deplibs; do
  6846. if $opt_preserve_dup_deps; then
  6847. case "$libs " in
  6848. *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  6849. esac
  6850. fi
  6851. func_append libs " $deplib"
  6852. done
  6853. if test lib = "$linkmode"; then
  6854. libs="$predeps $libs $compiler_lib_search_path $postdeps"
  6855. # Compute libraries that are listed more than once in $predeps
  6856. # $postdeps and mark them as special (i.e., whose duplicates are
  6857. # not to be eliminated).
  6858. pre_post_deps=
  6859. if $opt_duplicate_compiler_generated_deps; then
  6860. for pre_post_dep in $predeps $postdeps; do
  6861. case "$pre_post_deps " in
  6862. *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
  6863. esac
  6864. func_append pre_post_deps " $pre_post_dep"
  6865. done
  6866. fi
  6867. pre_post_deps=
  6868. fi
  6869. deplibs=
  6870. newdependency_libs=
  6871. newlib_search_path=
  6872. need_relink=no # whether we're linking any uninstalled libtool libraries
  6873. notinst_deplibs= # not-installed libtool libraries
  6874. notinst_path= # paths that contain not-installed libtool libraries
  6875. case $linkmode in
  6876. lib)
  6877. passes="conv dlpreopen link"
  6878. for file in $dlfiles $dlprefiles; do
  6879. case $file in
  6880. *.la) ;;
  6881. *)
  6882. func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
  6883. ;;
  6884. esac
  6885. done
  6886. ;;
  6887. prog)
  6888. compile_deplibs=
  6889. finalize_deplibs=
  6890. alldeplibs=false
  6891. newdlfiles=
  6892. newdlprefiles=
  6893. passes="conv scan dlopen dlpreopen link"
  6894. ;;
  6895. *) passes="conv"
  6896. ;;
  6897. esac
  6898. for pass in $passes; do
  6899. # The preopen pass in lib mode reverses $deplibs; put it back here
  6900. # so that -L comes before libs that need it for instance...
  6901. if test lib,link = "$linkmode,$pass"; then
  6902. ## FIXME: Find the place where the list is rebuilt in the wrong
  6903. ## order, and fix it there properly
  6904. tmp_deplibs=
  6905. for deplib in $deplibs; do
  6906. tmp_deplibs="$deplib $tmp_deplibs"
  6907. done
  6908. deplibs=$tmp_deplibs
  6909. fi
  6910. if test lib,link = "$linkmode,$pass" ||
  6911. test prog,scan = "$linkmode,$pass"; then
  6912. libs=$deplibs
  6913. deplibs=
  6914. fi
  6915. if test prog = "$linkmode"; then
  6916. case $pass in
  6917. dlopen) libs=$dlfiles ;;
  6918. dlpreopen) libs=$dlprefiles ;;
  6919. link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
  6920. esac
  6921. fi
  6922. if test lib,dlpreopen = "$linkmode,$pass"; then
  6923. # Collect and forward deplibs of preopened libtool libs
  6924. for lib in $dlprefiles; do
  6925. # Ignore non-libtool-libs
  6926. dependency_libs=
  6927. func_resolve_sysroot "$lib"
  6928. case $lib in
  6929. *.la) func_source "$func_resolve_sysroot_result" ;;
  6930. esac
  6931. # Collect preopened libtool deplibs, except any this library
  6932. # has declared as weak libs
  6933. for deplib in $dependency_libs; do
  6934. func_basename "$deplib"
  6935. deplib_base=$func_basename_result
  6936. case " $weak_libs " in
  6937. *" $deplib_base "*) ;;
  6938. *) func_append deplibs " $deplib" ;;
  6939. esac
  6940. done
  6941. done
  6942. libs=$dlprefiles
  6943. fi
  6944. if test dlopen = "$pass"; then
  6945. # Collect dlpreopened libraries
  6946. save_deplibs=$deplibs
  6947. deplibs=
  6948. fi
  6949. for deplib in $libs; do
  6950. lib=
  6951. found=false
  6952. case $deplib in
  6953. -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
  6954. |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
  6955. if test prog,link = "$linkmode,$pass"; then
  6956. compile_deplibs="$deplib $compile_deplibs"
  6957. finalize_deplibs="$deplib $finalize_deplibs"
  6958. else
  6959. func_append compiler_flags " $deplib"
  6960. if test lib = "$linkmode"; then
  6961. case "$new_inherited_linker_flags " in
  6962. *" $deplib "*) ;;
  6963. * ) func_append new_inherited_linker_flags " $deplib" ;;
  6964. esac
  6965. fi
  6966. fi
  6967. continue
  6968. ;;
  6969. -l*)
  6970. if test lib != "$linkmode" && test prog != "$linkmode"; then
  6971. func_warning "'-l' is ignored for archives/objects"
  6972. continue
  6973. fi
  6974. func_stripname '-l' '' "$deplib"
  6975. name=$func_stripname_result
  6976. if test lib = "$linkmode"; then
  6977. searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
  6978. else
  6979. searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
  6980. fi
  6981. for searchdir in $searchdirs; do
  6982. for search_ext in .la $std_shrext .so .a; do
  6983. # Search the libtool library
  6984. lib=$searchdir/lib$name$search_ext
  6985. if test -f "$lib"; then
  6986. if test .la = "$search_ext"; then
  6987. found=:
  6988. else
  6989. found=false
  6990. fi
  6991. break 2
  6992. fi
  6993. done
  6994. done
  6995. if $found; then
  6996. # deplib is a libtool library
  6997. # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
  6998. # We need to do some special things here, and not later.
  6999. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  7000. case " $predeps $postdeps " in
  7001. *" $deplib "*)
  7002. if func_lalib_p "$lib"; then
  7003. library_names=
  7004. old_library=
  7005. func_source "$lib"
  7006. for l in $old_library $library_names; do
  7007. ll=$l
  7008. done
  7009. if test "X$ll" = "X$old_library"; then # only static version available
  7010. found=false
  7011. func_dirname "$lib" "" "."
  7012. ladir=$func_dirname_result
  7013. lib=$ladir/$old_library
  7014. if test prog,link = "$linkmode,$pass"; then
  7015. compile_deplibs="$deplib $compile_deplibs"
  7016. finalize_deplibs="$deplib $finalize_deplibs"
  7017. else
  7018. deplibs="$deplib $deplibs"
  7019. test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
  7020. fi
  7021. continue
  7022. fi
  7023. fi
  7024. ;;
  7025. *) ;;
  7026. esac
  7027. fi
  7028. else
  7029. # deplib doesn't seem to be a libtool library
  7030. if test prog,link = "$linkmode,$pass"; then
  7031. compile_deplibs="$deplib $compile_deplibs"
  7032. finalize_deplibs="$deplib $finalize_deplibs"
  7033. else
  7034. deplibs="$deplib $deplibs"
  7035. test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
  7036. fi
  7037. continue
  7038. fi
  7039. ;; # -l
  7040. *.ltframework)
  7041. if test prog,link = "$linkmode,$pass"; then
  7042. compile_deplibs="$deplib $compile_deplibs"
  7043. finalize_deplibs="$deplib $finalize_deplibs"
  7044. else
  7045. deplibs="$deplib $deplibs"
  7046. if test lib = "$linkmode"; then
  7047. case "$new_inherited_linker_flags " in
  7048. *" $deplib "*) ;;
  7049. * ) func_append new_inherited_linker_flags " $deplib" ;;
  7050. esac
  7051. fi
  7052. fi
  7053. continue
  7054. ;;
  7055. -L*)
  7056. case $linkmode in
  7057. lib)
  7058. deplibs="$deplib $deplibs"
  7059. test conv = "$pass" && continue
  7060. newdependency_libs="$deplib $newdependency_libs"
  7061. func_stripname '-L' '' "$deplib"
  7062. func_resolve_sysroot "$func_stripname_result"
  7063. func_append newlib_search_path " $func_resolve_sysroot_result"
  7064. ;;
  7065. prog)
  7066. if test conv = "$pass"; then
  7067. deplibs="$deplib $deplibs"
  7068. continue
  7069. fi
  7070. if test scan = "$pass"; then
  7071. deplibs="$deplib $deplibs"
  7072. else
  7073. compile_deplibs="$deplib $compile_deplibs"
  7074. finalize_deplibs="$deplib $finalize_deplibs"
  7075. fi
  7076. func_stripname '-L' '' "$deplib"
  7077. func_resolve_sysroot "$func_stripname_result"
  7078. func_append newlib_search_path " $func_resolve_sysroot_result"
  7079. ;;
  7080. *)
  7081. func_warning "'-L' is ignored for archives/objects"
  7082. ;;
  7083. esac # linkmode
  7084. continue
  7085. ;; # -L
  7086. -R*)
  7087. if test link = "$pass"; then
  7088. func_stripname '-R' '' "$deplib"
  7089. func_resolve_sysroot "$func_stripname_result"
  7090. dir=$func_resolve_sysroot_result
  7091. # Make sure the xrpath contains only unique directories.
  7092. case "$xrpath " in
  7093. *" $dir "*) ;;
  7094. *) func_append xrpath " $dir" ;;
  7095. esac
  7096. fi
  7097. deplibs="$deplib $deplibs"
  7098. continue
  7099. ;;
  7100. *.la)
  7101. func_resolve_sysroot "$deplib"
  7102. lib=$func_resolve_sysroot_result
  7103. ;;
  7104. *.$libext)
  7105. if test conv = "$pass"; then
  7106. deplibs="$deplib $deplibs"
  7107. continue
  7108. fi
  7109. case $linkmode in
  7110. lib)
  7111. # Linking convenience modules into shared libraries is allowed,
  7112. # but linking other static libraries is non-portable.
  7113. case " $dlpreconveniencelibs " in
  7114. *" $deplib "*) ;;
  7115. *)
  7116. valid_a_lib=false
  7117. case $deplibs_check_method in
  7118. match_pattern*)
  7119. set dummy $deplibs_check_method; shift
  7120. match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  7121. if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
  7122. | $EGREP "$match_pattern_regex" > /dev/null; then
  7123. valid_a_lib=:
  7124. fi
  7125. ;;
  7126. pass_all)
  7127. valid_a_lib=:
  7128. ;;
  7129. esac
  7130. if $valid_a_lib; then
  7131. echo
  7132. $ECHO "*** Warning: Linking the shared library $output against the"
  7133. $ECHO "*** static library $deplib is not portable!"
  7134. deplibs="$deplib $deplibs"
  7135. else
  7136. echo
  7137. $ECHO "*** Warning: Trying to link with static lib archive $deplib."
  7138. echo "*** I have the capability to make that library automatically link in when"
  7139. echo "*** you link to this library. But I can only do this if you have a"
  7140. echo "*** shared version of the library, which you do not appear to have"
  7141. echo "*** because the file extensions .$libext of this argument makes me believe"
  7142. echo "*** that it is just a static archive that I should not use here."
  7143. fi
  7144. ;;
  7145. esac
  7146. continue
  7147. ;;
  7148. prog)
  7149. if test link != "$pass"; then
  7150. deplibs="$deplib $deplibs"
  7151. else
  7152. compile_deplibs="$deplib $compile_deplibs"
  7153. finalize_deplibs="$deplib $finalize_deplibs"
  7154. fi
  7155. continue
  7156. ;;
  7157. esac # linkmode
  7158. ;; # *.$libext
  7159. *.lo | *.$objext)
  7160. if test conv = "$pass"; then
  7161. deplibs="$deplib $deplibs"
  7162. elif test prog = "$linkmode"; then
  7163. if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
  7164. # If there is no dlopen support or we're linking statically,
  7165. # we need to preload.
  7166. func_append newdlprefiles " $deplib"
  7167. compile_deplibs="$deplib $compile_deplibs"
  7168. finalize_deplibs="$deplib $finalize_deplibs"
  7169. else
  7170. func_append newdlfiles " $deplib"
  7171. fi
  7172. fi
  7173. continue
  7174. ;;
  7175. %DEPLIBS%)
  7176. alldeplibs=:
  7177. continue
  7178. ;;
  7179. esac # case $deplib
  7180. $found || test -f "$lib" \
  7181. || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
  7182. # Check to see that this really is a libtool archive.
  7183. func_lalib_unsafe_p "$lib" \
  7184. || func_fatal_error "'$lib' is not a valid libtool archive"
  7185. func_dirname "$lib" "" "."
  7186. ladir=$func_dirname_result
  7187. dlname=
  7188. dlopen=
  7189. dlpreopen=
  7190. libdir=
  7191. library_names=
  7192. old_library=
  7193. inherited_linker_flags=
  7194. # If the library was installed with an old release of libtool,
  7195. # it will not redefine variables installed, or shouldnotlink
  7196. installed=yes
  7197. shouldnotlink=no
  7198. avoidtemprpath=
  7199. # Read the .la file
  7200. func_source "$lib"
  7201. # Convert "-framework foo" to "foo.ltframework"
  7202. if test -n "$inherited_linker_flags"; then
  7203. tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
  7204. for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
  7205. case " $new_inherited_linker_flags " in
  7206. *" $tmp_inherited_linker_flag "*) ;;
  7207. *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
  7208. esac
  7209. done
  7210. fi
  7211. dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7212. if test lib,link = "$linkmode,$pass" ||
  7213. test prog,scan = "$linkmode,$pass" ||
  7214. { test prog != "$linkmode" && test lib != "$linkmode"; }; then
  7215. test -n "$dlopen" && func_append dlfiles " $dlopen"
  7216. test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
  7217. fi
  7218. if test conv = "$pass"; then
  7219. # Only check for convenience libraries
  7220. deplibs="$lib $deplibs"
  7221. if test -z "$libdir"; then
  7222. if test -z "$old_library"; then
  7223. func_fatal_error "cannot find name of link library for '$lib'"
  7224. fi
  7225. # It is a libtool convenience library, so add in its objects.
  7226. func_append convenience " $ladir/$objdir/$old_library"
  7227. func_append old_convenience " $ladir/$objdir/$old_library"
  7228. elif test prog != "$linkmode" && test lib != "$linkmode"; then
  7229. func_fatal_error "'$lib' is not a convenience library"
  7230. fi
  7231. tmp_libs=
  7232. for deplib in $dependency_libs; do
  7233. deplibs="$deplib $deplibs"
  7234. if $opt_preserve_dup_deps; then
  7235. case "$tmp_libs " in
  7236. *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  7237. esac
  7238. fi
  7239. func_append tmp_libs " $deplib"
  7240. done
  7241. continue
  7242. fi # $pass = conv
  7243. # Get the name of the library we link against.
  7244. linklib=
  7245. if test -n "$old_library" &&
  7246. { test yes = "$prefer_static_libs" ||
  7247. test built,no = "$prefer_static_libs,$installed"; }; then
  7248. linklib=$old_library
  7249. else
  7250. for l in $old_library $library_names; do
  7251. linklib=$l
  7252. done
  7253. fi
  7254. if test -z "$linklib"; then
  7255. func_fatal_error "cannot find name of link library for '$lib'"
  7256. fi
  7257. # This library was specified with -dlopen.
  7258. if test dlopen = "$pass"; then
  7259. test -z "$libdir" \
  7260. && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
  7261. if test -z "$dlname" ||
  7262. test yes != "$dlopen_support" ||
  7263. test no = "$build_libtool_libs"
  7264. then
  7265. # If there is no dlname, no dlopen support or we're linking
  7266. # statically, we need to preload. We also need to preload any
  7267. # dependent libraries so libltdl's deplib preloader doesn't
  7268. # bomb out in the load deplibs phase.
  7269. func_append dlprefiles " $lib $dependency_libs"
  7270. else
  7271. func_append newdlfiles " $lib"
  7272. fi
  7273. continue
  7274. fi # $pass = dlopen
  7275. # We need an absolute path.
  7276. case $ladir in
  7277. [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
  7278. *)
  7279. abs_ladir=`cd "$ladir" && pwd`
  7280. if test -z "$abs_ladir"; then
  7281. func_warning "cannot determine absolute directory name of '$ladir'"
  7282. func_warning "passing it literally to the linker, although it might fail"
  7283. abs_ladir=$ladir
  7284. fi
  7285. ;;
  7286. esac
  7287. func_basename "$lib"
  7288. laname=$func_basename_result
  7289. # Find the relevant object directory and library name.
  7290. if test yes = "$installed"; then
  7291. if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
  7292. func_warning "library '$lib' was moved."
  7293. dir=$ladir
  7294. absdir=$abs_ladir
  7295. libdir=$abs_ladir
  7296. else
  7297. dir=$lt_sysroot$libdir
  7298. absdir=$lt_sysroot$libdir
  7299. fi
  7300. test yes = "$hardcode_automatic" && avoidtemprpath=yes
  7301. else
  7302. if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
  7303. dir=$ladir
  7304. absdir=$abs_ladir
  7305. # Remove this search path later
  7306. func_append notinst_path " $abs_ladir"
  7307. else
  7308. dir=$ladir/$objdir
  7309. absdir=$abs_ladir/$objdir
  7310. # Remove this search path later
  7311. func_append notinst_path " $abs_ladir"
  7312. fi
  7313. fi # $installed = yes
  7314. func_stripname 'lib' '.la' "$laname"
  7315. name=$func_stripname_result
  7316. # This library was specified with -dlpreopen.
  7317. if test dlpreopen = "$pass"; then
  7318. if test -z "$libdir" && test prog = "$linkmode"; then
  7319. func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
  7320. fi
  7321. case $host in
  7322. # special handling for platforms with PE-DLLs.
  7323. *cygwin* | *mingw* | *cegcc* )
  7324. # Linker will automatically link against shared library if both
  7325. # static and shared are present. Therefore, ensure we extract
  7326. # symbols from the import library if a shared library is present
  7327. # (otherwise, the dlopen module name will be incorrect). We do
  7328. # this by putting the import library name into $newdlprefiles.
  7329. # We recover the dlopen module name by 'saving' the la file
  7330. # name in a special purpose variable, and (later) extracting the
  7331. # dlname from the la file.
  7332. if test -n "$dlname"; then
  7333. func_tr_sh "$dir/$linklib"
  7334. eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
  7335. func_append newdlprefiles " $dir/$linklib"
  7336. else
  7337. func_append newdlprefiles " $dir/$old_library"
  7338. # Keep a list of preopened convenience libraries to check
  7339. # that they are being used correctly in the link pass.
  7340. test -z "$libdir" && \
  7341. func_append dlpreconveniencelibs " $dir/$old_library"
  7342. fi
  7343. ;;
  7344. * )
  7345. # Prefer using a static library (so that no silly _DYNAMIC symbols
  7346. # are required to link).
  7347. if test -n "$old_library"; then
  7348. func_append newdlprefiles " $dir/$old_library"
  7349. # Keep a list of preopened convenience libraries to check
  7350. # that they are being used correctly in the link pass.
  7351. test -z "$libdir" && \
  7352. func_append dlpreconveniencelibs " $dir/$old_library"
  7353. # Otherwise, use the dlname, so that lt_dlopen finds it.
  7354. elif test -n "$dlname"; then
  7355. func_append newdlprefiles " $dir/$dlname"
  7356. else
  7357. func_append newdlprefiles " $dir/$linklib"
  7358. fi
  7359. ;;
  7360. esac
  7361. fi # $pass = dlpreopen
  7362. if test -z "$libdir"; then
  7363. # Link the convenience library
  7364. if test lib = "$linkmode"; then
  7365. deplibs="$dir/$old_library $deplibs"
  7366. elif test prog,link = "$linkmode,$pass"; then
  7367. compile_deplibs="$dir/$old_library $compile_deplibs"
  7368. finalize_deplibs="$dir/$old_library $finalize_deplibs"
  7369. else
  7370. deplibs="$lib $deplibs" # used for prog,scan pass
  7371. fi
  7372. continue
  7373. fi
  7374. if test prog = "$linkmode" && test link != "$pass"; then
  7375. func_append newlib_search_path " $ladir"
  7376. deplibs="$lib $deplibs"
  7377. linkalldeplibs=false
  7378. if test no != "$link_all_deplibs" || test -z "$library_names" ||
  7379. test no = "$build_libtool_libs"; then
  7380. linkalldeplibs=:
  7381. fi
  7382. tmp_libs=
  7383. for deplib in $dependency_libs; do
  7384. case $deplib in
  7385. -L*) func_stripname '-L' '' "$deplib"
  7386. func_resolve_sysroot "$func_stripname_result"
  7387. func_append newlib_search_path " $func_resolve_sysroot_result"
  7388. ;;
  7389. esac
  7390. # Need to link against all dependency_libs?
  7391. if $linkalldeplibs; then
  7392. deplibs="$deplib $deplibs"
  7393. else
  7394. # Need to hardcode shared library paths
  7395. # or/and link against static libraries
  7396. newdependency_libs="$deplib $newdependency_libs"
  7397. fi
  7398. if $opt_preserve_dup_deps; then
  7399. case "$tmp_libs " in
  7400. *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  7401. esac
  7402. fi
  7403. func_append tmp_libs " $deplib"
  7404. done # for deplib
  7405. continue
  7406. fi # $linkmode = prog...
  7407. if test prog,link = "$linkmode,$pass"; then
  7408. if test -n "$library_names" &&
  7409. { { test no = "$prefer_static_libs" ||
  7410. test built,yes = "$prefer_static_libs,$installed"; } ||
  7411. test -z "$old_library"; }; then
  7412. # We need to hardcode the library path
  7413. if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
  7414. # Make sure the rpath contains only unique directories.
  7415. case $temp_rpath: in
  7416. *"$absdir:"*) ;;
  7417. *) func_append temp_rpath "$absdir:" ;;
  7418. esac
  7419. fi
  7420. # Hardcode the library path.
  7421. # Skip directories that are in the system default run-time
  7422. # search path.
  7423. case " $sys_lib_dlsearch_path " in
  7424. *" $absdir "*) ;;
  7425. *)
  7426. case "$compile_rpath " in
  7427. *" $absdir "*) ;;
  7428. *) func_append compile_rpath " $absdir" ;;
  7429. esac
  7430. ;;
  7431. esac
  7432. case " $sys_lib_dlsearch_path " in
  7433. *" $libdir "*) ;;
  7434. *)
  7435. case "$finalize_rpath " in
  7436. *" $libdir "*) ;;
  7437. *) func_append finalize_rpath " $libdir" ;;
  7438. esac
  7439. ;;
  7440. esac
  7441. fi # $linkmode,$pass = prog,link...
  7442. if $alldeplibs &&
  7443. { test pass_all = "$deplibs_check_method" ||
  7444. { test yes = "$build_libtool_libs" &&
  7445. test -n "$library_names"; }; }; then
  7446. # We only need to search for static libraries
  7447. continue
  7448. fi
  7449. fi
  7450. link_static=no # Whether the deplib will be linked statically
  7451. use_static_libs=$prefer_static_libs
  7452. if test built = "$use_static_libs" && test yes = "$installed"; then
  7453. use_static_libs=no
  7454. fi
  7455. if test -n "$library_names" &&
  7456. { test no = "$use_static_libs" || test -z "$old_library"; }; then
  7457. case $host in
  7458. *cygwin* | *mingw* | *cegcc* | *os2*)
  7459. # No point in relinking DLLs because paths are not encoded
  7460. func_append notinst_deplibs " $lib"
  7461. need_relink=no
  7462. ;;
  7463. *)
  7464. if test no = "$installed"; then
  7465. func_append notinst_deplibs " $lib"
  7466. need_relink=yes
  7467. fi
  7468. ;;
  7469. esac
  7470. # This is a shared library
  7471. # Warn about portability, can't link against -module's on some
  7472. # systems (darwin). Don't bleat about dlopened modules though!
  7473. dlopenmodule=
  7474. for dlpremoduletest in $dlprefiles; do
  7475. if test "X$dlpremoduletest" = "X$lib"; then
  7476. dlopenmodule=$dlpremoduletest
  7477. break
  7478. fi
  7479. done
  7480. if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
  7481. echo
  7482. if test prog = "$linkmode"; then
  7483. $ECHO "*** Warning: Linking the executable $output against the loadable module"
  7484. else
  7485. $ECHO "*** Warning: Linking the shared library $output against the loadable module"
  7486. fi
  7487. $ECHO "*** $linklib is not portable!"
  7488. fi
  7489. if test lib = "$linkmode" &&
  7490. test yes = "$hardcode_into_libs"; then
  7491. # Hardcode the library path.
  7492. # Skip directories that are in the system default run-time
  7493. # search path.
  7494. case " $sys_lib_dlsearch_path " in
  7495. *" $absdir "*) ;;
  7496. *)
  7497. case "$compile_rpath " in
  7498. *" $absdir "*) ;;
  7499. *) func_append compile_rpath " $absdir" ;;
  7500. esac
  7501. ;;
  7502. esac
  7503. case " $sys_lib_dlsearch_path " in
  7504. *" $libdir "*) ;;
  7505. *)
  7506. case "$finalize_rpath " in
  7507. *" $libdir "*) ;;
  7508. *) func_append finalize_rpath " $libdir" ;;
  7509. esac
  7510. ;;
  7511. esac
  7512. fi
  7513. if test -n "$old_archive_from_expsyms_cmds"; then
  7514. # figure out the soname
  7515. set dummy $library_names
  7516. shift
  7517. realname=$1
  7518. shift
  7519. libname=`eval "\\$ECHO \"$libname_spec\""`
  7520. # use dlname if we got it. it's perfectly good, no?
  7521. if test -n "$dlname"; then
  7522. soname=$dlname
  7523. elif test -n "$soname_spec"; then
  7524. # bleh windows
  7525. case $host in
  7526. *cygwin* | mingw* | *cegcc* | *os2*)
  7527. func_arith $current - $age
  7528. major=$func_arith_result
  7529. versuffix=-$major
  7530. ;;
  7531. esac
  7532. eval soname=\"$soname_spec\"
  7533. else
  7534. soname=$realname
  7535. fi
  7536. # Make a new name for the extract_expsyms_cmds to use
  7537. soroot=$soname
  7538. func_basename "$soroot"
  7539. soname=$func_basename_result
  7540. func_stripname 'lib' '.dll' "$soname"
  7541. newlib=libimp-$func_stripname_result.a
  7542. # If the library has no export list, then create one now
  7543. if test -f "$output_objdir/$soname-def"; then :
  7544. else
  7545. func_verbose "extracting exported symbol list from '$soname'"
  7546. func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
  7547. fi
  7548. # Create $newlib
  7549. if test -f "$output_objdir/$newlib"; then :; else
  7550. func_verbose "generating import library for '$soname'"
  7551. func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
  7552. fi
  7553. # make sure the library variables are pointing to the new library
  7554. dir=$output_objdir
  7555. linklib=$newlib
  7556. fi # test -n "$old_archive_from_expsyms_cmds"
  7557. if test prog = "$linkmode" || test relink != "$opt_mode"; then
  7558. add_shlibpath=
  7559. add_dir=
  7560. add=
  7561. lib_linked=yes
  7562. case $hardcode_action in
  7563. immediate | unsupported)
  7564. if test no = "$hardcode_direct"; then
  7565. add=$dir/$linklib
  7566. case $host in
  7567. *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
  7568. *-*-sysv4*uw2*) add_dir=-L$dir ;;
  7569. *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
  7570. *-*-unixware7*) add_dir=-L$dir ;;
  7571. *-*-darwin* )
  7572. # if the lib is a (non-dlopened) module then we cannot
  7573. # link against it, someone is ignoring the earlier warnings
  7574. if /usr/bin/file -L $add 2> /dev/null |
  7575. $GREP ": [^:]* bundle" >/dev/null; then
  7576. if test "X$dlopenmodule" != "X$lib"; then
  7577. $ECHO "*** Warning: lib $linklib is a module, not a shared library"
  7578. if test -z "$old_library"; then
  7579. echo
  7580. echo "*** And there doesn't seem to be a static archive available"
  7581. echo "*** The link will probably fail, sorry"
  7582. else
  7583. add=$dir/$old_library
  7584. fi
  7585. elif test -n "$old_library"; then
  7586. add=$dir/$old_library
  7587. fi
  7588. fi
  7589. esac
  7590. elif test no = "$hardcode_minus_L"; then
  7591. case $host in
  7592. *-*-sunos*) add_shlibpath=$dir ;;
  7593. esac
  7594. add_dir=-L$dir
  7595. add=-l$name
  7596. elif test no = "$hardcode_shlibpath_var"; then
  7597. add_shlibpath=$dir
  7598. add=-l$name
  7599. else
  7600. lib_linked=no
  7601. fi
  7602. ;;
  7603. relink)
  7604. if test yes = "$hardcode_direct" &&
  7605. test no = "$hardcode_direct_absolute"; then
  7606. add=$dir/$linklib
  7607. elif test yes = "$hardcode_minus_L"; then
  7608. add_dir=-L$absdir
  7609. # Try looking first in the location we're being installed to.
  7610. if test -n "$inst_prefix_dir"; then
  7611. case $libdir in
  7612. [\\/]*)
  7613. func_append add_dir " -L$inst_prefix_dir$libdir"
  7614. ;;
  7615. esac
  7616. fi
  7617. add=-l$name
  7618. elif test yes = "$hardcode_shlibpath_var"; then
  7619. add_shlibpath=$dir
  7620. add=-l$name
  7621. else
  7622. lib_linked=no
  7623. fi
  7624. ;;
  7625. *) lib_linked=no ;;
  7626. esac
  7627. if test yes != "$lib_linked"; then
  7628. func_fatal_configuration "unsupported hardcode properties"
  7629. fi
  7630. if test -n "$add_shlibpath"; then
  7631. case :$compile_shlibpath: in
  7632. *":$add_shlibpath:"*) ;;
  7633. *) func_append compile_shlibpath "$add_shlibpath:" ;;
  7634. esac
  7635. fi
  7636. if test prog = "$linkmode"; then
  7637. test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
  7638. test -n "$add" && compile_deplibs="$add $compile_deplibs"
  7639. else
  7640. test -n "$add_dir" && deplibs="$add_dir $deplibs"
  7641. test -n "$add" && deplibs="$add $deplibs"
  7642. if test yes != "$hardcode_direct" &&
  7643. test yes != "$hardcode_minus_L" &&
  7644. test yes = "$hardcode_shlibpath_var"; then
  7645. case :$finalize_shlibpath: in
  7646. *":$libdir:"*) ;;
  7647. *) func_append finalize_shlibpath "$libdir:" ;;
  7648. esac
  7649. fi
  7650. fi
  7651. fi
  7652. if test prog = "$linkmode" || test relink = "$opt_mode"; then
  7653. add_shlibpath=
  7654. add_dir=
  7655. add=
  7656. # Finalize command for both is simple: just hardcode it.
  7657. if test yes = "$hardcode_direct" &&
  7658. test no = "$hardcode_direct_absolute"; then
  7659. add=$libdir/$linklib
  7660. elif test yes = "$hardcode_minus_L"; then
  7661. add_dir=-L$libdir
  7662. add=-l$name
  7663. elif test yes = "$hardcode_shlibpath_var"; then
  7664. case :$finalize_shlibpath: in
  7665. *":$libdir:"*) ;;
  7666. *) func_append finalize_shlibpath "$libdir:" ;;
  7667. esac
  7668. add=-l$name
  7669. elif test yes = "$hardcode_automatic"; then
  7670. if test -n "$inst_prefix_dir" &&
  7671. test -f "$inst_prefix_dir$libdir/$linklib"; then
  7672. add=$inst_prefix_dir$libdir/$linklib
  7673. else
  7674. add=$libdir/$linklib
  7675. fi
  7676. else
  7677. # We cannot seem to hardcode it, guess we'll fake it.
  7678. add_dir=-L$libdir
  7679. # Try looking first in the location we're being installed to.
  7680. if test -n "$inst_prefix_dir"; then
  7681. case $libdir in
  7682. [\\/]*)
  7683. func_append add_dir " -L$inst_prefix_dir$libdir"
  7684. ;;
  7685. esac
  7686. fi
  7687. add=-l$name
  7688. fi
  7689. if test prog = "$linkmode"; then
  7690. test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
  7691. test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
  7692. else
  7693. test -n "$add_dir" && deplibs="$add_dir $deplibs"
  7694. test -n "$add" && deplibs="$add $deplibs"
  7695. fi
  7696. fi
  7697. elif test prog = "$linkmode"; then
  7698. # Here we assume that one of hardcode_direct or hardcode_minus_L
  7699. # is not unsupported. This is valid on all known static and
  7700. # shared platforms.
  7701. if test unsupported != "$hardcode_direct"; then
  7702. test -n "$old_library" && linklib=$old_library
  7703. compile_deplibs="$dir/$linklib $compile_deplibs"
  7704. finalize_deplibs="$dir/$linklib $finalize_deplibs"
  7705. else
  7706. compile_deplibs="-l$name -L$dir $compile_deplibs"
  7707. finalize_deplibs="-l$name -L$dir $finalize_deplibs"
  7708. fi
  7709. elif test yes = "$build_libtool_libs"; then
  7710. # Not a shared library
  7711. if test pass_all != "$deplibs_check_method"; then
  7712. # We're trying link a shared library against a static one
  7713. # but the system doesn't support it.
  7714. # Just print a warning and add the library to dependency_libs so
  7715. # that the program can be linked against the static library.
  7716. echo
  7717. $ECHO "*** Warning: This system cannot link to static lib archive $lib."
  7718. echo "*** I have the capability to make that library automatically link in when"
  7719. echo "*** you link to this library. But I can only do this if you have a"
  7720. echo "*** shared version of the library, which you do not appear to have."
  7721. if test yes = "$module"; then
  7722. echo "*** But as you try to build a module library, libtool will still create "
  7723. echo "*** a static module, that should work as long as the dlopening application"
  7724. echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
  7725. if test -z "$global_symbol_pipe"; then
  7726. echo
  7727. echo "*** However, this would only work if libtool was able to extract symbol"
  7728. echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
  7729. echo "*** not find such a program. So, this module is probably useless."
  7730. echo "*** 'nm' from GNU binutils and a full rebuild may help."
  7731. fi
  7732. if test no = "$build_old_libs"; then
  7733. build_libtool_libs=module
  7734. build_old_libs=yes
  7735. else
  7736. build_libtool_libs=no
  7737. fi
  7738. fi
  7739. else
  7740. deplibs="$dir/$old_library $deplibs"
  7741. link_static=yes
  7742. fi
  7743. fi # link shared/static library?
  7744. if test lib = "$linkmode"; then
  7745. if test -n "$dependency_libs" &&
  7746. { test yes != "$hardcode_into_libs" ||
  7747. test yes = "$build_old_libs" ||
  7748. test yes = "$link_static"; }; then
  7749. # Extract -R from dependency_libs
  7750. temp_deplibs=
  7751. for libdir in $dependency_libs; do
  7752. case $libdir in
  7753. -R*) func_stripname '-R' '' "$libdir"
  7754. temp_xrpath=$func_stripname_result
  7755. case " $xrpath " in
  7756. *" $temp_xrpath "*) ;;
  7757. *) func_append xrpath " $temp_xrpath";;
  7758. esac;;
  7759. *) func_append temp_deplibs " $libdir";;
  7760. esac
  7761. done
  7762. dependency_libs=$temp_deplibs
  7763. fi
  7764. func_append newlib_search_path " $absdir"
  7765. # Link against this library
  7766. test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
  7767. # ... and its dependency_libs
  7768. tmp_libs=
  7769. for deplib in $dependency_libs; do
  7770. newdependency_libs="$deplib $newdependency_libs"
  7771. case $deplib in
  7772. -L*) func_stripname '-L' '' "$deplib"
  7773. func_resolve_sysroot "$func_stripname_result";;
  7774. *) func_resolve_sysroot "$deplib" ;;
  7775. esac
  7776. if $opt_preserve_dup_deps; then
  7777. case "$tmp_libs " in
  7778. *" $func_resolve_sysroot_result "*)
  7779. func_append specialdeplibs " $func_resolve_sysroot_result" ;;
  7780. esac
  7781. fi
  7782. func_append tmp_libs " $func_resolve_sysroot_result"
  7783. done
  7784. if test no != "$link_all_deplibs"; then
  7785. # Add the search paths of all dependency libraries
  7786. for deplib in $dependency_libs; do
  7787. path=
  7788. case $deplib in
  7789. -L*) path=$deplib ;;
  7790. *.la)
  7791. func_resolve_sysroot "$deplib"
  7792. deplib=$func_resolve_sysroot_result
  7793. func_dirname "$deplib" "" "."
  7794. dir=$func_dirname_result
  7795. # We need an absolute path.
  7796. case $dir in
  7797. [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
  7798. *)
  7799. absdir=`cd "$dir" && pwd`
  7800. if test -z "$absdir"; then
  7801. func_warning "cannot determine absolute directory name of '$dir'"
  7802. absdir=$dir
  7803. fi
  7804. ;;
  7805. esac
  7806. if $GREP "^installed=no" $deplib > /dev/null; then
  7807. case $host in
  7808. *-*-darwin*)
  7809. depdepl=
  7810. eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
  7811. if test -n "$deplibrary_names"; then
  7812. for tmp in $deplibrary_names; do
  7813. depdepl=$tmp
  7814. done
  7815. if test -f "$absdir/$objdir/$depdepl"; then
  7816. depdepl=$absdir/$objdir/$depdepl
  7817. darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
  7818. if test -z "$darwin_install_name"; then
  7819. darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
  7820. fi
  7821. func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
  7822. func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
  7823. path=
  7824. fi
  7825. fi
  7826. ;;
  7827. *)
  7828. path=-L$absdir/$objdir
  7829. ;;
  7830. esac
  7831. else
  7832. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
  7833. test -z "$libdir" && \
  7834. func_fatal_error "'$deplib' is not a valid libtool archive"
  7835. test "$absdir" != "$libdir" && \
  7836. func_warning "'$deplib' seems to be moved"
  7837. path=-L$absdir
  7838. fi
  7839. ;;
  7840. esac
  7841. case " $deplibs " in
  7842. *" $path "*) ;;
  7843. *) deplibs="$path $deplibs" ;;
  7844. esac
  7845. done
  7846. fi # link_all_deplibs != no
  7847. fi # linkmode = lib
  7848. done # for deplib in $libs
  7849. if test link = "$pass"; then
  7850. if test prog = "$linkmode"; then
  7851. compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
  7852. finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
  7853. else
  7854. compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7855. fi
  7856. fi
  7857. dependency_libs=$newdependency_libs
  7858. if test dlpreopen = "$pass"; then
  7859. # Link the dlpreopened libraries before other libraries
  7860. for deplib in $save_deplibs; do
  7861. deplibs="$deplib $deplibs"
  7862. done
  7863. fi
  7864. if test dlopen != "$pass"; then
  7865. test conv = "$pass" || {
  7866. # Make sure lib_search_path contains only unique directories.
  7867. lib_search_path=
  7868. for dir in $newlib_search_path; do
  7869. case "$lib_search_path " in
  7870. *" $dir "*) ;;
  7871. *) func_append lib_search_path " $dir" ;;
  7872. esac
  7873. done
  7874. newlib_search_path=
  7875. }
  7876. if test prog,link = "$linkmode,$pass"; then
  7877. vars="compile_deplibs finalize_deplibs"
  7878. else
  7879. vars=deplibs
  7880. fi
  7881. for var in $vars dependency_libs; do
  7882. # Add libraries to $var in reverse order
  7883. eval tmp_libs=\"\$$var\"
  7884. new_libs=
  7885. for deplib in $tmp_libs; do
  7886. # FIXME: Pedantically, this is the right thing to do, so
  7887. # that some nasty dependency loop isn't accidentally
  7888. # broken:
  7889. #new_libs="$deplib $new_libs"
  7890. # Pragmatically, this seems to cause very few problems in
  7891. # practice:
  7892. case $deplib in
  7893. -L*) new_libs="$deplib $new_libs" ;;
  7894. -R*) ;;
  7895. *)
  7896. # And here is the reason: when a library appears more
  7897. # than once as an explicit dependence of a library, or
  7898. # is implicitly linked in more than once by the
  7899. # compiler, it is considered special, and multiple
  7900. # occurrences thereof are not removed. Compare this
  7901. # with having the same library being listed as a
  7902. # dependency of multiple other libraries: in this case,
  7903. # we know (pedantically, we assume) the library does not
  7904. # need to be listed more than once, so we keep only the
  7905. # last copy. This is not always right, but it is rare
  7906. # enough that we require users that really mean to play
  7907. # such unportable linking tricks to link the library
  7908. # using -Wl,-lname, so that libtool does not consider it
  7909. # for duplicate removal.
  7910. case " $specialdeplibs " in
  7911. *" $deplib "*) new_libs="$deplib $new_libs" ;;
  7912. *)
  7913. case " $new_libs " in
  7914. *" $deplib "*) ;;
  7915. *) new_libs="$deplib $new_libs" ;;
  7916. esac
  7917. ;;
  7918. esac
  7919. ;;
  7920. esac
  7921. done
  7922. tmp_libs=
  7923. for deplib in $new_libs; do
  7924. case $deplib in
  7925. -L*)
  7926. case " $tmp_libs " in
  7927. *" $deplib "*) ;;
  7928. *) func_append tmp_libs " $deplib" ;;
  7929. esac
  7930. ;;
  7931. *) func_append tmp_libs " $deplib" ;;
  7932. esac
  7933. done
  7934. eval $var=\"$tmp_libs\"
  7935. done # for var
  7936. fi
  7937. # Add Sun CC postdeps if required:
  7938. test CXX = "$tagname" && {
  7939. case $host_os in
  7940. linux*)
  7941. case `$CC -V 2>&1 | sed 5q` in
  7942. *Sun\ C*) # Sun C++ 5.9
  7943. func_suncc_cstd_abi
  7944. if test no != "$suncc_use_cstd_abi"; then
  7945. func_append postdeps ' -library=Cstd -library=Crun'
  7946. fi
  7947. ;;
  7948. esac
  7949. ;;
  7950. solaris*)
  7951. func_cc_basename "$CC"
  7952. case $func_cc_basename_result in
  7953. CC* | sunCC*)
  7954. func_suncc_cstd_abi
  7955. if test no != "$suncc_use_cstd_abi"; then
  7956. func_append postdeps ' -library=Cstd -library=Crun'
  7957. fi
  7958. ;;
  7959. esac
  7960. ;;
  7961. esac
  7962. }
  7963. # Last step: remove runtime libs from dependency_libs
  7964. # (they stay in deplibs)
  7965. tmp_libs=
  7966. for i in $dependency_libs; do
  7967. case " $predeps $postdeps $compiler_lib_search_path " in
  7968. *" $i "*)
  7969. i=
  7970. ;;
  7971. esac
  7972. if test -n "$i"; then
  7973. func_append tmp_libs " $i"
  7974. fi
  7975. done
  7976. dependency_libs=$tmp_libs
  7977. done # for pass
  7978. if test prog = "$linkmode"; then
  7979. dlfiles=$newdlfiles
  7980. fi
  7981. if test prog = "$linkmode" || test lib = "$linkmode"; then
  7982. dlprefiles=$newdlprefiles
  7983. fi
  7984. case $linkmode in
  7985. oldlib)
  7986. if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
  7987. func_warning "'-dlopen' is ignored for archives"
  7988. fi
  7989. case " $deplibs" in
  7990. *\ -l* | *\ -L*)
  7991. func_warning "'-l' and '-L' are ignored for archives" ;;
  7992. esac
  7993. test -n "$rpath" && \
  7994. func_warning "'-rpath' is ignored for archives"
  7995. test -n "$xrpath" && \
  7996. func_warning "'-R' is ignored for archives"
  7997. test -n "$vinfo" && \
  7998. func_warning "'-version-info/-version-number' is ignored for archives"
  7999. test -n "$release" && \
  8000. func_warning "'-release' is ignored for archives"
  8001. test -n "$export_symbols$export_symbols_regex" && \
  8002. func_warning "'-export-symbols' is ignored for archives"
  8003. # Now set the variables for building old libraries.
  8004. build_libtool_libs=no
  8005. oldlibs=$output
  8006. func_append objs "$old_deplibs"
  8007. ;;
  8008. lib)
  8009. # Make sure we only generate libraries of the form 'libNAME.la'.
  8010. case $outputname in
  8011. lib*)
  8012. func_stripname 'lib' '.la' "$outputname"
  8013. name=$func_stripname_result
  8014. eval shared_ext=\"$shrext_cmds\"
  8015. eval libname=\"$libname_spec\"
  8016. ;;
  8017. *)
  8018. test no = "$module" \
  8019. && func_fatal_help "libtool library '$output' must begin with 'lib'"
  8020. if test no != "$need_lib_prefix"; then
  8021. # Add the "lib" prefix for modules if required
  8022. func_stripname '' '.la' "$outputname"
  8023. name=$func_stripname_result
  8024. eval shared_ext=\"$shrext_cmds\"
  8025. eval libname=\"$libname_spec\"
  8026. else
  8027. func_stripname '' '.la' "$outputname"
  8028. libname=$func_stripname_result
  8029. fi
  8030. ;;
  8031. esac
  8032. if test -n "$objs"; then
  8033. if test pass_all != "$deplibs_check_method"; then
  8034. func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
  8035. else
  8036. echo
  8037. $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
  8038. $ECHO "*** objects $objs is not portable!"
  8039. func_append libobjs " $objs"
  8040. fi
  8041. fi
  8042. test no = "$dlself" \
  8043. || func_warning "'-dlopen self' is ignored for libtool libraries"
  8044. set dummy $rpath
  8045. shift
  8046. test 1 -lt "$#" \
  8047. && func_warning "ignoring multiple '-rpath's for a libtool library"
  8048. install_libdir=$1
  8049. oldlibs=
  8050. if test -z "$rpath"; then
  8051. if test yes = "$build_libtool_libs"; then
  8052. # Building a libtool convenience library.
  8053. # Some compilers have problems with a '.al' extension so
  8054. # convenience libraries should have the same extension an
  8055. # archive normally would.
  8056. oldlibs="$output_objdir/$libname.$libext $oldlibs"
  8057. build_libtool_libs=convenience
  8058. build_old_libs=yes
  8059. fi
  8060. test -n "$vinfo" && \
  8061. func_warning "'-version-info/-version-number' is ignored for convenience libraries"
  8062. test -n "$release" && \
  8063. func_warning "'-release' is ignored for convenience libraries"
  8064. else
  8065. # Parse the version information argument.
  8066. save_ifs=$IFS; IFS=:
  8067. set dummy $vinfo 0 0 0
  8068. shift
  8069. IFS=$save_ifs
  8070. test -n "$7" && \
  8071. func_fatal_help "too many parameters to '-version-info'"
  8072. # convert absolute version numbers to libtool ages
  8073. # this retains compatibility with .la files and attempts
  8074. # to make the code below a bit more comprehensible
  8075. case $vinfo_number in
  8076. yes)
  8077. number_major=$1
  8078. number_minor=$2
  8079. number_revision=$3
  8080. #
  8081. # There are really only two kinds -- those that
  8082. # use the current revision as the major version
  8083. # and those that subtract age and use age as
  8084. # a minor version. But, then there is irix
  8085. # that has an extra 1 added just for fun
  8086. #
  8087. case $version_type in
  8088. # correct linux to gnu/linux during the next big refactor
  8089. darwin|freebsd-elf|linux|osf|windows|none)
  8090. func_arith $number_major + $number_minor
  8091. current=$func_arith_result
  8092. age=$number_minor
  8093. revision=$number_revision
  8094. ;;
  8095. freebsd-aout|qnx|sunos)
  8096. current=$number_major
  8097. revision=$number_minor
  8098. age=0
  8099. ;;
  8100. irix|nonstopux)
  8101. func_arith $number_major + $number_minor
  8102. current=$func_arith_result
  8103. age=$number_minor
  8104. revision=$number_minor
  8105. lt_irix_increment=no
  8106. ;;
  8107. esac
  8108. ;;
  8109. no)
  8110. current=$1
  8111. revision=$2
  8112. age=$3
  8113. ;;
  8114. esac
  8115. # Check that each of the things are valid numbers.
  8116. case $current in
  8117. 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
  8118. *)
  8119. func_error "CURRENT '$current' must be a nonnegative integer"
  8120. func_fatal_error "'$vinfo' is not valid version information"
  8121. ;;
  8122. esac
  8123. case $revision in
  8124. 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
  8125. *)
  8126. func_error "REVISION '$revision' must be a nonnegative integer"
  8127. func_fatal_error "'$vinfo' is not valid version information"
  8128. ;;
  8129. esac
  8130. case $age in
  8131. 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
  8132. *)
  8133. func_error "AGE '$age' must be a nonnegative integer"
  8134. func_fatal_error "'$vinfo' is not valid version information"
  8135. ;;
  8136. esac
  8137. if test "$age" -gt "$current"; then
  8138. func_error "AGE '$age' is greater than the current interface number '$current'"
  8139. func_fatal_error "'$vinfo' is not valid version information"
  8140. fi
  8141. # Calculate the version variables.
  8142. major=
  8143. versuffix=
  8144. verstring=
  8145. case $version_type in
  8146. none) ;;
  8147. darwin)
  8148. # Like Linux, but with the current version available in
  8149. # verstring for coding it into the library header
  8150. func_arith $current - $age
  8151. major=.$func_arith_result
  8152. versuffix=$major.$age.$revision
  8153. # Darwin ld doesn't like 0 for these options...
  8154. func_arith $current + 1
  8155. minor_current=$func_arith_result
  8156. xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
  8157. verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
  8158. # On Darwin other compilers
  8159. case $CC in
  8160. nagfor*)
  8161. verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
  8162. ;;
  8163. *)
  8164. verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
  8165. ;;
  8166. esac
  8167. ;;
  8168. freebsd-aout)
  8169. major=.$current
  8170. versuffix=.$current.$revision
  8171. ;;
  8172. freebsd-elf)
  8173. func_arith $current - $age
  8174. major=.$func_arith_result
  8175. versuffix=$major.$age.$revision
  8176. ;;
  8177. irix | nonstopux)
  8178. if test no = "$lt_irix_increment"; then
  8179. func_arith $current - $age
  8180. else
  8181. func_arith $current - $age + 1
  8182. fi
  8183. major=$func_arith_result
  8184. case $version_type in
  8185. nonstopux) verstring_prefix=nonstopux ;;
  8186. *) verstring_prefix=sgi ;;
  8187. esac
  8188. verstring=$verstring_prefix$major.$revision
  8189. # Add in all the interfaces that we are compatible with.
  8190. loop=$revision
  8191. while test 0 -ne "$loop"; do
  8192. func_arith $revision - $loop
  8193. iface=$func_arith_result
  8194. func_arith $loop - 1
  8195. loop=$func_arith_result
  8196. verstring=$verstring_prefix$major.$iface:$verstring
  8197. done
  8198. # Before this point, $major must not contain '.'.
  8199. major=.$major
  8200. versuffix=$major.$revision
  8201. ;;
  8202. linux) # correct to gnu/linux during the next big refactor
  8203. func_arith $current - $age
  8204. major=.$func_arith_result
  8205. versuffix=$major.$age.$revision
  8206. ;;
  8207. osf)
  8208. func_arith $current - $age
  8209. major=.$func_arith_result
  8210. versuffix=.$current.$age.$revision
  8211. verstring=$current.$age.$revision
  8212. # Add in all the interfaces that we are compatible with.
  8213. loop=$age
  8214. while test 0 -ne "$loop"; do
  8215. func_arith $current - $loop
  8216. iface=$func_arith_result
  8217. func_arith $loop - 1
  8218. loop=$func_arith_result
  8219. verstring=$verstring:$iface.0
  8220. done
  8221. # Make executables depend on our current version.
  8222. func_append verstring ":$current.0"
  8223. ;;
  8224. qnx)
  8225. major=.$current
  8226. versuffix=.$current
  8227. ;;
  8228. sco)
  8229. major=.$current
  8230. versuffix=.$current
  8231. ;;
  8232. sunos)
  8233. major=.$current
  8234. versuffix=.$current.$revision
  8235. ;;
  8236. windows)
  8237. # Use '-' rather than '.', since we only want one
  8238. # extension on DOS 8.3 file systems.
  8239. func_arith $current - $age
  8240. major=$func_arith_result
  8241. versuffix=-$major
  8242. ;;
  8243. *)
  8244. func_fatal_configuration "unknown library version type '$version_type'"
  8245. ;;
  8246. esac
  8247. # Clear the version info if we defaulted, and they specified a release.
  8248. if test -z "$vinfo" && test -n "$release"; then
  8249. major=
  8250. case $version_type in
  8251. darwin)
  8252. # we can't check for "0.0" in archive_cmds due to quoting
  8253. # problems, so we reset it completely
  8254. verstring=
  8255. ;;
  8256. *)
  8257. verstring=0.0
  8258. ;;
  8259. esac
  8260. if test no = "$need_version"; then
  8261. versuffix=
  8262. else
  8263. versuffix=.0.0
  8264. fi
  8265. fi
  8266. # Remove version info from name if versioning should be avoided
  8267. if test yes,no = "$avoid_version,$need_version"; then
  8268. major=
  8269. versuffix=
  8270. verstring=
  8271. fi
  8272. # Check to see if the archive will have undefined symbols.
  8273. if test yes = "$allow_undefined"; then
  8274. if test unsupported = "$allow_undefined_flag"; then
  8275. if test yes = "$build_old_libs"; then
  8276. func_warning "undefined symbols not allowed in $host shared libraries; building static only"
  8277. build_libtool_libs=no
  8278. else
  8279. func_fatal_error "can't build $host shared library unless -no-undefined is specified"
  8280. fi
  8281. fi
  8282. else
  8283. # Don't allow undefined symbols.
  8284. allow_undefined_flag=$no_undefined_flag
  8285. fi
  8286. fi
  8287. func_generate_dlsyms "$libname" "$libname" :
  8288. func_append libobjs " $symfileobj"
  8289. test " " = "$libobjs" && libobjs=
  8290. if test relink != "$opt_mode"; then
  8291. # Remove our outputs, but don't remove object files since they
  8292. # may have been created when compiling PIC objects.
  8293. removelist=
  8294. tempremovelist=`$ECHO "$output_objdir/*"`
  8295. for p in $tempremovelist; do
  8296. case $p in
  8297. *.$objext | *.gcno)
  8298. ;;
  8299. $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
  8300. if test -n "$precious_files_regex"; then
  8301. if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
  8302. then
  8303. continue
  8304. fi
  8305. fi
  8306. func_append removelist " $p"
  8307. ;;
  8308. *) ;;
  8309. esac
  8310. done
  8311. test -n "$removelist" && \
  8312. func_show_eval "${RM}r \$removelist"
  8313. fi
  8314. # Now set the variables for building old libraries.
  8315. if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
  8316. func_append oldlibs " $output_objdir/$libname.$libext"
  8317. # Transform .lo files to .o files.
  8318. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
  8319. fi
  8320. # Eliminate all temporary directories.
  8321. #for path in $notinst_path; do
  8322. # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
  8323. # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
  8324. # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
  8325. #done
  8326. if test -n "$xrpath"; then
  8327. # If the user specified any rpath flags, then add them.
  8328. temp_xrpath=
  8329. for libdir in $xrpath; do
  8330. func_replace_sysroot "$libdir"
  8331. func_append temp_xrpath " -R$func_replace_sysroot_result"
  8332. case "$finalize_rpath " in
  8333. *" $libdir "*) ;;
  8334. *) func_append finalize_rpath " $libdir" ;;
  8335. esac
  8336. done
  8337. if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
  8338. dependency_libs="$temp_xrpath $dependency_libs"
  8339. fi
  8340. fi
  8341. # Make sure dlfiles contains only unique files that won't be dlpreopened
  8342. old_dlfiles=$dlfiles
  8343. dlfiles=
  8344. for lib in $old_dlfiles; do
  8345. case " $dlprefiles $dlfiles " in
  8346. *" $lib "*) ;;
  8347. *) func_append dlfiles " $lib" ;;
  8348. esac
  8349. done
  8350. # Make sure dlprefiles contains only unique files
  8351. old_dlprefiles=$dlprefiles
  8352. dlprefiles=
  8353. for lib in $old_dlprefiles; do
  8354. case "$dlprefiles " in
  8355. *" $lib "*) ;;
  8356. *) func_append dlprefiles " $lib" ;;
  8357. esac
  8358. done
  8359. if test yes = "$build_libtool_libs"; then
  8360. if test -n "$rpath"; then
  8361. case $host in
  8362. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
  8363. # these systems don't actually have a c library (as such)!
  8364. ;;
  8365. *-*-rhapsody* | *-*-darwin1.[012])
  8366. # Rhapsody C library is in the System framework
  8367. func_append deplibs " System.ltframework"
  8368. ;;
  8369. *-*-netbsd*)
  8370. # Don't link with libc until the a.out ld.so is fixed.
  8371. ;;
  8372. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
  8373. # Do not include libc due to us having libc/libc_r.
  8374. ;;
  8375. *-*-sco3.2v5* | *-*-sco5v6*)
  8376. # Causes problems with __ctype
  8377. ;;
  8378. *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
  8379. # Compiler inserts libc in the correct place for threads to work
  8380. ;;
  8381. *)
  8382. # Add libc to deplibs on all other systems if necessary.
  8383. if test yes = "$build_libtool_need_lc"; then
  8384. func_append deplibs " -lc"
  8385. fi
  8386. ;;
  8387. esac
  8388. fi
  8389. # Transform deplibs into only deplibs that can be linked in shared.
  8390. name_save=$name
  8391. libname_save=$libname
  8392. release_save=$release
  8393. versuffix_save=$versuffix
  8394. major_save=$major
  8395. # I'm not sure if I'm treating the release correctly. I think
  8396. # release should show up in the -l (ie -lgmp5) so we don't want to
  8397. # add it in twice. Is that correct?
  8398. release=
  8399. versuffix=
  8400. major=
  8401. newdeplibs=
  8402. droppeddeps=no
  8403. case $deplibs_check_method in
  8404. pass_all)
  8405. # Don't check for shared/static. Everything works.
  8406. # This might be a little naive. We might want to check
  8407. # whether the library exists or not. But this is on
  8408. # osf3 & osf4 and I'm not really sure... Just
  8409. # implementing what was already the behavior.
  8410. newdeplibs=$deplibs
  8411. ;;
  8412. test_compile)
  8413. # This code stresses the "libraries are programs" paradigm to its
  8414. # limits. Maybe even breaks it. We compile a program, linking it
  8415. # against the deplibs as a proxy for the library. Then we can check
  8416. # whether they linked in statically or dynamically with ldd.
  8417. $opt_dry_run || $RM conftest.c
  8418. cat > conftest.c <<EOF
  8419. int main() { return 0; }
  8420. EOF
  8421. $opt_dry_run || $RM conftest
  8422. if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
  8423. ldd_output=`ldd conftest`
  8424. for i in $deplibs; do
  8425. case $i in
  8426. -l*)
  8427. func_stripname -l '' "$i"
  8428. name=$func_stripname_result
  8429. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8430. case " $predeps $postdeps " in
  8431. *" $i "*)
  8432. func_append newdeplibs " $i"
  8433. i=
  8434. ;;
  8435. esac
  8436. fi
  8437. if test -n "$i"; then
  8438. libname=`eval "\\$ECHO \"$libname_spec\""`
  8439. deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
  8440. set dummy $deplib_matches; shift
  8441. deplib_match=$1
  8442. if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
  8443. func_append newdeplibs " $i"
  8444. else
  8445. droppeddeps=yes
  8446. echo
  8447. $ECHO "*** Warning: dynamic linker does not accept needed library $i."
  8448. echo "*** I have the capability to make that library automatically link in when"
  8449. echo "*** you link to this library. But I can only do this if you have a"
  8450. echo "*** shared version of the library, which I believe you do not have"
  8451. echo "*** because a test_compile did reveal that the linker did not use it for"
  8452. echo "*** its dynamic dependency list that programs get resolved with at runtime."
  8453. fi
  8454. fi
  8455. ;;
  8456. *)
  8457. func_append newdeplibs " $i"
  8458. ;;
  8459. esac
  8460. done
  8461. else
  8462. # Error occurred in the first compile. Let's try to salvage
  8463. # the situation: Compile a separate program for each library.
  8464. for i in $deplibs; do
  8465. case $i in
  8466. -l*)
  8467. func_stripname -l '' "$i"
  8468. name=$func_stripname_result
  8469. $opt_dry_run || $RM conftest
  8470. if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
  8471. ldd_output=`ldd conftest`
  8472. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8473. case " $predeps $postdeps " in
  8474. *" $i "*)
  8475. func_append newdeplibs " $i"
  8476. i=
  8477. ;;
  8478. esac
  8479. fi
  8480. if test -n "$i"; then
  8481. libname=`eval "\\$ECHO \"$libname_spec\""`
  8482. deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
  8483. set dummy $deplib_matches; shift
  8484. deplib_match=$1
  8485. if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
  8486. func_append newdeplibs " $i"
  8487. else
  8488. droppeddeps=yes
  8489. echo
  8490. $ECHO "*** Warning: dynamic linker does not accept needed library $i."
  8491. echo "*** I have the capability to make that library automatically link in when"
  8492. echo "*** you link to this library. But I can only do this if you have a"
  8493. echo "*** shared version of the library, which you do not appear to have"
  8494. echo "*** because a test_compile did reveal that the linker did not use this one"
  8495. echo "*** as a dynamic dependency that programs can get resolved with at runtime."
  8496. fi
  8497. fi
  8498. else
  8499. droppeddeps=yes
  8500. echo
  8501. $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
  8502. echo "*** make it link in! You will probably need to install it or some"
  8503. echo "*** library that it depends on before this library will be fully"
  8504. echo "*** functional. Installing it before continuing would be even better."
  8505. fi
  8506. ;;
  8507. *)
  8508. func_append newdeplibs " $i"
  8509. ;;
  8510. esac
  8511. done
  8512. fi
  8513. ;;
  8514. file_magic*)
  8515. set dummy $deplibs_check_method; shift
  8516. file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  8517. for a_deplib in $deplibs; do
  8518. case $a_deplib in
  8519. -l*)
  8520. func_stripname -l '' "$a_deplib"
  8521. name=$func_stripname_result
  8522. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8523. case " $predeps $postdeps " in
  8524. *" $a_deplib "*)
  8525. func_append newdeplibs " $a_deplib"
  8526. a_deplib=
  8527. ;;
  8528. esac
  8529. fi
  8530. if test -n "$a_deplib"; then
  8531. libname=`eval "\\$ECHO \"$libname_spec\""`
  8532. if test -n "$file_magic_glob"; then
  8533. libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
  8534. else
  8535. libnameglob=$libname
  8536. fi
  8537. test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
  8538. for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
  8539. if test yes = "$want_nocaseglob"; then
  8540. shopt -s nocaseglob
  8541. potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
  8542. $nocaseglob
  8543. else
  8544. potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
  8545. fi
  8546. for potent_lib in $potential_libs; do
  8547. # Follow soft links.
  8548. if ls -lLd "$potent_lib" 2>/dev/null |
  8549. $GREP " -> " >/dev/null; then
  8550. continue
  8551. fi
  8552. # The statement above tries to avoid entering an
  8553. # endless loop below, in case of cyclic links.
  8554. # We might still enter an endless loop, since a link
  8555. # loop can be closed while we follow links,
  8556. # but so what?
  8557. potlib=$potent_lib
  8558. while test -h "$potlib" 2>/dev/null; do
  8559. potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
  8560. case $potliblink in
  8561. [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
  8562. *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
  8563. esac
  8564. done
  8565. if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
  8566. $SED -e 10q |
  8567. $EGREP "$file_magic_regex" > /dev/null; then
  8568. func_append newdeplibs " $a_deplib"
  8569. a_deplib=
  8570. break 2
  8571. fi
  8572. done
  8573. done
  8574. fi
  8575. if test -n "$a_deplib"; then
  8576. droppeddeps=yes
  8577. echo
  8578. $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
  8579. echo "*** I have the capability to make that library automatically link in when"
  8580. echo "*** you link to this library. But I can only do this if you have a"
  8581. echo "*** shared version of the library, which you do not appear to have"
  8582. echo "*** because I did check the linker path looking for a file starting"
  8583. if test -z "$potlib"; then
  8584. $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
  8585. else
  8586. $ECHO "*** with $libname and none of the candidates passed a file format test"
  8587. $ECHO "*** using a file magic. Last file checked: $potlib"
  8588. fi
  8589. fi
  8590. ;;
  8591. *)
  8592. # Add a -L argument.
  8593. func_append newdeplibs " $a_deplib"
  8594. ;;
  8595. esac
  8596. done # Gone through all deplibs.
  8597. ;;
  8598. match_pattern*)
  8599. set dummy $deplibs_check_method; shift
  8600. match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  8601. for a_deplib in $deplibs; do
  8602. case $a_deplib in
  8603. -l*)
  8604. func_stripname -l '' "$a_deplib"
  8605. name=$func_stripname_result
  8606. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8607. case " $predeps $postdeps " in
  8608. *" $a_deplib "*)
  8609. func_append newdeplibs " $a_deplib"
  8610. a_deplib=
  8611. ;;
  8612. esac
  8613. fi
  8614. if test -n "$a_deplib"; then
  8615. libname=`eval "\\$ECHO \"$libname_spec\""`
  8616. for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
  8617. potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
  8618. for potent_lib in $potential_libs; do
  8619. potlib=$potent_lib # see symlink-check above in file_magic test
  8620. if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
  8621. $EGREP "$match_pattern_regex" > /dev/null; then
  8622. func_append newdeplibs " $a_deplib"
  8623. a_deplib=
  8624. break 2
  8625. fi
  8626. done
  8627. done
  8628. fi
  8629. if test -n "$a_deplib"; then
  8630. droppeddeps=yes
  8631. echo
  8632. $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
  8633. echo "*** I have the capability to make that library automatically link in when"
  8634. echo "*** you link to this library. But I can only do this if you have a"
  8635. echo "*** shared version of the library, which you do not appear to have"
  8636. echo "*** because I did check the linker path looking for a file starting"
  8637. if test -z "$potlib"; then
  8638. $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
  8639. else
  8640. $ECHO "*** with $libname and none of the candidates passed a file format test"
  8641. $ECHO "*** using a regex pattern. Last file checked: $potlib"
  8642. fi
  8643. fi
  8644. ;;
  8645. *)
  8646. # Add a -L argument.
  8647. func_append newdeplibs " $a_deplib"
  8648. ;;
  8649. esac
  8650. done # Gone through all deplibs.
  8651. ;;
  8652. none | unknown | *)
  8653. newdeplibs=
  8654. tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
  8655. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8656. for i in $predeps $postdeps; do
  8657. # can't use Xsed below, because $i might contain '/'
  8658. tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
  8659. done
  8660. fi
  8661. case $tmp_deplibs in
  8662. *[!\ \ ]*)
  8663. echo
  8664. if test none = "$deplibs_check_method"; then
  8665. echo "*** Warning: inter-library dependencies are not supported in this platform."
  8666. else
  8667. echo "*** Warning: inter-library dependencies are not known to be supported."
  8668. fi
  8669. echo "*** All declared inter-library dependencies are being dropped."
  8670. droppeddeps=yes
  8671. ;;
  8672. esac
  8673. ;;
  8674. esac
  8675. versuffix=$versuffix_save
  8676. major=$major_save
  8677. release=$release_save
  8678. libname=$libname_save
  8679. name=$name_save
  8680. case $host in
  8681. *-*-rhapsody* | *-*-darwin1.[012])
  8682. # On Rhapsody replace the C library with the System framework
  8683. newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
  8684. ;;
  8685. esac
  8686. if test yes = "$droppeddeps"; then
  8687. if test yes = "$module"; then
  8688. echo
  8689. echo "*** Warning: libtool could not satisfy all declared inter-library"
  8690. $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
  8691. echo "*** a static module, that should work as long as the dlopening"
  8692. echo "*** application is linked with the -dlopen flag."
  8693. if test -z "$global_symbol_pipe"; then
  8694. echo
  8695. echo "*** However, this would only work if libtool was able to extract symbol"
  8696. echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
  8697. echo "*** not find such a program. So, this module is probably useless."
  8698. echo "*** 'nm' from GNU binutils and a full rebuild may help."
  8699. fi
  8700. if test no = "$build_old_libs"; then
  8701. oldlibs=$output_objdir/$libname.$libext
  8702. build_libtool_libs=module
  8703. build_old_libs=yes
  8704. else
  8705. build_libtool_libs=no
  8706. fi
  8707. else
  8708. echo "*** The inter-library dependencies that have been dropped here will be"
  8709. echo "*** automatically added whenever a program is linked with this library"
  8710. echo "*** or is declared to -dlopen it."
  8711. if test no = "$allow_undefined"; then
  8712. echo
  8713. echo "*** Since this library must not contain undefined symbols,"
  8714. echo "*** because either the platform does not support them or"
  8715. echo "*** it was explicitly requested with -no-undefined,"
  8716. echo "*** libtool will only create a static version of it."
  8717. if test no = "$build_old_libs"; then
  8718. oldlibs=$output_objdir/$libname.$libext
  8719. build_libtool_libs=module
  8720. build_old_libs=yes
  8721. else
  8722. build_libtool_libs=no
  8723. fi
  8724. fi
  8725. fi
  8726. fi
  8727. # Done checking deplibs!
  8728. deplibs=$newdeplibs
  8729. fi
  8730. # Time to change all our "foo.ltframework" stuff back to "-framework foo"
  8731. case $host in
  8732. *-*-darwin*)
  8733. newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8734. new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8735. deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8736. ;;
  8737. esac
  8738. # move library search paths that coincide with paths to not yet
  8739. # installed libraries to the beginning of the library search list
  8740. new_libs=
  8741. for path in $notinst_path; do
  8742. case " $new_libs " in
  8743. *" -L$path/$objdir "*) ;;
  8744. *)
  8745. case " $deplibs " in
  8746. *" -L$path/$objdir "*)
  8747. func_append new_libs " -L$path/$objdir" ;;
  8748. esac
  8749. ;;
  8750. esac
  8751. done
  8752. for deplib in $deplibs; do
  8753. case $deplib in
  8754. -L*)
  8755. case " $new_libs " in
  8756. *" $deplib "*) ;;
  8757. *) func_append new_libs " $deplib" ;;
  8758. esac
  8759. ;;
  8760. *) func_append new_libs " $deplib" ;;
  8761. esac
  8762. done
  8763. deplibs=$new_libs
  8764. # All the library-specific variables (install_libdir is set above).
  8765. library_names=
  8766. old_library=
  8767. dlname=
  8768. # Test again, we may have decided not to build it any more
  8769. if test yes = "$build_libtool_libs"; then
  8770. # Remove $wl instances when linking with ld.
  8771. # FIXME: should test the right _cmds variable.
  8772. case $archive_cmds in
  8773. *\$LD\ *) wl= ;;
  8774. esac
  8775. if test yes = "$hardcode_into_libs"; then
  8776. # Hardcode the library paths
  8777. hardcode_libdirs=
  8778. dep_rpath=
  8779. rpath=$finalize_rpath
  8780. test relink = "$opt_mode" || rpath=$compile_rpath$rpath
  8781. for libdir in $rpath; do
  8782. if test -n "$hardcode_libdir_flag_spec"; then
  8783. if test -n "$hardcode_libdir_separator"; then
  8784. func_replace_sysroot "$libdir"
  8785. libdir=$func_replace_sysroot_result
  8786. if test -z "$hardcode_libdirs"; then
  8787. hardcode_libdirs=$libdir
  8788. else
  8789. # Just accumulate the unique libdirs.
  8790. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  8791. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  8792. ;;
  8793. *)
  8794. func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  8795. ;;
  8796. esac
  8797. fi
  8798. else
  8799. eval flag=\"$hardcode_libdir_flag_spec\"
  8800. func_append dep_rpath " $flag"
  8801. fi
  8802. elif test -n "$runpath_var"; then
  8803. case "$perm_rpath " in
  8804. *" $libdir "*) ;;
  8805. *) func_append perm_rpath " $libdir" ;;
  8806. esac
  8807. fi
  8808. done
  8809. # Substitute the hardcoded libdirs into the rpath.
  8810. if test -n "$hardcode_libdir_separator" &&
  8811. test -n "$hardcode_libdirs"; then
  8812. libdir=$hardcode_libdirs
  8813. eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
  8814. fi
  8815. if test -n "$runpath_var" && test -n "$perm_rpath"; then
  8816. # We should set the runpath_var.
  8817. rpath=
  8818. for dir in $perm_rpath; do
  8819. func_append rpath "$dir:"
  8820. done
  8821. eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
  8822. fi
  8823. test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
  8824. fi
  8825. shlibpath=$finalize_shlibpath
  8826. test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
  8827. if test -n "$shlibpath"; then
  8828. eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
  8829. fi
  8830. # Get the real and link names of the library.
  8831. eval shared_ext=\"$shrext_cmds\"
  8832. eval library_names=\"$library_names_spec\"
  8833. set dummy $library_names
  8834. shift
  8835. realname=$1
  8836. shift
  8837. if test -n "$soname_spec"; then
  8838. eval soname=\"$soname_spec\"
  8839. else
  8840. soname=$realname
  8841. fi
  8842. if test -z "$dlname"; then
  8843. dlname=$soname
  8844. fi
  8845. lib=$output_objdir/$realname
  8846. linknames=
  8847. for link
  8848. do
  8849. func_append linknames " $link"
  8850. done
  8851. # Use standard objects if they are pic
  8852. test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
  8853. test "X$libobjs" = "X " && libobjs=
  8854. delfiles=
  8855. if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8856. $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
  8857. export_symbols=$output_objdir/$libname.uexp
  8858. func_append delfiles " $export_symbols"
  8859. fi
  8860. orig_export_symbols=
  8861. case $host_os in
  8862. cygwin* | mingw* | cegcc*)
  8863. if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
  8864. # exporting using user supplied symfile
  8865. func_dll_def_p "$export_symbols" || {
  8866. # and it's NOT already a .def file. Must figure out
  8867. # which of the given symbols are data symbols and tag
  8868. # them as such. So, trigger use of export_symbols_cmds.
  8869. # export_symbols gets reassigned inside the "prepare
  8870. # the list of exported symbols" if statement, so the
  8871. # include_expsyms logic still works.
  8872. orig_export_symbols=$export_symbols
  8873. export_symbols=
  8874. always_export_symbols=yes
  8875. }
  8876. fi
  8877. ;;
  8878. esac
  8879. # Prepare the list of exported symbols
  8880. if test -z "$export_symbols"; then
  8881. if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
  8882. func_verbose "generating symbol list for '$libname.la'"
  8883. export_symbols=$output_objdir/$libname.exp
  8884. $opt_dry_run || $RM $export_symbols
  8885. cmds=$export_symbols_cmds
  8886. save_ifs=$IFS; IFS='~'
  8887. for cmd1 in $cmds; do
  8888. IFS=$save_ifs
  8889. # Take the normal branch if the nm_file_list_spec branch
  8890. # doesn't work or if tool conversion is not needed.
  8891. case $nm_file_list_spec~$to_tool_file_cmd in
  8892. *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
  8893. try_normal_branch=yes
  8894. eval cmd=\"$cmd1\"
  8895. func_len " $cmd"
  8896. len=$func_len_result
  8897. ;;
  8898. *)
  8899. try_normal_branch=no
  8900. ;;
  8901. esac
  8902. if test yes = "$try_normal_branch" \
  8903. && { test "$len" -lt "$max_cmd_len" \
  8904. || test "$max_cmd_len" -le -1; }
  8905. then
  8906. func_show_eval "$cmd" 'exit $?'
  8907. skipped_export=false
  8908. elif test -n "$nm_file_list_spec"; then
  8909. func_basename "$output"
  8910. output_la=$func_basename_result
  8911. save_libobjs=$libobjs
  8912. save_output=$output
  8913. output=$output_objdir/$output_la.nm
  8914. func_to_tool_file "$output"
  8915. libobjs=$nm_file_list_spec$func_to_tool_file_result
  8916. func_append delfiles " $output"
  8917. func_verbose "creating $NM input file list: $output"
  8918. for obj in $save_libobjs; do
  8919. func_to_tool_file "$obj"
  8920. $ECHO "$func_to_tool_file_result"
  8921. done > "$output"
  8922. eval cmd=\"$cmd1\"
  8923. func_show_eval "$cmd" 'exit $?'
  8924. output=$save_output
  8925. libobjs=$save_libobjs
  8926. skipped_export=false
  8927. else
  8928. # The command line is too long to execute in one step.
  8929. func_verbose "using reloadable object file for export list..."
  8930. skipped_export=:
  8931. # Break out early, otherwise skipped_export may be
  8932. # set to false by a later but shorter cmd.
  8933. break
  8934. fi
  8935. done
  8936. IFS=$save_ifs
  8937. if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
  8938. func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
  8939. func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
  8940. fi
  8941. fi
  8942. fi
  8943. if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8944. tmp_export_symbols=$export_symbols
  8945. test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
  8946. $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
  8947. fi
  8948. if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
  8949. # The given exports_symbols file has to be filtered, so filter it.
  8950. func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
  8951. # FIXME: $output_objdir/$libname.filter potentially contains lots of
  8952. # 's' commands, which not all seds can handle. GNU sed should be fine
  8953. # though. Also, the filter scales superlinearly with the number of
  8954. # global variables. join(1) would be nice here, but unfortunately
  8955. # isn't a blessed tool.
  8956. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
  8957. func_append delfiles " $export_symbols $output_objdir/$libname.filter"
  8958. export_symbols=$output_objdir/$libname.def
  8959. $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
  8960. fi
  8961. tmp_deplibs=
  8962. for test_deplib in $deplibs; do
  8963. case " $convenience " in
  8964. *" $test_deplib "*) ;;
  8965. *)
  8966. func_append tmp_deplibs " $test_deplib"
  8967. ;;
  8968. esac
  8969. done
  8970. deplibs=$tmp_deplibs
  8971. if test -n "$convenience"; then
  8972. if test -n "$whole_archive_flag_spec" &&
  8973. test yes = "$compiler_needs_object" &&
  8974. test -z "$libobjs"; then
  8975. # extract the archives, so we have objects to list.
  8976. # TODO: could optimize this to just extract one archive.
  8977. whole_archive_flag_spec=
  8978. fi
  8979. if test -n "$whole_archive_flag_spec"; then
  8980. save_libobjs=$libobjs
  8981. eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
  8982. test "X$libobjs" = "X " && libobjs=
  8983. else
  8984. gentop=$output_objdir/${outputname}x
  8985. func_append generated " $gentop"
  8986. func_extract_archives $gentop $convenience
  8987. func_append libobjs " $func_extract_archives_result"
  8988. test "X$libobjs" = "X " && libobjs=
  8989. fi
  8990. fi
  8991. if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
  8992. eval flag=\"$thread_safe_flag_spec\"
  8993. func_append linker_flags " $flag"
  8994. fi
  8995. # Make a backup of the uninstalled library when relinking
  8996. if test relink = "$opt_mode"; then
  8997. $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
  8998. fi
  8999. # Do each of the archive commands.
  9000. if test yes = "$module" && test -n "$module_cmds"; then
  9001. if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
  9002. eval test_cmds=\"$module_expsym_cmds\"
  9003. cmds=$module_expsym_cmds
  9004. else
  9005. eval test_cmds=\"$module_cmds\"
  9006. cmds=$module_cmds
  9007. fi
  9008. else
  9009. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
  9010. eval test_cmds=\"$archive_expsym_cmds\"
  9011. cmds=$archive_expsym_cmds
  9012. else
  9013. eval test_cmds=\"$archive_cmds\"
  9014. cmds=$archive_cmds
  9015. fi
  9016. fi
  9017. if test : != "$skipped_export" &&
  9018. func_len " $test_cmds" &&
  9019. len=$func_len_result &&
  9020. test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
  9021. :
  9022. else
  9023. # The command line is too long to link in one step, link piecewise
  9024. # or, if using GNU ld and skipped_export is not :, use a linker
  9025. # script.
  9026. # Save the value of $output and $libobjs because we want to
  9027. # use them later. If we have whole_archive_flag_spec, we
  9028. # want to use save_libobjs as it was before
  9029. # whole_archive_flag_spec was expanded, because we can't
  9030. # assume the linker understands whole_archive_flag_spec.
  9031. # This may have to be revisited, in case too many
  9032. # convenience libraries get linked in and end up exceeding
  9033. # the spec.
  9034. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
  9035. save_libobjs=$libobjs
  9036. fi
  9037. save_output=$output
  9038. func_basename "$output"
  9039. output_la=$func_basename_result
  9040. # Clear the reloadable object creation command queue and
  9041. # initialize k to one.
  9042. test_cmds=
  9043. concat_cmds=
  9044. objlist=
  9045. last_robj=
  9046. k=1
  9047. if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
  9048. output=$output_objdir/$output_la.lnkscript
  9049. func_verbose "creating GNU ld script: $output"
  9050. echo 'INPUT (' > $output
  9051. for obj in $save_libobjs
  9052. do
  9053. func_to_tool_file "$obj"
  9054. $ECHO "$func_to_tool_file_result" >> $output
  9055. done
  9056. echo ')' >> $output
  9057. func_append delfiles " $output"
  9058. func_to_tool_file "$output"
  9059. output=$func_to_tool_file_result
  9060. elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
  9061. output=$output_objdir/$output_la.lnk
  9062. func_verbose "creating linker input file list: $output"
  9063. : > $output
  9064. set x $save_libobjs
  9065. shift
  9066. firstobj=
  9067. if test yes = "$compiler_needs_object"; then
  9068. firstobj="$1 "
  9069. shift
  9070. fi
  9071. for obj
  9072. do
  9073. func_to_tool_file "$obj"
  9074. $ECHO "$func_to_tool_file_result" >> $output
  9075. done
  9076. func_append delfiles " $output"
  9077. func_to_tool_file "$output"
  9078. output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
  9079. else
  9080. if test -n "$save_libobjs"; then
  9081. func_verbose "creating reloadable object files..."
  9082. output=$output_objdir/$output_la-$k.$objext
  9083. eval test_cmds=\"$reload_cmds\"
  9084. func_len " $test_cmds"
  9085. len0=$func_len_result
  9086. len=$len0
  9087. # Loop over the list of objects to be linked.
  9088. for obj in $save_libobjs
  9089. do
  9090. func_len " $obj"
  9091. func_arith $len + $func_len_result
  9092. len=$func_arith_result
  9093. if test -z "$objlist" ||
  9094. test "$len" -lt "$max_cmd_len"; then
  9095. func_append objlist " $obj"
  9096. else
  9097. # The command $test_cmds is almost too long, add a
  9098. # command to the queue.
  9099. if test 1 -eq "$k"; then
  9100. # The first file doesn't have a previous command to add.
  9101. reload_objs=$objlist
  9102. eval concat_cmds=\"$reload_cmds\"
  9103. else
  9104. # All subsequent reloadable object files will link in
  9105. # the last one created.
  9106. reload_objs="$objlist $last_robj"
  9107. eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
  9108. fi
  9109. last_robj=$output_objdir/$output_la-$k.$objext
  9110. func_arith $k + 1
  9111. k=$func_arith_result
  9112. output=$output_objdir/$output_la-$k.$objext
  9113. objlist=" $obj"
  9114. func_len " $last_robj"
  9115. func_arith $len0 + $func_len_result
  9116. len=$func_arith_result
  9117. fi
  9118. done
  9119. # Handle the remaining objects by creating one last
  9120. # reloadable object file. All subsequent reloadable object
  9121. # files will link in the last one created.
  9122. test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  9123. reload_objs="$objlist $last_robj"
  9124. eval concat_cmds=\"\$concat_cmds$reload_cmds\"
  9125. if test -n "$last_robj"; then
  9126. eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
  9127. fi
  9128. func_append delfiles " $output"
  9129. else
  9130. output=
  9131. fi
  9132. ${skipped_export-false} && {
  9133. func_verbose "generating symbol list for '$libname.la'"
  9134. export_symbols=$output_objdir/$libname.exp
  9135. $opt_dry_run || $RM $export_symbols
  9136. libobjs=$output
  9137. # Append the command to create the export file.
  9138. test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  9139. eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
  9140. if test -n "$last_robj"; then
  9141. eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
  9142. fi
  9143. }
  9144. test -n "$save_libobjs" &&
  9145. func_verbose "creating a temporary reloadable object file: $output"
  9146. # Loop through the commands generated above and execute them.
  9147. save_ifs=$IFS; IFS='~'
  9148. for cmd in $concat_cmds; do
  9149. IFS=$save_ifs
  9150. $opt_quiet || {
  9151. func_quote_for_expand "$cmd"
  9152. eval "func_echo $func_quote_for_expand_result"
  9153. }
  9154. $opt_dry_run || eval "$cmd" || {
  9155. lt_exit=$?
  9156. # Restore the uninstalled library and exit
  9157. if test relink = "$opt_mode"; then
  9158. ( cd "$output_objdir" && \
  9159. $RM "${realname}T" && \
  9160. $MV "${realname}U" "$realname" )
  9161. fi
  9162. exit $lt_exit
  9163. }
  9164. done
  9165. IFS=$save_ifs
  9166. if test -n "$export_symbols_regex" && ${skipped_export-false}; then
  9167. func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
  9168. func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
  9169. fi
  9170. fi
  9171. ${skipped_export-false} && {
  9172. if test -n "$export_symbols" && test -n "$include_expsyms"; then
  9173. tmp_export_symbols=$export_symbols
  9174. test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
  9175. $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
  9176. fi
  9177. if test -n "$orig_export_symbols"; then
  9178. # The given exports_symbols file has to be filtered, so filter it.
  9179. func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
  9180. # FIXME: $output_objdir/$libname.filter potentially contains lots of
  9181. # 's' commands, which not all seds can handle. GNU sed should be fine
  9182. # though. Also, the filter scales superlinearly with the number of
  9183. # global variables. join(1) would be nice here, but unfortunately
  9184. # isn't a blessed tool.
  9185. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
  9186. func_append delfiles " $export_symbols $output_objdir/$libname.filter"
  9187. export_symbols=$output_objdir/$libname.def
  9188. $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
  9189. fi
  9190. }
  9191. libobjs=$output
  9192. # Restore the value of output.
  9193. output=$save_output
  9194. if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
  9195. eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
  9196. test "X$libobjs" = "X " && libobjs=
  9197. fi
  9198. # Expand the library linking commands again to reset the
  9199. # value of $libobjs for piecewise linking.
  9200. # Do each of the archive commands.
  9201. if test yes = "$module" && test -n "$module_cmds"; then
  9202. if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
  9203. cmds=$module_expsym_cmds
  9204. else
  9205. cmds=$module_cmds
  9206. fi
  9207. else
  9208. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
  9209. cmds=$archive_expsym_cmds
  9210. else
  9211. cmds=$archive_cmds
  9212. fi
  9213. fi
  9214. fi
  9215. if test -n "$delfiles"; then
  9216. # Append the command to remove temporary files to $cmds.
  9217. eval cmds=\"\$cmds~\$RM $delfiles\"
  9218. fi
  9219. # Add any objects from preloaded convenience libraries
  9220. if test -n "$dlprefiles"; then
  9221. gentop=$output_objdir/${outputname}x
  9222. func_append generated " $gentop"
  9223. func_extract_archives $gentop $dlprefiles
  9224. func_append libobjs " $func_extract_archives_result"
  9225. test "X$libobjs" = "X " && libobjs=
  9226. fi
  9227. save_ifs=$IFS; IFS='~'
  9228. for cmd in $cmds; do
  9229. IFS=$sp$nl
  9230. eval cmd=\"$cmd\"
  9231. IFS=$save_ifs
  9232. $opt_quiet || {
  9233. func_quote_for_expand "$cmd"
  9234. eval "func_echo $func_quote_for_expand_result"
  9235. }
  9236. $opt_dry_run || eval "$cmd" || {
  9237. lt_exit=$?
  9238. # Restore the uninstalled library and exit
  9239. if test relink = "$opt_mode"; then
  9240. ( cd "$output_objdir" && \
  9241. $RM "${realname}T" && \
  9242. $MV "${realname}U" "$realname" )
  9243. fi
  9244. exit $lt_exit
  9245. }
  9246. done
  9247. IFS=$save_ifs
  9248. # Restore the uninstalled library and exit
  9249. if test relink = "$opt_mode"; then
  9250. $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
  9251. if test -n "$convenience"; then
  9252. if test -z "$whole_archive_flag_spec"; then
  9253. func_show_eval '${RM}r "$gentop"'
  9254. fi
  9255. fi
  9256. exit $EXIT_SUCCESS
  9257. fi
  9258. # Create links to the real library.
  9259. for linkname in $linknames; do
  9260. if test "$realname" != "$linkname"; then
  9261. func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
  9262. fi
  9263. done
  9264. # If -module or -export-dynamic was specified, set the dlname.
  9265. if test yes = "$module" || test yes = "$export_dynamic"; then
  9266. # On all known operating systems, these are identical.
  9267. dlname=$soname
  9268. fi
  9269. fi
  9270. ;;
  9271. obj)
  9272. if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
  9273. func_warning "'-dlopen' is ignored for objects"
  9274. fi
  9275. case " $deplibs" in
  9276. *\ -l* | *\ -L*)
  9277. func_warning "'-l' and '-L' are ignored for objects" ;;
  9278. esac
  9279. test -n "$rpath" && \
  9280. func_warning "'-rpath' is ignored for objects"
  9281. test -n "$xrpath" && \
  9282. func_warning "'-R' is ignored for objects"
  9283. test -n "$vinfo" && \
  9284. func_warning "'-version-info' is ignored for objects"
  9285. test -n "$release" && \
  9286. func_warning "'-release' is ignored for objects"
  9287. case $output in
  9288. *.lo)
  9289. test -n "$objs$old_deplibs" && \
  9290. func_fatal_error "cannot build library object '$output' from non-libtool objects"
  9291. libobj=$output
  9292. func_lo2o "$libobj"
  9293. obj=$func_lo2o_result
  9294. ;;
  9295. *)
  9296. libobj=
  9297. obj=$output
  9298. ;;
  9299. esac
  9300. # Delete the old objects.
  9301. $opt_dry_run || $RM $obj $libobj
  9302. # Objects from convenience libraries. This assumes
  9303. # single-version convenience libraries. Whenever we create
  9304. # different ones for PIC/non-PIC, this we'll have to duplicate
  9305. # the extraction.
  9306. reload_conv_objs=
  9307. gentop=
  9308. # if reload_cmds runs $LD directly, get rid of -Wl from
  9309. # whole_archive_flag_spec and hope we can get by with turning comma
  9310. # into space.
  9311. case $reload_cmds in
  9312. *\$LD[\ \$]*) wl= ;;
  9313. esac
  9314. if test -n "$convenience"; then
  9315. if test -n "$whole_archive_flag_spec"; then
  9316. eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
  9317. test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
  9318. reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
  9319. else
  9320. gentop=$output_objdir/${obj}x
  9321. func_append generated " $gentop"
  9322. func_extract_archives $gentop $convenience
  9323. reload_conv_objs="$reload_objs $func_extract_archives_result"
  9324. fi
  9325. fi
  9326. # If we're not building shared, we need to use non_pic_objs
  9327. test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
  9328. # Create the old-style object.
  9329. reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
  9330. output=$obj
  9331. func_execute_cmds "$reload_cmds" 'exit $?'
  9332. # Exit if we aren't doing a library object file.
  9333. if test -z "$libobj"; then
  9334. if test -n "$gentop"; then
  9335. func_show_eval '${RM}r "$gentop"'
  9336. fi
  9337. exit $EXIT_SUCCESS
  9338. fi
  9339. test yes = "$build_libtool_libs" || {
  9340. if test -n "$gentop"; then
  9341. func_show_eval '${RM}r "$gentop"'
  9342. fi
  9343. # Create an invalid libtool object if no PIC, so that we don't
  9344. # accidentally link it into a program.
  9345. # $show "echo timestamp > $libobj"
  9346. # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
  9347. exit $EXIT_SUCCESS
  9348. }
  9349. if test -n "$pic_flag" || test default != "$pic_mode"; then
  9350. # Only do commands if we really have different PIC objects.
  9351. reload_objs="$libobjs $reload_conv_objs"
  9352. output=$libobj
  9353. func_execute_cmds "$reload_cmds" 'exit $?'
  9354. fi
  9355. if test -n "$gentop"; then
  9356. func_show_eval '${RM}r "$gentop"'
  9357. fi
  9358. exit $EXIT_SUCCESS
  9359. ;;
  9360. prog)
  9361. case $host in
  9362. *cygwin*) func_stripname '' '.exe' "$output"
  9363. output=$func_stripname_result.exe;;
  9364. esac
  9365. test -n "$vinfo" && \
  9366. func_warning "'-version-info' is ignored for programs"
  9367. test -n "$release" && \
  9368. func_warning "'-release' is ignored for programs"
  9369. $preload \
  9370. && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
  9371. && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
  9372. case $host in
  9373. *-*-rhapsody* | *-*-darwin1.[012])
  9374. # On Rhapsody replace the C library is the System framework
  9375. compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
  9376. finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
  9377. ;;
  9378. esac
  9379. case $host in
  9380. *-*-darwin*)
  9381. # Don't allow lazy linking, it breaks C++ global constructors
  9382. # But is supposedly fixed on 10.4 or later (yay!).
  9383. if test CXX = "$tagname"; then
  9384. case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
  9385. 10.[0123])
  9386. func_append compile_command " $wl-bind_at_load"
  9387. func_append finalize_command " $wl-bind_at_load"
  9388. ;;
  9389. esac
  9390. fi
  9391. # Time to change all our "foo.ltframework" stuff back to "-framework foo"
  9392. compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  9393. finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  9394. ;;
  9395. esac
  9396. # move library search paths that coincide with paths to not yet
  9397. # installed libraries to the beginning of the library search list
  9398. new_libs=
  9399. for path in $notinst_path; do
  9400. case " $new_libs " in
  9401. *" -L$path/$objdir "*) ;;
  9402. *)
  9403. case " $compile_deplibs " in
  9404. *" -L$path/$objdir "*)
  9405. func_append new_libs " -L$path/$objdir" ;;
  9406. esac
  9407. ;;
  9408. esac
  9409. done
  9410. for deplib in $compile_deplibs; do
  9411. case $deplib in
  9412. -L*)
  9413. case " $new_libs " in
  9414. *" $deplib "*) ;;
  9415. *) func_append new_libs " $deplib" ;;
  9416. esac
  9417. ;;
  9418. *) func_append new_libs " $deplib" ;;
  9419. esac
  9420. done
  9421. compile_deplibs=$new_libs
  9422. func_append compile_command " $compile_deplibs"
  9423. func_append finalize_command " $finalize_deplibs"
  9424. if test -n "$rpath$xrpath"; then
  9425. # If the user specified any rpath flags, then add them.
  9426. for libdir in $rpath $xrpath; do
  9427. # This is the magic to use -rpath.
  9428. case "$finalize_rpath " in
  9429. *" $libdir "*) ;;
  9430. *) func_append finalize_rpath " $libdir" ;;
  9431. esac
  9432. done
  9433. fi
  9434. # Now hardcode the library paths
  9435. rpath=
  9436. hardcode_libdirs=
  9437. for libdir in $compile_rpath $finalize_rpath; do
  9438. if test -n "$hardcode_libdir_flag_spec"; then
  9439. if test -n "$hardcode_libdir_separator"; then
  9440. if test -z "$hardcode_libdirs"; then
  9441. hardcode_libdirs=$libdir
  9442. else
  9443. # Just accumulate the unique libdirs.
  9444. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  9445. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  9446. ;;
  9447. *)
  9448. func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  9449. ;;
  9450. esac
  9451. fi
  9452. else
  9453. eval flag=\"$hardcode_libdir_flag_spec\"
  9454. func_append rpath " $flag"
  9455. fi
  9456. elif test -n "$runpath_var"; then
  9457. case "$perm_rpath " in
  9458. *" $libdir "*) ;;
  9459. *) func_append perm_rpath " $libdir" ;;
  9460. esac
  9461. fi
  9462. case $host in
  9463. *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
  9464. testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
  9465. case :$dllsearchpath: in
  9466. *":$libdir:"*) ;;
  9467. ::) dllsearchpath=$libdir;;
  9468. *) func_append dllsearchpath ":$libdir";;
  9469. esac
  9470. case :$dllsearchpath: in
  9471. *":$testbindir:"*) ;;
  9472. ::) dllsearchpath=$testbindir;;
  9473. *) func_append dllsearchpath ":$testbindir";;
  9474. esac
  9475. ;;
  9476. esac
  9477. done
  9478. # Substitute the hardcoded libdirs into the rpath.
  9479. if test -n "$hardcode_libdir_separator" &&
  9480. test -n "$hardcode_libdirs"; then
  9481. libdir=$hardcode_libdirs
  9482. eval rpath=\" $hardcode_libdir_flag_spec\"
  9483. fi
  9484. compile_rpath=$rpath
  9485. rpath=
  9486. hardcode_libdirs=
  9487. for libdir in $finalize_rpath; do
  9488. if test -n "$hardcode_libdir_flag_spec"; then
  9489. if test -n "$hardcode_libdir_separator"; then
  9490. if test -z "$hardcode_libdirs"; then
  9491. hardcode_libdirs=$libdir
  9492. else
  9493. # Just accumulate the unique libdirs.
  9494. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  9495. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  9496. ;;
  9497. *)
  9498. func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  9499. ;;
  9500. esac
  9501. fi
  9502. else
  9503. eval flag=\"$hardcode_libdir_flag_spec\"
  9504. func_append rpath " $flag"
  9505. fi
  9506. elif test -n "$runpath_var"; then
  9507. case "$finalize_perm_rpath " in
  9508. *" $libdir "*) ;;
  9509. *) func_append finalize_perm_rpath " $libdir" ;;
  9510. esac
  9511. fi
  9512. done
  9513. # Substitute the hardcoded libdirs into the rpath.
  9514. if test -n "$hardcode_libdir_separator" &&
  9515. test -n "$hardcode_libdirs"; then
  9516. libdir=$hardcode_libdirs
  9517. eval rpath=\" $hardcode_libdir_flag_spec\"
  9518. fi
  9519. finalize_rpath=$rpath
  9520. if test -n "$libobjs" && test yes = "$build_old_libs"; then
  9521. # Transform all the library objects into standard objects.
  9522. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
  9523. finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
  9524. fi
  9525. func_generate_dlsyms "$outputname" "@PROGRAM@" false
  9526. # template prelinking step
  9527. if test -n "$prelink_cmds"; then
  9528. func_execute_cmds "$prelink_cmds" 'exit $?'
  9529. fi
  9530. wrappers_required=:
  9531. case $host in
  9532. *cegcc* | *mingw32ce*)
  9533. # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
  9534. wrappers_required=false
  9535. ;;
  9536. *cygwin* | *mingw* )
  9537. test yes = "$build_libtool_libs" || wrappers_required=false
  9538. ;;
  9539. *)
  9540. if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
  9541. wrappers_required=false
  9542. fi
  9543. ;;
  9544. esac
  9545. $wrappers_required || {
  9546. # Replace the output file specification.
  9547. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
  9548. link_command=$compile_command$compile_rpath
  9549. # We have no uninstalled library dependencies, so finalize right now.
  9550. exit_status=0
  9551. func_show_eval "$link_command" 'exit_status=$?'
  9552. if test -n "$postlink_cmds"; then
  9553. func_to_tool_file "$output"
  9554. postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  9555. func_execute_cmds "$postlink_cmds" 'exit $?'
  9556. fi
  9557. # Delete the generated files.
  9558. if test -f "$output_objdir/${outputname}S.$objext"; then
  9559. func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
  9560. fi
  9561. exit $exit_status
  9562. }
  9563. if test -n "$compile_shlibpath$finalize_shlibpath"; then
  9564. compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
  9565. fi
  9566. if test -n "$finalize_shlibpath"; then
  9567. finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
  9568. fi
  9569. compile_var=
  9570. finalize_var=
  9571. if test -n "$runpath_var"; then
  9572. if test -n "$perm_rpath"; then
  9573. # We should set the runpath_var.
  9574. rpath=
  9575. for dir in $perm_rpath; do
  9576. func_append rpath "$dir:"
  9577. done
  9578. compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
  9579. fi
  9580. if test -n "$finalize_perm_rpath"; then
  9581. # We should set the runpath_var.
  9582. rpath=
  9583. for dir in $finalize_perm_rpath; do
  9584. func_append rpath "$dir:"
  9585. done
  9586. finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
  9587. fi
  9588. fi
  9589. if test yes = "$no_install"; then
  9590. # We don't need to create a wrapper script.
  9591. link_command=$compile_var$compile_command$compile_rpath
  9592. # Replace the output file specification.
  9593. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
  9594. # Delete the old output file.
  9595. $opt_dry_run || $RM $output
  9596. # Link the executable and exit
  9597. func_show_eval "$link_command" 'exit $?'
  9598. if test -n "$postlink_cmds"; then
  9599. func_to_tool_file "$output"
  9600. postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  9601. func_execute_cmds "$postlink_cmds" 'exit $?'
  9602. fi
  9603. exit $EXIT_SUCCESS
  9604. fi
  9605. case $hardcode_action,$fast_install in
  9606. relink,*)
  9607. # Fast installation is not supported
  9608. link_command=$compile_var$compile_command$compile_rpath
  9609. relink_command=$finalize_var$finalize_command$finalize_rpath
  9610. func_warning "this platform does not like uninstalled shared libraries"
  9611. func_warning "'$output' will be relinked during installation"
  9612. ;;
  9613. *,yes)
  9614. link_command=$finalize_var$compile_command$finalize_rpath
  9615. relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
  9616. ;;
  9617. *,no)
  9618. link_command=$compile_var$compile_command$compile_rpath
  9619. relink_command=$finalize_var$finalize_command$finalize_rpath
  9620. ;;
  9621. *,needless)
  9622. link_command=$finalize_var$compile_command$finalize_rpath
  9623. relink_command=
  9624. ;;
  9625. esac
  9626. # Replace the output file specification.
  9627. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
  9628. # Delete the old output files.
  9629. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
  9630. func_show_eval "$link_command" 'exit $?'
  9631. if test -n "$postlink_cmds"; then
  9632. func_to_tool_file "$output_objdir/$outputname"
  9633. postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  9634. func_execute_cmds "$postlink_cmds" 'exit $?'
  9635. fi
  9636. # Now create the wrapper script.
  9637. func_verbose "creating $output"
  9638. # Quote the relink command for shipping.
  9639. if test -n "$relink_command"; then
  9640. # Preserve any variables that may affect compiler behavior
  9641. for var in $variables_saved_for_relink; do
  9642. if eval test -z \"\${$var+set}\"; then
  9643. relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
  9644. elif eval var_value=\$$var; test -z "$var_value"; then
  9645. relink_command="$var=; export $var; $relink_command"
  9646. else
  9647. func_quote_for_eval "$var_value"
  9648. relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
  9649. fi
  9650. done
  9651. relink_command="(cd `pwd`; $relink_command)"
  9652. relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
  9653. fi
  9654. # Only actually do things if not in dry run mode.
  9655. $opt_dry_run || {
  9656. # win32 will think the script is a binary if it has
  9657. # a .exe suffix, so we strip it off here.
  9658. case $output in
  9659. *.exe) func_stripname '' '.exe' "$output"
  9660. output=$func_stripname_result ;;
  9661. esac
  9662. # test for cygwin because mv fails w/o .exe extensions
  9663. case $host in
  9664. *cygwin*)
  9665. exeext=.exe
  9666. func_stripname '' '.exe' "$outputname"
  9667. outputname=$func_stripname_result ;;
  9668. *) exeext= ;;
  9669. esac
  9670. case $host in
  9671. *cygwin* | *mingw* )
  9672. func_dirname_and_basename "$output" "" "."
  9673. output_name=$func_basename_result
  9674. output_path=$func_dirname_result
  9675. cwrappersource=$output_path/$objdir/lt-$output_name.c
  9676. cwrapper=$output_path/$output_name.exe
  9677. $RM $cwrappersource $cwrapper
  9678. trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
  9679. func_emit_cwrapperexe_src > $cwrappersource
  9680. # The wrapper executable is built using the $host compiler,
  9681. # because it contains $host paths and files. If cross-
  9682. # compiling, it, like the target executable, must be
  9683. # executed on the $host or under an emulation environment.
  9684. $opt_dry_run || {
  9685. $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
  9686. $STRIP $cwrapper
  9687. }
  9688. # Now, create the wrapper script for func_source use:
  9689. func_ltwrapper_scriptname $cwrapper
  9690. $RM $func_ltwrapper_scriptname_result
  9691. trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
  9692. $opt_dry_run || {
  9693. # note: this script will not be executed, so do not chmod.
  9694. if test "x$build" = "x$host"; then
  9695. $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
  9696. else
  9697. func_emit_wrapper no > $func_ltwrapper_scriptname_result
  9698. fi
  9699. }
  9700. ;;
  9701. * )
  9702. $RM $output
  9703. trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
  9704. func_emit_wrapper no > $output
  9705. chmod +x $output
  9706. ;;
  9707. esac
  9708. }
  9709. exit $EXIT_SUCCESS
  9710. ;;
  9711. esac
  9712. # See if we need to build an old-fashioned archive.
  9713. for oldlib in $oldlibs; do
  9714. case $build_libtool_libs in
  9715. convenience)
  9716. oldobjs="$libobjs_save $symfileobj"
  9717. addlibs=$convenience
  9718. build_libtool_libs=no
  9719. ;;
  9720. module)
  9721. oldobjs=$libobjs_save
  9722. addlibs=$old_convenience
  9723. build_libtool_libs=no
  9724. ;;
  9725. *)
  9726. oldobjs="$old_deplibs $non_pic_objects"
  9727. $preload && test -f "$symfileobj" \
  9728. && func_append oldobjs " $symfileobj"
  9729. addlibs=$old_convenience
  9730. ;;
  9731. esac
  9732. if test -n "$addlibs"; then
  9733. gentop=$output_objdir/${outputname}x
  9734. func_append generated " $gentop"
  9735. func_extract_archives $gentop $addlibs
  9736. func_append oldobjs " $func_extract_archives_result"
  9737. fi
  9738. # Do each command in the archive commands.
  9739. if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
  9740. cmds=$old_archive_from_new_cmds
  9741. else
  9742. # Add any objects from preloaded convenience libraries
  9743. if test -n "$dlprefiles"; then
  9744. gentop=$output_objdir/${outputname}x
  9745. func_append generated " $gentop"
  9746. func_extract_archives $gentop $dlprefiles
  9747. func_append oldobjs " $func_extract_archives_result"
  9748. fi
  9749. # POSIX demands no paths to be encoded in archives. We have
  9750. # to avoid creating archives with duplicate basenames if we
  9751. # might have to extract them afterwards, e.g., when creating a
  9752. # static archive out of a convenience library, or when linking
  9753. # the entirety of a libtool archive into another (currently
  9754. # not supported by libtool).
  9755. if (for obj in $oldobjs
  9756. do
  9757. func_basename "$obj"
  9758. $ECHO "$func_basename_result"
  9759. done | sort | sort -uc >/dev/null 2>&1); then
  9760. :
  9761. else
  9762. echo "copying selected object files to avoid basename conflicts..."
  9763. gentop=$output_objdir/${outputname}x
  9764. func_append generated " $gentop"
  9765. func_mkdir_p "$gentop"
  9766. save_oldobjs=$oldobjs
  9767. oldobjs=
  9768. counter=1
  9769. for obj in $save_oldobjs
  9770. do
  9771. func_basename "$obj"
  9772. objbase=$func_basename_result
  9773. case " $oldobjs " in
  9774. " ") oldobjs=$obj ;;
  9775. *[\ /]"$objbase "*)
  9776. while :; do
  9777. # Make sure we don't pick an alternate name that also
  9778. # overlaps.
  9779. newobj=lt$counter-$objbase
  9780. func_arith $counter + 1
  9781. counter=$func_arith_result
  9782. case " $oldobjs " in
  9783. *[\ /]"$newobj "*) ;;
  9784. *) if test ! -f "$gentop/$newobj"; then break; fi ;;
  9785. esac
  9786. done
  9787. func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
  9788. func_append oldobjs " $gentop/$newobj"
  9789. ;;
  9790. *) func_append oldobjs " $obj" ;;
  9791. esac
  9792. done
  9793. fi
  9794. func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
  9795. tool_oldlib=$func_to_tool_file_result
  9796. eval cmds=\"$old_archive_cmds\"
  9797. func_len " $cmds"
  9798. len=$func_len_result
  9799. if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
  9800. cmds=$old_archive_cmds
  9801. elif test -n "$archiver_list_spec"; then
  9802. func_verbose "using command file archive linking..."
  9803. for obj in $oldobjs
  9804. do
  9805. func_to_tool_file "$obj"
  9806. $ECHO "$func_to_tool_file_result"
  9807. done > $output_objdir/$libname.libcmd
  9808. func_to_tool_file "$output_objdir/$libname.libcmd"
  9809. oldobjs=" $archiver_list_spec$func_to_tool_file_result"
  9810. cmds=$old_archive_cmds
  9811. else
  9812. # the command line is too long to link in one step, link in parts
  9813. func_verbose "using piecewise archive linking..."
  9814. save_RANLIB=$RANLIB
  9815. RANLIB=:
  9816. objlist=
  9817. concat_cmds=
  9818. save_oldobjs=$oldobjs
  9819. oldobjs=
  9820. # Is there a better way of finding the last object in the list?
  9821. for obj in $save_oldobjs
  9822. do
  9823. last_oldobj=$obj
  9824. done
  9825. eval test_cmds=\"$old_archive_cmds\"
  9826. func_len " $test_cmds"
  9827. len0=$func_len_result
  9828. len=$len0
  9829. for obj in $save_oldobjs
  9830. do
  9831. func_len " $obj"
  9832. func_arith $len + $func_len_result
  9833. len=$func_arith_result
  9834. func_append objlist " $obj"
  9835. if test "$len" -lt "$max_cmd_len"; then
  9836. :
  9837. else
  9838. # the above command should be used before it gets too long
  9839. oldobjs=$objlist
  9840. if test "$obj" = "$last_oldobj"; then
  9841. RANLIB=$save_RANLIB
  9842. fi
  9843. test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  9844. eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
  9845. objlist=
  9846. len=$len0
  9847. fi
  9848. done
  9849. RANLIB=$save_RANLIB
  9850. oldobjs=$objlist
  9851. if test -z "$oldobjs"; then
  9852. eval cmds=\"\$concat_cmds\"
  9853. else
  9854. eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
  9855. fi
  9856. fi
  9857. fi
  9858. func_execute_cmds "$cmds" 'exit $?'
  9859. done
  9860. test -n "$generated" && \
  9861. func_show_eval "${RM}r$generated"
  9862. # Now create the libtool archive.
  9863. case $output in
  9864. *.la)
  9865. old_library=
  9866. test yes = "$build_old_libs" && old_library=$libname.$libext
  9867. func_verbose "creating $output"
  9868. # Preserve any variables that may affect compiler behavior
  9869. for var in $variables_saved_for_relink; do
  9870. if eval test -z \"\${$var+set}\"; then
  9871. relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
  9872. elif eval var_value=\$$var; test -z "$var_value"; then
  9873. relink_command="$var=; export $var; $relink_command"
  9874. else
  9875. func_quote_for_eval "$var_value"
  9876. relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
  9877. fi
  9878. done
  9879. # Quote the link command for shipping.
  9880. relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
  9881. relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
  9882. if test yes = "$hardcode_automatic"; then
  9883. relink_command=
  9884. fi
  9885. # Only create the output if not a dry run.
  9886. $opt_dry_run || {
  9887. for installed in no yes; do
  9888. if test yes = "$installed"; then
  9889. if test -z "$install_libdir"; then
  9890. break
  9891. fi
  9892. output=$output_objdir/${outputname}i
  9893. # Replace all uninstalled libtool libraries with the installed ones
  9894. newdependency_libs=
  9895. for deplib in $dependency_libs; do
  9896. case $deplib in
  9897. *.la)
  9898. func_basename "$deplib"
  9899. name=$func_basename_result
  9900. func_resolve_sysroot "$deplib"
  9901. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
  9902. test -z "$libdir" && \
  9903. func_fatal_error "'$deplib' is not a valid libtool archive"
  9904. func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
  9905. ;;
  9906. -L*)
  9907. func_stripname -L '' "$deplib"
  9908. func_replace_sysroot "$func_stripname_result"
  9909. func_append newdependency_libs " -L$func_replace_sysroot_result"
  9910. ;;
  9911. -R*)
  9912. func_stripname -R '' "$deplib"
  9913. func_replace_sysroot "$func_stripname_result"
  9914. func_append newdependency_libs " -R$func_replace_sysroot_result"
  9915. ;;
  9916. *) func_append newdependency_libs " $deplib" ;;
  9917. esac
  9918. done
  9919. dependency_libs=$newdependency_libs
  9920. newdlfiles=
  9921. for lib in $dlfiles; do
  9922. case $lib in
  9923. *.la)
  9924. func_basename "$lib"
  9925. name=$func_basename_result
  9926. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
  9927. test -z "$libdir" && \
  9928. func_fatal_error "'$lib' is not a valid libtool archive"
  9929. func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
  9930. ;;
  9931. *) func_append newdlfiles " $lib" ;;
  9932. esac
  9933. done
  9934. dlfiles=$newdlfiles
  9935. newdlprefiles=
  9936. for lib in $dlprefiles; do
  9937. case $lib in
  9938. *.la)
  9939. # Only pass preopened files to the pseudo-archive (for
  9940. # eventual linking with the app. that links it) if we
  9941. # didn't already link the preopened objects directly into
  9942. # the library:
  9943. func_basename "$lib"
  9944. name=$func_basename_result
  9945. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
  9946. test -z "$libdir" && \
  9947. func_fatal_error "'$lib' is not a valid libtool archive"
  9948. func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
  9949. ;;
  9950. esac
  9951. done
  9952. dlprefiles=$newdlprefiles
  9953. else
  9954. newdlfiles=
  9955. for lib in $dlfiles; do
  9956. case $lib in
  9957. [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
  9958. *) abs=`pwd`"/$lib" ;;
  9959. esac
  9960. func_append newdlfiles " $abs"
  9961. done
  9962. dlfiles=$newdlfiles
  9963. newdlprefiles=
  9964. for lib in $dlprefiles; do
  9965. case $lib in
  9966. [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
  9967. *) abs=`pwd`"/$lib" ;;
  9968. esac
  9969. func_append newdlprefiles " $abs"
  9970. done
  9971. dlprefiles=$newdlprefiles
  9972. fi
  9973. $RM $output
  9974. # place dlname in correct position for cygwin
  9975. # In fact, it would be nice if we could use this code for all target
  9976. # systems that can't hard-code library paths into their executables
  9977. # and that have no shared library path variable independent of PATH,
  9978. # but it turns out we can't easily determine that from inspecting
  9979. # libtool variables, so we have to hard-code the OSs to which it
  9980. # applies here; at the moment, that means platforms that use the PE
  9981. # object format with DLL files. See the long comment at the top of
  9982. # tests/bindir.at for full details.
  9983. tdlname=$dlname
  9984. case $host,$output,$installed,$module,$dlname in
  9985. *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
  9986. # If a -bindir argument was supplied, place the dll there.
  9987. if test -n "$bindir"; then
  9988. func_relative_path "$install_libdir" "$bindir"
  9989. tdlname=$func_relative_path_result/$dlname
  9990. else
  9991. # Otherwise fall back on heuristic.
  9992. tdlname=../bin/$dlname
  9993. fi
  9994. ;;
  9995. esac
  9996. $ECHO > $output "\
  9997. # $outputname - a libtool library file
  9998. # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  9999. #
  10000. # Please DO NOT delete this file!
  10001. # It is necessary for linking the library.
  10002. # The name that we can dlopen(3).
  10003. dlname='$tdlname'
  10004. # Names of this library.
  10005. library_names='$library_names'
  10006. # The name of the static archive.
  10007. old_library='$old_library'
  10008. # Linker flags that cannot go in dependency_libs.
  10009. inherited_linker_flags='$new_inherited_linker_flags'
  10010. # Libraries that this one depends upon.
  10011. dependency_libs='$dependency_libs'
  10012. # Names of additional weak libraries provided by this library
  10013. weak_library_names='$weak_libs'
  10014. # Version information for $libname.
  10015. current=$current
  10016. age=$age
  10017. revision=$revision
  10018. # Is this an already installed library?
  10019. installed=$installed
  10020. # Should we warn about portability when linking against -modules?
  10021. shouldnotlink=$module
  10022. # Files to dlopen/dlpreopen
  10023. dlopen='$dlfiles'
  10024. dlpreopen='$dlprefiles'
  10025. # Directory that this library needs to be installed in:
  10026. libdir='$install_libdir'"
  10027. if test no,yes = "$installed,$need_relink"; then
  10028. $ECHO >> $output "\
  10029. relink_command=\"$relink_command\""
  10030. fi
  10031. done
  10032. }
  10033. # Do a symbolic link so that the libtool archive can be found in
  10034. # LD_LIBRARY_PATH before the program is installed.
  10035. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
  10036. ;;
  10037. esac
  10038. exit $EXIT_SUCCESS
  10039. }
  10040. if test link = "$opt_mode" || test relink = "$opt_mode"; then
  10041. func_mode_link ${1+"$@"}
  10042. fi
  10043. # func_mode_uninstall arg...
  10044. func_mode_uninstall ()
  10045. {
  10046. $debug_cmd
  10047. RM=$nonopt
  10048. files=
  10049. rmforce=false
  10050. exit_status=0
  10051. # This variable tells wrapper scripts just to set variables rather
  10052. # than running their programs.
  10053. libtool_install_magic=$magic
  10054. for arg
  10055. do
  10056. case $arg in
  10057. -f) func_append RM " $arg"; rmforce=: ;;
  10058. -*) func_append RM " $arg" ;;
  10059. *) func_append files " $arg" ;;
  10060. esac
  10061. done
  10062. test -z "$RM" && \
  10063. func_fatal_help "you must specify an RM program"
  10064. rmdirs=
  10065. for file in $files; do
  10066. func_dirname "$file" "" "."
  10067. dir=$func_dirname_result
  10068. if test . = "$dir"; then
  10069. odir=$objdir
  10070. else
  10071. odir=$dir/$objdir
  10072. fi
  10073. func_basename "$file"
  10074. name=$func_basename_result
  10075. test uninstall = "$opt_mode" && odir=$dir
  10076. # Remember odir for removal later, being careful to avoid duplicates
  10077. if test clean = "$opt_mode"; then
  10078. case " $rmdirs " in
  10079. *" $odir "*) ;;
  10080. *) func_append rmdirs " $odir" ;;
  10081. esac
  10082. fi
  10083. # Don't error if the file doesn't exist and rm -f was used.
  10084. if { test -L "$file"; } >/dev/null 2>&1 ||
  10085. { test -h "$file"; } >/dev/null 2>&1 ||
  10086. test -f "$file"; then
  10087. :
  10088. elif test -d "$file"; then
  10089. exit_status=1
  10090. continue
  10091. elif $rmforce; then
  10092. continue
  10093. fi
  10094. rmfiles=$file
  10095. case $name in
  10096. *.la)
  10097. # Possibly a libtool archive, so verify it.
  10098. if func_lalib_p "$file"; then
  10099. func_source $dir/$name
  10100. # Delete the libtool libraries and symlinks.
  10101. for n in $library_names; do
  10102. func_append rmfiles " $odir/$n"
  10103. done
  10104. test -n "$old_library" && func_append rmfiles " $odir/$old_library"
  10105. case $opt_mode in
  10106. clean)
  10107. case " $library_names " in
  10108. *" $dlname "*) ;;
  10109. *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
  10110. esac
  10111. test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
  10112. ;;
  10113. uninstall)
  10114. if test -n "$library_names"; then
  10115. # Do each command in the postuninstall commands.
  10116. func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
  10117. fi
  10118. if test -n "$old_library"; then
  10119. # Do each command in the old_postuninstall commands.
  10120. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
  10121. fi
  10122. # FIXME: should reinstall the best remaining shared library.
  10123. ;;
  10124. esac
  10125. fi
  10126. ;;
  10127. *.lo)
  10128. # Possibly a libtool object, so verify it.
  10129. if func_lalib_p "$file"; then
  10130. # Read the .lo file
  10131. func_source $dir/$name
  10132. # Add PIC object to the list of files to remove.
  10133. if test -n "$pic_object" && test none != "$pic_object"; then
  10134. func_append rmfiles " $dir/$pic_object"
  10135. fi
  10136. # Add non-PIC object to the list of files to remove.
  10137. if test -n "$non_pic_object" && test none != "$non_pic_object"; then
  10138. func_append rmfiles " $dir/$non_pic_object"
  10139. fi
  10140. fi
  10141. ;;
  10142. *)
  10143. if test clean = "$opt_mode"; then
  10144. noexename=$name
  10145. case $file in
  10146. *.exe)
  10147. func_stripname '' '.exe' "$file"
  10148. file=$func_stripname_result
  10149. func_stripname '' '.exe' "$name"
  10150. noexename=$func_stripname_result
  10151. # $file with .exe has already been added to rmfiles,
  10152. # add $file without .exe
  10153. func_append rmfiles " $file"
  10154. ;;
  10155. esac
  10156. # Do a test to see if this is a libtool program.
  10157. if func_ltwrapper_p "$file"; then
  10158. if func_ltwrapper_executable_p "$file"; then
  10159. func_ltwrapper_scriptname "$file"
  10160. relink_command=
  10161. func_source $func_ltwrapper_scriptname_result
  10162. func_append rmfiles " $func_ltwrapper_scriptname_result"
  10163. else
  10164. relink_command=
  10165. func_source $dir/$noexename
  10166. fi
  10167. # note $name still contains .exe if it was in $file originally
  10168. # as does the version of $file that was added into $rmfiles
  10169. func_append rmfiles " $odir/$name $odir/${name}S.$objext"
  10170. if test yes = "$fast_install" && test -n "$relink_command"; then
  10171. func_append rmfiles " $odir/lt-$name"
  10172. fi
  10173. if test "X$noexename" != "X$name"; then
  10174. func_append rmfiles " $odir/lt-$noexename.c"
  10175. fi
  10176. fi
  10177. fi
  10178. ;;
  10179. esac
  10180. func_show_eval "$RM $rmfiles" 'exit_status=1'
  10181. done
  10182. # Try to remove the $objdir's in the directories where we deleted files
  10183. for dir in $rmdirs; do
  10184. if test -d "$dir"; then
  10185. func_show_eval "rmdir $dir >/dev/null 2>&1"
  10186. fi
  10187. done
  10188. exit $exit_status
  10189. }
  10190. if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
  10191. func_mode_uninstall ${1+"$@"}
  10192. fi
  10193. test -z "$opt_mode" && {
  10194. help=$generic_help
  10195. func_fatal_help "you must specify a MODE"
  10196. }
  10197. test -z "$exec_cmd" && \
  10198. func_fatal_help "invalid operation mode '$opt_mode'"
  10199. if test -n "$exec_cmd"; then
  10200. eval exec "$exec_cmd"
  10201. exit $EXIT_FAILURE
  10202. fi
  10203. exit $exit_status
  10204. # The TAGs below are defined such that we never get into a situation
  10205. # where we disable both kinds of libraries. Given conflicting
  10206. # choices, we go for a static library, that is the most portable,
  10207. # since we can't tell whether shared libraries were disabled because
  10208. # the user asked for that or because the platform doesn't support
  10209. # them. This is particularly important on AIX, because we don't
  10210. # support having both static and shared libraries enabled at the same
  10211. # time on that platform, so we default to a shared-only configuration.
  10212. # If a disable-shared tag is given, we'll fallback to a static-only
  10213. # configuration. But we'll never go from static-only to shared-only.
  10214. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
  10215. build_libtool_libs=no
  10216. build_old_libs=yes
  10217. # ### END LIBTOOL TAG CONFIG: disable-shared
  10218. # ### BEGIN LIBTOOL TAG CONFIG: disable-static
  10219. build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
  10220. # ### END LIBTOOL TAG CONFIG: disable-static
  10221. # Local Variables:
  10222. # mode:shell-script
  10223. # sh-indentation:2
  10224. # End: