ltmain.sh 276 KB
Newer Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021

	-Xcompiler)
	  arg_mode=arg  #  the next one goes into the "base_compile" arg list
	  continue      #  The current "srcfile" will either be retained or
	  ;;            #  replaced later.  I would guess that would be a bug.

	-Wc,*)
	  func_stripname '-Wc,' '' "$arg"
	  args=$func_stripname_result
	  lastarg=
	  save_ifs="$IFS"; IFS=','
	  for arg in $args; do
	    IFS="$save_ifs"
	    func_append_quoted lastarg "$arg"
	  done
	  IFS="$save_ifs"
	  func_stripname ' ' '' "$lastarg"
	  lastarg=$func_stripname_result

	  # Add the arguments to base_compile.
	  func_append base_compile " $lastarg"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2022
2023
	  continue
	  ;;
2024

Emmanuel Bertin's avatar
Emmanuel Bertin committed
2025
	*)
2026
2027
2028
2029
2030
	  # Accept the current argument as the source file.
	  # The previous "srcfile" becomes the current argument.
	  #
	  lastarg="$srcfile"
	  srcfile="$arg"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2031
	  ;;
2032
	esac  #  case $arg
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2033
	;;
2034
      esac    #  case $arg_mode
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2035

2036
2037
2038
      # Aesthetically quote the previous argument.
      func_append_quoted base_compile "$lastarg"
    done # for arg
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2039

2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
    case $arg_mode in
    arg)
      func_fatal_error "you must specify an argument for -Xcompile"
      ;;
    target)
      func_fatal_error "you must specify a target with \`-o'"
      ;;
    *)
      # Get the name of the library object.
      test -z "$libobj" && {
	func_basename "$srcfile"
	libobj="$func_basename_result"
      }
      ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2055

2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
    # Recognize several different file suffixes.
    # If the user specifies -o file.o, it is replaced with file.lo
    case $libobj in
    *.[cCFSifmso] | \
    *.ada | *.adb | *.ads | *.asm | \
    *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
    *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup)
      func_xform "$libobj"
      libobj=$func_xform_result
      ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2067

2068
2069
2070
2071
2072
2073
    case $libobj in
    *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
    *)
      func_fatal_error "cannot determine name of library object from \`$libobj'"
      ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2074

2075
    func_infer_tag $base_compile
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2076

2077
2078
2079
2080
2081
2082
    for arg in $later; do
      case $arg in
      -shared)
	test "$build_libtool_libs" != yes && \
	  func_fatal_configuration "can not build a shared library"
	build_old_libs=no
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2083
2084
2085
	continue
	;;

2086
2087
2088
      -static)
	build_libtool_libs=no
	build_old_libs=yes
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2089
2090
2091
	continue
	;;

2092
2093
      -prefer-pic)
	pic_mode=yes
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2094
2095
2096
	continue
	;;

2097
2098
      -prefer-non-pic)
	pic_mode=no
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2099
2100
	continue
	;;
2101
2102
      esac
    done
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2103

2104
2105
2106
2107
2108
2109
2110
2111
    func_quote_for_eval "$libobj"
    test "X$libobj" != "X$func_quote_for_eval_result" \
      && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'	 &()|`$[]' \
      && func_warning "libobj name \`$libobj' may not contain shell special characters."
    func_dirname_and_basename "$obj" "/" ""
    objname="$func_basename_result"
    xdir="$func_dirname_result"
    lobj=${xdir}$objdir/$objname
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2112

2113
2114
    test -z "$base_compile" && \
      func_fatal_help "you must specify a compilation command"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2115

2116
2117
2118
2119
2120
2121
    # Delete any leftover library objects.
    if test "$build_old_libs" = yes; then
      removelist="$obj $lobj $libobj ${libobj}T"
    else
      removelist="$lobj $libobj ${libobj}T"
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2122

2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
    # On Cygwin there's no "real" PIC flag so we must build both object types
    case $host_os in
    cygwin* | mingw* | pw32* | os2* | cegcc*)
      pic_mode=default
      ;;
    esac
    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
      # non-PIC code in shared libraries is not supported
      pic_mode=default
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2133

2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
    # Calculate the filename of the output object if compiler does
    # not support -o with -c
    if test "$compiler_c_o" = no; then
      output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
      lockfile="$output_obj.lock"
    else
      output_obj=
      need_locks=no
      lockfile=
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2144

