ltmain.sh 277 KB
Newer Older
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2001
	  ;;
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022

	-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
2023
2024
	  continue
	  ;;
2025

Emmanuel Bertin's avatar
Emmanuel Bertin committed
2026
	*)
2027
2028
2029
2030
2031
	  # 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
2032
	  ;;
2033
	esac  #  case $arg
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2034
	;;
2035
      esac    #  case $arg_mode
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2036

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

2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
    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
2056

2057
2058
2059
2060
2061
2062
    # 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 | \
2063
    *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
2064
2065
2066
2067
      func_xform "$libobj"
      libobj=$func_xform_result
      ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2068

2069
2070
2071
2072
2073
2074
    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
2075

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

2078
2079
2080
2081
2082
2083
    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
2084
2085
2086
	continue
	;;

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

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

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

2105
2106
2107
2108
2109
2110
2111
2112
    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
2113

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

2117
2118
2119
2120
2121
2122
    # 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
2123

2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
    # 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
2134

2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
    # 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
2145

2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
    # 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
2158

2159
2160
2161
2162
2163
2164
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
2165

2166
2167
2168
2169
2170
2171
	$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
2172

2173
2174
2175
    $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
2176

2177
2178
2179
2180
    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
2181

2182
2183
2184
2185
    # 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
2186

2187
2188
2189
2190
2191
2192
      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
2193

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

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

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

2204
2205
2206
2207
2208
      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
2209

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

2213
2214
2215
2216
2217
2218
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
2219

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

2224
2225
2226
2227
2228
      # 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
2229

2230
2231
2232
2233
2234
      # 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
2235

2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
    # 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
2247

2248
2249
2250
2251
      # 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
2252

2253
2254
2255
2256
2257
      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
2258

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

2262
2263
2264
2265
2266
2267
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
2268

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

2273
2274
2275
2276
2277
2278
      # 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
2279

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

2283
2284
2285
2286
2287
2288
      # 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
2289

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

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

2297
2298
2299
2300
2301
2302
2303
2304
2305
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
2306

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

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

2313
2314
2315
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
2316

2317
2318
2319
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
2320

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

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

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

2329
2330
2331
2332
2333
2334
2335
  -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
2336

2337
2338
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
2339

2340
2341
2342
2343
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
2344

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

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

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

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

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

2358
2359
2360
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
2361

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

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

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

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

2373
2374
2375
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
2376

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

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

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

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

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

2390
2391
2392
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
2393

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

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

2401
2402
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
2403

2404
The following components of LINK-COMMAND are treated specially:
Emmanuel Bertin's avatar
Emmanuel Bertin committed
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
2442
  -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
2443

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

2446
2447
2448
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
2449

2450
2451
2452
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
2453

2454
2455
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
2456

2457
2458
2459
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
2460

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

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

2467
2468
2469
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
2470

2471
2472
2473
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
2474

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

2480
2481
2482
    echo
    $ECHO "Try \`$progname --help' for more information about other modes."
}
Emmanuel Bertin's avatar
Emmanuel Bertin committed
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
2513
# 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
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
2550
# 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
2551
2552
	fi

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

2556
2557
2558
2559
2560
2561
2562
2563
	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
2564

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

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

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

2581
2582
2583
2584
2585
2586
2587
      # 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
2588

2589
2590
2591
    # 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
2592

2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
    # 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
2616

2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
    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
2628
	      else
2629
2630
2631
		$lt_unset $lt_var
	      fi"
      done
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2632

2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
      # 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
2645

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


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

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

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

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

2674
2675
2676
2677
2678
2679
    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
2680
2681
      fi

2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
      # 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
2695
      fi
2696
    fi
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2697

2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
    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
2713

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

2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
    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
2731
      fi
2732
2733
2734
      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
2735
      fi
2736
2737
2738
      if test -n "$hardcode_libdir_flag_spec"; then
	libdir=LIBDIR
	eval flag=\"$hardcode_libdir_flag_spec\"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2739

2740
	$ECHO "   - use the \`$flag' linker flag"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2741
      fi
2742
2743
      if test -n "$admincmds"; then
	$ECHO "   - have your system administrator run these commands:$admincmds"
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2744
      fi
2745
2746
      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
2747
      fi
2748
      echo
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2749

2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
      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
2764

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


2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
# 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
2786

2787
2788
2789
2790
2791
2792
2793
2794
2795
    # 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
2796

2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
    # 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
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
2844
      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
2845

2846
2847
2848
2849
2850
2851
2852
2853
      # 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
2854

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

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

2861
2862
2863
2864
2865
2866
    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
2867

2868
2869
2870
2871
2872
2873
2874
    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
2875

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

2880
2881
2882
2883
2884
2885
2886
2887
2888
    # 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
2889

2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
      # 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
2903
	  ;;
2904
2905
2906
2907
	esac
      done
      ;;
    esac
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2908

2909
2910
2911
    # 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
2912

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

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

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

2929
2930
2931
	# 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
2932

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

2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
	# 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
2951

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

2956
2957
2958
	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
2959

2960
2961
2962
2963
2964
2965
2966
2967
	  # 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
2968

2969
2970
2971
	  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
2972
	  else
2973
	    relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
Emmanuel Bertin's avatar
Emmanuel Bertin committed
2974
2975
	  fi

2976
2977
2978
	  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
2979
2980
	fi

2981
2982
2983
2984
2985
	# 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
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