2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
    # Lock this critical section if it is needed
    # We use this script file to make the link, it avoids creating a new file
    if test "$need_locks" = yes; then
      until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
	func_echo "Waiting for $lockfile to be removed"
	sleep 2
      done
    elif test "$need_locks" = warn; then
      if test -f "$lockfile"; then
	$ECHO "\
*** ERROR, $lockfile exists and contains:
`cat $lockfile 2>/dev/null`
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2157

2158
2159
2160
2161
2162
2163
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2164

2165
2166
2167
2168
2169
2170
	$opt_dry_run || $RM $removelist
	exit $EXIT_FAILURE
      fi
      func_append removelist " $output_obj"
      $ECHO "$srcfile" > "$lockfile"
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2171

2172
2173
2174
    $opt_dry_run || $RM $removelist
    func_append removelist " $lockfile"
    trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2175

2176
2177
2178
2179
    func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
    srcfile=$func_to_tool_file_result
    func_quote_for_eval "$srcfile"
    qsrcfile=$func_quote_for_eval_result
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2180

2181
2182
2183
2184
    # Only build a PIC object if we are building libtool libraries.
    if test "$build_libtool_libs" = yes; then
      # Without this assignment, base_compile gets emptied.
      fbsd_hideous_sh_bug=$base_compile
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2185

2186
2187
2188
2189
2190
2191
      if test "$pic_mode" != no; then
	command="$base_compile $qsrcfile $pic_flag"
      else
	# Don't build PIC code
	command="$base_compile $qsrcfile"
      fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2192

2193
      func_mkdir_p "$xdir$objdir"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2194

2195
2196
2197
2198
      if test -z "$output_obj"; then
	# Place PIC objects in $objdir
	func_append command " -o $lobj"
      fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2199

2200
2201
      func_show_eval_locale "$command"	\
          'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2202

2203
2204
2205
2206
2207
      if test "$need_locks" = warn &&
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
	$ECHO "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2208

2209
2210
but it should contain:
$srcfile
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2211

2212
2213
2214
2215
2216
2217
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2218

2219
2220
2221
	$opt_dry_run || $RM $removelist
	exit $EXIT_FAILURE
      fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2222

2223
2224
2225
2226
2227
      # Just move the object if needed, then go on to compile the next one
      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
	func_show_eval '$MV "$output_obj" "$lobj"' \
	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
      fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2228

2229
2230
2231
2232
2233
      # Allow error messages only from the first compilation.
      if test "$suppress_opt" = yes; then
	suppress_output=' >/dev/null 2>&1'
      fi
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2234

2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
    # Only build a position-dependent object if we build old libraries.
    if test "$build_old_libs" = yes; then
      if test "$pic_mode" != yes; then
	# Don't build PIC code
	command="$base_compile $qsrcfile$pie_flag"
      else
	command="$base_compile $qsrcfile $pic_flag"
      fi
      if test "$compiler_c_o" = yes; then
	func_append command " -o $obj"
      fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2246

2247
2248
2249
2250
      # Suppress compiler output if we already did a PIC compilation.
      func_append command "$suppress_output"
      func_show_eval_locale "$command" \
        '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2251

2252
2253
2254
2255
2256
      if test "$need_locks" = warn &&
	 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
	$ECHO "\
*** ERROR, $lockfile contains:
`cat $lockfile 2>/dev/null`
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2257

2258
2259
but it should contain:
$srcfile
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2260

2261
2262
2263
2264
2265
2266
This indicates that another process is trying to use the same
temporary object file, and libtool could not work around it because
your compiler does not support \`-c' and \`-o' together.  If you
repeat this compilation, it may succeed, by chance, but you had better
avoid parallel builds (make -j) in this platform, or get a better
compiler."
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2267

2268
2269
2270
	$opt_dry_run || $RM $removelist
	exit $EXIT_FAILURE
      fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2271

2272
2273
2274
2275
2276
2277
      # Just move the object if needed
      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
	func_show_eval '$MV "$output_obj" "$obj"' \
	  'error=$?; $opt_dry_run || $RM $removelist; exit $error'
      fi
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2278

2279
2280
    $opt_dry_run || {
      func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2281

2282
2283
2284
2285
2286
2287
      # Unlock the critical section if it was locked
      if test "$need_locks" != no; then
	removelist=$lockfile
        $RM "$lockfile"
      fi
    }
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2288

2289
2290
    exit $EXIT_SUCCESS
}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2291

2292
2293
2294
$opt_help || {
  test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2295

2296
2297
2298
2299
2300
2301
2302
2303
2304
func_mode_help ()
{
    # We need to display help for each of the modes.
    case $opt_mode in
      "")
        # Generic help is extracted from the usage comments
        # at the start of this file.
        func_help
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2305

2306
2307
2308
      clean)
        $ECHO \
"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2309

2310
Remove files from the build directory.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2311

2312
2313
2314
RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
to RM.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2315

2316
2317
2318
If FILE is a libtool library, object or program, all the files associated
with it are deleted. Otherwise, only FILE itself is deleted using RM."
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2319

2320
2321
2322
      compile)
      $ECHO \
"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2323

2324
Compile a source file into a libtool library object.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2325

2326
This mode accepts the following additional options:
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2327

2328
2329
2330
2331
2332
2333
2334
  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
  -no-suppress      do not suppress compiler output for multiple passes
  -prefer-pic       try to build PIC objects only
  -prefer-non-pic   try to build non-PIC objects only
  -shared           do not build a \`.o' file suitable for static linking
  -static           only build a \`.o' file suitable for static linking
  -Wc,FLAG          pass FLAG directly to the compiler
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2335

2336
2337
COMPILE-COMMAND is a command to be used in creating a \`standard' object file
from the given SOURCEFILE.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2338

2339
2340
2341
2342
The output file name is determined by removing the directory component from
SOURCEFILE, then substituting the C source code suffix \`.c' with the
library object suffix, \`.lo'."
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2343

2344
2345
2346
      execute)
        $ECHO \
"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2347

2348
Automatically set library path, then run a program.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2349

2350
This mode accepts the following additional options:
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2351

2352
  -dlopen FILE      add the directory containing FILE to the library path
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2353

2354
2355
This mode sets the library path environment variable according to \`-dlopen'
flags.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2356

2357
2358
2359
If any of the ARGS are libtool executable wrappers, then they are translated
into their corresponding uninstalled binary, and any of their required library
directories are added to the library path.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2360

2361
2362
Then, COMMAND is executed, with ARGS as arguments."
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2363

2364
2365
2366
      finish)
        $ECHO \
"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2367

2368
Complete the installation of libtool libraries.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2369

2370
Each LIBDIR is a directory that contains libtool libraries.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2371

2372
2373
2374
The commands that this mode executes may require superuser privileges.  Use
the \`--dry-run' option if you just want to see what would be executed."
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2375

2376
2377
2378
      install)
        $ECHO \
"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2379

2380
Install executables or libraries.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2381

2382
2383
INSTALL-COMMAND is the installation command.  The first component should be
either the \`install' or \`cp' program.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2384

2385
The following components of INSTALL-COMMAND are treated specially:
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2386

2387
  -inst-prefix-dir PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2388

2389
2390
2391
The rest of the components are interpreted as arguments to that command (only
BSD-compatible install options are recognized)."
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2392

2393
2394
2395
      link)
        $ECHO \
"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2396

2397
2398
Link object files or libraries together to form another library, or to
create an executable program.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2399

2400
2401
LINK-COMMAND is a command using the C compiler that you would use to create
a program from several object files.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2402

2403
The following components of LINK-COMMAND are treated specially:
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2404

2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
  -all-static       do not do any dynamic linking at all
  -avoid-version    do not add a version suffix if possible
  -bindir BINDIR    specify path to binaries directory (for systems where
                    libraries must be found in the PATH setting at runtime)
  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
  -export-symbols SYMFILE
                    try to export only the symbols listed in SYMFILE
  -export-symbols-regex REGEX
                    try to export only the symbols matching REGEX
  -LLIBDIR          search LIBDIR for required installed libraries
  -lNAME            OUTPUT-FILE requires the installed library libNAME
  -module           build a library that can dlopened
  -no-fast-install  disable the fast-install mode
  -no-install       link a not-installable executable
  -no-undefined     declare that a library does not refer to external symbols
  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
  -objectlist FILE  Use a list of object files found in FILE to specify objects
  -precious-files-regex REGEX
                    don't remove output files matching REGEX
  -release RELEASE  specify package release information
  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
  -shared           only do dynamic linking of libtool libraries
  -shrext SUFFIX    override the standard shared library file extension
  -static           do not do any dynamic linking of uninstalled libtool libraries
  -static-libtool-libs
                    do not do any dynamic linking of libtool libraries
  -version-info CURRENT[:REVISION[:AGE]]
                    specify library version info [each variable defaults to 0]
  -weak LIBNAME     declare that the target provides the LIBNAME interface
  -Wc,FLAG
  -Xcompiler FLAG   pass linker-specific FLAG directly to the compiler
  -Wl,FLAG
  -Xlinker FLAG     pass linker-specific FLAG directly to the linker
  -XCClinker FLAG   pass link-specific FLAG to the compiler driver (CC)
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2442

2443
All other options (arguments beginning with \`-') are ignored.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2444

2445
2446
2447
Every other argument is treated as a filename.  Files ending in \`.la' are
treated as uninstalled libtool libraries, other files are standard or library
object files.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2448

2449
2450
2451
If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
only library objects (\`.lo' files) may be specified, and \`-rpath' is
required, except when creating a convenience library.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2452

2453
2454
If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
using \`ar' and \`ranlib', or on Windows using \`lib'.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2455

2456
2457
2458
If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
is created, otherwise an executable program is created."
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2459

2460
2461
2462
      uninstall)
        $ECHO \
"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2463

2464
Remove libraries from an installation directory.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2465

2466
2467
2468
RM is the name of the program to use to delete files associated with each FILE
(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
to RM.
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2469

2470
2471
2472
If FILE is a libtool library, all the files associated with it are deleted.
Otherwise, only FILE itself is deleted using RM."
        ;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2473

2474
2475
2476
2477
      *)
        func_fatal_help "invalid operation mode \`$opt_mode'"
        ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2478

2479
2480
2481
    echo
    $ECHO "Try \`$progname --help' for more information about other modes."
}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2482

2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
# Now that we've collected a possible --mode arg, show help if necessary
if $opt_help; then
  if test "$opt_help" = :; then
    func_mode_help
  else
    {
      func_help noexit
      for opt_mode in compile link execute install finish uninstall clean; do
	func_mode_help
      done
    } | sed -n '1p; 2,$s/^Usage:/  or: /p'
    {
      func_help noexit
      for opt_mode in compile link execute install finish uninstall clean; do
	echo
	func_mode_help
      done
    } |
    sed '1d
      /^When reporting/,/^Report/{
	H
	d
      }
      $x
      /information about other modes/d
      /more detailed .*MODE/d
      s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
  fi
  exit $?
fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2513
2514


2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
# func_mode_execute arg...
func_mode_execute ()
{
    $opt_debug
    # The first argument is the command name.
    cmd="$nonopt"
    test -z "$cmd" && \
      func_fatal_help "you must specify a COMMAND"

    # Handle -dlopen flags immediately.
    for file in $opt_dlopen; do
      test -f "$file" \
	|| func_fatal_help "\`$file' is not a file"

      dir=
      case $file in
      *.la)
	func_resolve_sysroot "$file"
	file=$func_resolve_sysroot_result

	# Check to see that this really is a libtool archive.
	func_lalib_unsafe_p "$file" \
	  || func_fatal_help "\`$lib' is not a valid libtool archive"

	# Read the libtool library.
	dlname=
	library_names=
	func_source "$file"

	# Skip this library if it cannot be dlopened.
	if test -z "$dlname"; then
	  # Warn if it was a shared library.
	  test -n "$library_names" && \
	    func_warning "\`$file' was not linked with \`-export-dynamic'"
	  continue
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2550
2551
	fi

2552
2553
	func_dirname "$file" "" "."
	dir="$func_dirname_result"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2554

2555
2556
2557
2558
2559
2560
2561
2562
	if test -f "$dir/$objdir/$dlname"; then
	  func_append dir "/$objdir"
	else
	  if test ! -f "$dir/$dlname"; then
	    func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
	  fi
	fi
	;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2563

2564
2565
2566
2567
2568
      *.lo)
	# Just add the directory containing the .lo file.
	func_dirname "$file" "" "."
	dir="$func_dirname_result"
	;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2569

2570
2571
2572
2573
2574
      *)
	func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
	continue
	;;
      esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2575

2576
2577
2578
      # Get the absolute pathname.
      absdir=`cd "$dir" && pwd`
      test -n "$absdir" && dir="$absdir"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2579

2580
2581
2582
2583
2584
2585
2586
      # Now add the directory to shlibpath_var.
      if eval "test -z \"\$$shlibpath_var\""; then
	eval "$shlibpath_var=\"\$dir\""
      else
	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
      fi
    done
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2587

2588
2589
2590
    # This variable tells wrapper scripts just to set shlibpath_var
    # rather than running their programs.
    libtool_execute_magic="$magic"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2591

2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
    # Check if any of the arguments is a wrapper script.
    args=
    for file
    do
      case $file in
      -* | *.la | *.lo ) ;;
      *)
	# Do a test to see if this is really a libtool program.
	if func_ltwrapper_script_p "$file"; then
	  func_source "$file"
	  # Transform arg to wrapped name.
	  file="$progdir/$program"
	elif func_ltwrapper_executable_p "$file"; then
	  func_ltwrapper_scriptname "$file"
	  func_source "$func_ltwrapper_scriptname_result"
	  # Transform arg to wrapped name.
	  file="$progdir/$program"
	fi
	;;
      esac
      # Quote arguments (to preserve shell metacharacters).
      func_append_quoted args "$file"
    done
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2615

2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
    if test "X$opt_dry_run" = Xfalse; then
      if test -n "$shlibpath_var"; then
	# Export the shlibpath_var.
	eval "export $shlibpath_var"
      fi

      # Restore saved environment variables
      for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
      do
	eval "if test \"\${save_$lt_var+set}\" = set; then
                $lt_var=\$save_$lt_var; export $lt_var
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2627
	      else
2628
2629
2630
		$lt_unset $lt_var
	      fi"
      done
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2631

2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
      # Now prepare to actually exec the command.
      exec_cmd="\$cmd$args"
    else
      # Display what would be done.
      if test -n "$shlibpath_var"; then
	eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
	echo "export $shlibpath_var"
      fi
      $ECHO "$cmd$args"
      exit $EXIT_SUCCESS
    fi
}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2644

2645
test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2646
2647


2648
2649
2650
2651
2652
2653
2654
# func_mode_finish arg...
func_mode_finish ()
{
    $opt_debug
    libs=
    libdirs=
    admincmds=
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2655

2656
2657
2658
2659
    for opt in "$nonopt" ${1+"$@"}
    do
      if test -d "$opt"; then
	func_append libdirs " $opt"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2660

2661
2662
2663
      elif test -f "$opt"; then
	if func_lalib_unsafe_p "$opt"; then
	  func_append libs " $opt"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2664
	else
2665
	  func_warning "\`$opt' is not a valid libtool archive"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2666
	fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2667

2668
2669
      else
	func_fatal_error "invalid argument \`$opt'"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2670
      fi
2671
    done
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2672

2673
2674
2675
2676
2677
2678
    if test -n "$libs"; then
      if test -n "$lt_sysroot"; then
        sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
        sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
      else
        sysroot_cmd=
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2679
2680
      fi

2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
      # Remove sysroot references
      if $opt_dry_run; then
        for lib in $libs; do
          echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
        done
      else
        tmpdir=`func_mktempdir`
        for lib in $libs; do
	  sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
	    > $tmpdir/tmp-la
	  mv -f $tmpdir/tmp-la $lib
	done
        ${RM}r "$tmpdir"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2694
      fi
2695
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2696

2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
      for libdir in $libdirs; do
	if test -n "$finish_cmds"; then
	  # Do each command in the finish commands.
	  func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
'"$cmd"'"'
	fi
	if test -n "$finish_eval"; then
	  # Do the single finish_eval.
	  eval cmds=\"$finish_eval\"
	  $opt_dry_run || eval "$cmds" || func_append admincmds "
       $cmds"
	fi
      done
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2712

2713
2714
    # Exit here if they wanted silent mode.
    $opt_silent && exit $EXIT_SUCCESS
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2715

2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
      echo "----------------------------------------------------------------------"
      echo "Libraries have been installed in:"
      for libdir in $libdirs; do
	$ECHO "   $libdir"
      done
      echo
      echo "If you ever happen to want to link against installed libraries"
      echo "in a given directory, LIBDIR, you must either use libtool, and"
      echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
      echo "flag during linking and do at least one of the following:"
      if test -n "$shlibpath_var"; then
	echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
	echo "     during execution"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2730
      fi
2731
2732
2733
      if test -n "$runpath_var"; then
	echo "   - add LIBDIR to the \`$runpath_var' environment variable"
	echo "     during linking"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2734
      fi
2735
2736
2737
      if test -n "$hardcode_libdir_flag_spec"; then
	libdir=LIBDIR
	eval flag=\"$hardcode_libdir_flag_spec\"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2738

2739
	$ECHO "   - use the \`$flag' linker flag"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2740
      fi
2741
2742
      if test -n "$admincmds"; then
	$ECHO "   - have your system administrator run these commands:$admincmds"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2743
      fi
2744
2745
      if test -f /etc/ld.so.conf; then
	echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2746
      fi
2747
      echo
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2748

2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
      echo "See any operating system documentation about shared libraries for"
      case $host in
	solaris2.[6789]|solaris2.1[0-9])
	  echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
	  echo "pages."
	  ;;
	*)
	  echo "more information, such as the ld(1) and ld.so(8) manual pages."
	  ;;
      esac
      echo "----------------------------------------------------------------------"
    fi
    exit $EXIT_SUCCESS
}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2763

2764
test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2765
2766


2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
# func_mode_install arg...
func_mode_install ()
{
    $opt_debug
    # There may be an optional sh(1) argument at the beginning of
    # install_prog (especially on Windows NT).
    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
       # Allow the use of GNU shtool's install command.
       case $nonopt in *shtool*) :;; *) false;; esac; then
      # Aesthetically quote it.
      func_quote_for_eval "$nonopt"
      install_prog="$func_quote_for_eval_result "
      arg=$1
      shift
    else
      install_prog=
      arg=$nonopt
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2785

2786
2787
2788
2789
2790
2791
2792
2793
2794
    # The real first argument should be the name of the installation program.
    # Aesthetically quote it.
    func_quote_for_eval "$arg"
    func_append install_prog "$func_quote_for_eval_result"
    install_shared_prog=$install_prog
    case " $install_prog " in
      *[\\\ /]cp\ *) install_cp=: ;;
      *) install_cp=false ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2795

2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
    # We need to accept at least all the BSD install flags.
    dest=
    files=
    opts=
    prev=
    install_type=
    isdir=no
    stripme=
    no_mode=:
    for arg
    do
      arg2=
      if test -n "$dest"; then
	func_append files " $dest"
	dest=$arg
	continue
      fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2813

2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
      case $arg in
      -d) isdir=yes ;;
      -f)
	if $install_cp; then :; else
	  prev=$arg
	fi
	;;
      -g | -m | -o)
	prev=$arg
	;;
      -s)
	stripme=" -s"
	continue
	;;
      -*)
	;;
      *)
	# If the previous option needed an argument, then skip it.
	if test -n "$prev"; then
	  if test "x$prev" = x-m && test -n "$install_override_mode"; then
	    arg2=$install_override_mode
	    no_mode=false
	  fi
	  prev=
	else
	  dest=$arg
	  continue
	fi
	;;
      esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2844

2845
2846
2847
2848
2849
2850
2851
2852
      # Aesthetically quote the argument.
      func_quote_for_eval "$arg"
      func_append install_prog " $func_quote_for_eval_result"
      if test -n "$arg2"; then
	func_quote_for_eval "$arg2"
      fi
      func_append install_shared_prog " $func_quote_for_eval_result"
    done
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2853

2854
2855
    test -z "$install_prog" && \
      func_fatal_help "you must specify an install program"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2856

2857
2858
    test -n "$prev" && \
      func_fatal_help "the \`$prev' option requires an argument"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2859

2860
2861
2862
2863
2864
2865
    if test -n "$install_override_mode" && $no_mode; then
      if $install_cp; then :; else
	func_quote_for_eval "$install_override_mode"
	func_append install_shared_prog " -m $func_quote_for_eval_result"
      fi
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2866

2867
2868
2869
2870
2871
2872
2873
    if test -z "$files"; then
      if test -z "$dest"; then
	func_fatal_help "no file or destination specified"
      else
	func_fatal_help "you must specify a destination"
      fi
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2874

2875
2876
2877
    # Strip any trailing slash from the destination.
    func_stripname '' '/' "$dest"
    dest=$func_stripname_result
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2878

2879
2880
2881
2882
2883
2884
2885
2886
2887
    # Check to see that the destination is a directory.
    test -d "$dest" && isdir=yes
    if test "$isdir" = yes; then
      destdir="$dest"
      destname=
    else
      func_dirname_and_basename "$dest" "" "."
      destdir="$func_dirname_result"
      destname="$func_basename_result"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2888

2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
      # Not a directory, so check to see that there is only one file specified.
      set dummy $files; shift
      test "$#" -gt 1 && \
	func_fatal_help "\`$dest' is not a directory"
    fi
    case $destdir in
    [\\/]* | [A-Za-z]:[\\/]*) ;;
    *)
      for file in $files; do
	case $file in
	*.lo) ;;
	*)
	  func_fatal_help "\`$destdir' must be an absolute directory name"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2902
	  ;;
2903
2904
2905
2906
	esac
      done
      ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2907

2908
2909
2910
    # This variable tells wrapper scripts just to set variables rather
    # than running their programs.
    libtool_install_magic="$magic"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2911

2912
2913
2914
2915
    staticlibs=
    future_libdirs=
    current_libdirs=
    for file in $files; do
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2916

2917
2918
2919
2920
2921
2922
      # Do each installation.
      case $file in
      *.$libext)
	# Do the static libraries later.
	func_append staticlibs " $file"
	;;
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2923

2924
2925
2926
      *.la)
	func_resolve_sysroot "$file"
	file=$func_resolve_sysroot_result
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2927

2928
2929
2930
	# Check to see that this really is a libtool archive.
	func_lalib_unsafe_p "$file" \
	  || func_fatal_help "\`$file' is not a valid libtool archive"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2931

2932
2933
2934
2935
	library_names=
	old_library=
	relink_command=
	func_source "$file"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2936

2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
	# Add the libdir to current_libdirs if it is the destination.
	if test "X$destdir" = "X$libdir"; then
	  case "$current_libdirs " in
	  *" $libdir "*) ;;
	  *) func_append current_libdirs " $libdir" ;;
	  esac
	else
	  # Note the libdir as a future libdir.
	  case "$future_libdirs " in
	  *" $libdir "*) ;;
	  *) func_append future_libdirs " $libdir" ;;
	  esac
	fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2950

2951
2952
2953
	func_dirname "$file" "/" ""
	dir="$func_dirname_result"
	func_append dir "$objdir"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2954

2955
2956
2957
	if test -n "$relink_command"; then
	  # Determine the prefix the user has applied to our future dir.
	  inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2958

2959
2960
2961
2962
2963
2964
2965
2966
	  # Don't allow the user to place us outside of our expected
	  # location b/c this prevents finding dependent libraries that
	  # are installed to the same prefix.
	  # At present, this check doesn't affect windows .dll's that
	  # are installed into $libdir/../bin (currently, that works fine)
	  # but it's something to keep an eye on.
	  test "$inst_prefix_dir" = "$destdir" && \
	    func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2967

2968
2969
2970
	  if test -n "$inst_prefix_dir"; then
	    # Stick the inst_prefix_dir data into the link command.
	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2971
	  else
2972
	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2973
2974
	  fi

2975
2976
2977
	  func_warning "relinking \`$file'"
	  func_show_eval "$relink_command" \
	    'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2978
2979
	fi

2980
2981
2982
2983
2984
	# See the names of the shared library.
	set dummy $library_names; shift
	if test -n "$1"; then
	  realname="$1"
	  shift
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2985

2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
	  srcname="$realname"
	  test -n "$relink_command" && srcname="$realname"T

	  # Install the shared library and build the symlinks.
	  func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
	      'exit $?'
	  tstripme="$stripme"
	  case $host_os in
	  cygwin* | mingw* | pw32* | cegcc*)
	    case $realname in
	    *.dll.a)
	      tstripme=""
	      ;;
	    esac
	    ;;
For faster browsing, not all history is shown. View entire blame