| 1 | # ltmain.sh - Provide generalized library-building support services. |
|---|
| 2 | # NOTE: Changing this file will not affect anything until you rerun ltconfig. |
|---|
| 3 | # |
|---|
| 4 | # Copyright (C) 1996-1999 Free Software Foundation, Inc. |
|---|
| 5 | # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 |
|---|
| 6 | # |
|---|
| 7 | # This program is free software; you can redistribute it and/or modify |
|---|
| 8 | # it under the terms of the GNU General Public License as published by |
|---|
| 9 | # the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | # (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, but |
|---|
| 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | # General Public License for more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License |
|---|
| 18 | # along with this program; if not, write to the Free Software |
|---|
| 19 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|---|
| 20 | # |
|---|
| 21 | # As a special exception to the GNU General Public License, if you |
|---|
| 22 | # distribute this file as part of a program that contains a |
|---|
| 23 | # configuration script generated by Autoconf, you may include it under |
|---|
| 24 | # the same distribution terms that you use for the rest of that program. |
|---|
| 25 | |
|---|
| 26 | # Check that we have a working $echo. |
|---|
| 27 | if test "X$1" = X--no-reexec; then |
|---|
| 28 | # Discard the --no-reexec flag, and continue. |
|---|
| 29 | shift |
|---|
| 30 | elif test "X$1" = X--fallback-echo; then |
|---|
| 31 | # Avoid inline document here, it may be left over |
|---|
| 32 | : |
|---|
| 33 | elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then |
|---|
| 34 | # Yippee, $echo works! |
|---|
| 35 | : |
|---|
| 36 | else |
|---|
| 37 | # Restart under the correct shell, and then maybe $echo will work. |
|---|
| 38 | exec $SHELL "$0" --no-reexec ${1+"$@"} |
|---|
| 39 | fi |
|---|
| 40 | |
|---|
| 41 | if test "X$1" = X--fallback-echo; then |
|---|
| 42 | # used as fallback echo |
|---|
| 43 | shift |
|---|
| 44 | cat <<EOF |
|---|
| 45 | $* |
|---|
| 46 | EOF |
|---|
| 47 | exit 0 |
|---|
| 48 | fi |
|---|
| 49 | |
|---|
| 50 | # The name of this program. |
|---|
| 51 | progname=`$echo "$0" | sed 's%^.*/%%'` |
|---|
| 52 | modename="$progname" |
|---|
| 53 | |
|---|
| 54 | # Constants. |
|---|
| 55 | PROGRAM=ltmain.sh |
|---|
| 56 | PACKAGE=libtool |
|---|
| 57 | VERSION=1.3c |
|---|
| 58 | TIMESTAMP=" (1.618 1999/10/04 14:44:15)" |
|---|
| 59 | |
|---|
| 60 | default_mode= |
|---|
| 61 | help="Try \`$progname --help' for more information." |
|---|
| 62 | magic="%%%MAGIC variable%%%" |
|---|
| 63 | mkdir="mkdir" |
|---|
| 64 | mv="mv -f" |
|---|
| 65 | rm="rm -f" |
|---|
| 66 | |
|---|
| 67 | # Sed substitution that helps us do robust quoting. It backslashifies |
|---|
| 68 | # metacharacters that are still active within double-quoted strings. |
|---|
| 69 | Xsed='sed -e 1s/^X//' |
|---|
| 70 | sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g' |
|---|
| 71 | SP2NL='tr \040 \012' |
|---|
| 72 | NL2SP='tr \015\012 \040\040' |
|---|
| 73 | |
|---|
| 74 | # NLS nuisances. |
|---|
| 75 | # Only set LANG and LC_ALL to C if already set. |
|---|
| 76 | # These must not be set unconditionally because not all systems understand |
|---|
| 77 | # e.g. LANG=C (notably SCO). |
|---|
| 78 | # We save the old values to restore during execute mode. |
|---|
| 79 | if test "${LC_ALL+set}" = set; then |
|---|
| 80 | save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL |
|---|
| 81 | fi |
|---|
| 82 | if test "${LANG+set}" = set; then |
|---|
| 83 | save_LANG="$LANG"; LANG=C; export LANG |
|---|
| 84 | fi |
|---|
| 85 | |
|---|
| 86 | if test "$LTCONFIG_VERSION" != "$VERSION"; then |
|---|
| 87 | echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2 |
|---|
| 88 | echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 |
|---|
| 89 | exit 1 |
|---|
| 90 | fi |
|---|
| 91 | |
|---|
| 92 | if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then |
|---|
| 93 | echo "$modename: not configured to build any kind of library" 1>&2 |
|---|
| 94 | echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 |
|---|
| 95 | exit 1 |
|---|
| 96 | fi |
|---|
| 97 | |
|---|
| 98 | # Global variables. |
|---|
| 99 | mode=$default_mode |
|---|
| 100 | nonopt= |
|---|
| 101 | prev= |
|---|
| 102 | prevopt= |
|---|
| 103 | run= |
|---|
| 104 | show="$echo" |
|---|
| 105 | show_help= |
|---|
| 106 | execute_dlfiles= |
|---|
| 107 | lo2o="s/\\.lo\$/.${objext}/" |
|---|
| 108 | o2lo="s/\\.${objext}\$/.lo/" |
|---|
| 109 | |
|---|
| 110 | # Parse our command line options once, thoroughly. |
|---|
| 111 | while test $# -gt 0 |
|---|
| 112 | do |
|---|
| 113 | arg="$1" |
|---|
| 114 | shift |
|---|
| 115 | |
|---|
| 116 | case "$arg" in |
|---|
| 117 | -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; |
|---|
| 118 | *) optarg= ;; |
|---|
| 119 | esac |
|---|
| 120 | |
|---|
| 121 | # If the previous option needs an argument, assign it. |
|---|
| 122 | if test -n "$prev"; then |
|---|
| 123 | case "$prev" in |
|---|
| 124 | execute_dlfiles) |
|---|
| 125 | eval "$prev=\"\$$prev \$arg\"" |
|---|
| 126 | ;; |
|---|
| 127 | *) |
|---|
| 128 | eval "$prev=\$arg" |
|---|
| 129 | ;; |
|---|
| 130 | esac |
|---|
| 131 | |
|---|
| 132 | prev= |
|---|
| 133 | prevopt= |
|---|
| 134 | continue |
|---|
| 135 | fi |
|---|
| 136 | |
|---|
| 137 | # Have we seen a non-optional argument yet? |
|---|
| 138 | case "$arg" in |
|---|
| 139 | --help) |
|---|
| 140 | show_help=yes |
|---|
| 141 | ;; |
|---|
| 142 | |
|---|
| 143 | --version) |
|---|
| 144 | echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" |
|---|
| 145 | exit 0 |
|---|
| 146 | ;; |
|---|
| 147 | |
|---|
| 148 | --config) |
|---|
| 149 | sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0 |
|---|
| 150 | exit 0 |
|---|
| 151 | ;; |
|---|
| 152 | |
|---|
| 153 | --debug) |
|---|
| 154 | echo "$progname: enabling shell trace mode" |
|---|
| 155 | set -x |
|---|
| 156 | ;; |
|---|
| 157 | |
|---|
| 158 | --dry-run | -n) |
|---|
| 159 | run=: |
|---|
| 160 | ;; |
|---|
| 161 | |
|---|
| 162 | --features) |
|---|
| 163 | echo "host: $host" |
|---|
| 164 | if test "$build_libtool_libs" = yes; then |
|---|
| 165 | echo "enable shared libraries" |
|---|
| 166 | else |
|---|
| 167 | echo "disable shared libraries" |
|---|
| 168 | fi |
|---|
| 169 | if test "$build_old_libs" = yes; then |
|---|
| 170 | echo "enable static libraries" |
|---|
| 171 | else |
|---|
| 172 | echo "disable static libraries" |
|---|
| 173 | fi |
|---|
| 174 | exit 0 |
|---|
| 175 | ;; |
|---|
| 176 | |
|---|
| 177 | --finish) mode="finish" ;; |
|---|
| 178 | |
|---|
| 179 | --mode) prevopt="--mode" prev=mode ;; |
|---|
| 180 | --mode=*) mode="$optarg" ;; |
|---|
| 181 | |
|---|
| 182 | --quiet | --silent) |
|---|
| 183 | show=: |
|---|
| 184 | ;; |
|---|
| 185 | |
|---|
| 186 | -dlopen) |
|---|
| 187 | prevopt="-dlopen" |
|---|
| 188 | prev=execute_dlfiles |
|---|
| 189 | ;; |
|---|
| 190 | |
|---|
| 191 | -*) |
|---|
| 192 | $echo "$modename: unrecognized option \`$arg'" 1>&2 |
|---|
| 193 | $echo "$help" 1>&2 |
|---|
| 194 | exit 1 |
|---|
| 195 | ;; |
|---|
| 196 | |
|---|
| 197 | *) |
|---|
| 198 | nonopt="$arg" |
|---|
| 199 | break |
|---|
| 200 | ;; |
|---|
| 201 | esac |
|---|
| 202 | done |
|---|
| 203 | |
|---|
| 204 | if test -n "$prevopt"; then |
|---|
| 205 | $echo "$modename: option \`$prevopt' requires an argument" 1>&2 |
|---|
| 206 | $echo "$help" 1>&2 |
|---|
| 207 | exit 1 |
|---|
| 208 | fi |
|---|
| 209 | |
|---|
| 210 | if test -z "$show_help"; then |
|---|
| 211 | |
|---|
| 212 | # Infer the operation mode. |
|---|
| 213 | if test -z "$mode"; then |
|---|
| 214 | case "$nonopt" in |
|---|
| 215 | *cc | *++ | gcc* | *-gcc*) |
|---|
| 216 | mode=link |
|---|
| 217 | for arg |
|---|
| 218 | do |
|---|
| 219 | case "$arg" in |
|---|
| 220 | -c) |
|---|
| 221 | mode=compile |
|---|
| 222 | break |
|---|
| 223 | ;; |
|---|
| 224 | esac |
|---|
| 225 | done |
|---|
| 226 | ;; |
|---|
| 227 | *db | *dbx | *strace | *truss) |
|---|
| 228 | mode=execute |
|---|
| 229 | ;; |
|---|
| 230 | *install*|cp|mv) |
|---|
| 231 | mode=install |
|---|
| 232 | ;; |
|---|
| 233 | *rm) |
|---|
| 234 | mode=uninstall |
|---|
| 235 | ;; |
|---|
| 236 | *) |
|---|
| 237 | # If we have no mode, but dlfiles were specified, then do execute mode. |
|---|
| 238 | test -n "$execute_dlfiles" && mode=execute |
|---|
| 239 | |
|---|
| 240 | # Just use the default operation mode. |
|---|
| 241 | if test -z "$mode"; then |
|---|
| 242 | if test -n "$nonopt"; then |
|---|
| 243 | $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 |
|---|
| 244 | else |
|---|
| 245 | $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 |
|---|
| 246 | fi |
|---|
| 247 | fi |
|---|
| 248 | ;; |
|---|
| 249 | esac |
|---|
| 250 | fi |
|---|
| 251 | |
|---|
| 252 | # Only execute mode is allowed to have -dlopen flags. |
|---|
| 253 | if test -n "$execute_dlfiles" && test "$mode" != execute; then |
|---|
| 254 | $echo "$modename: unrecognized option \`-dlopen'" 1>&2 |
|---|
| 255 | $echo "$help" 1>&2 |
|---|
| 256 | exit 1 |
|---|
| 257 | fi |
|---|
| 258 | |
|---|
| 259 | # Change the help message to a mode-specific one. |
|---|
| 260 | generic_help="$help" |
|---|
| 261 | help="Try \`$modename --help --mode=$mode' for more information." |
|---|
| 262 | |
|---|
| 263 | # These modes are in order of execution frequency so that they run quickly. |
|---|
| 264 | case "$mode" in |
|---|
| 265 | # libtool compile mode |
|---|
| 266 | compile) |
|---|
| 267 | modename="$modename: compile" |
|---|
| 268 | # Get the compilation command and the source file. |
|---|
| 269 | base_compile= |
|---|
| 270 | lastarg= |
|---|
| 271 | srcfile="$nonopt" |
|---|
| 272 | suppress_output= |
|---|
| 273 | |
|---|
| 274 | user_target=no |
|---|
| 275 | for arg |
|---|
| 276 | do |
|---|
| 277 | # Accept any command-line options. |
|---|
| 278 | case "$arg" in |
|---|
| 279 | -o) |
|---|
| 280 | if test "$user_target" != "no"; then |
|---|
| 281 | $echo "$modename: you cannot specify \`-o' more than once" 1>&2 |
|---|
| 282 | exit 1 |
|---|
| 283 | fi |
|---|
| 284 | user_target=next |
|---|
| 285 | ;; |
|---|
| 286 | |
|---|
| 287 | -static) |
|---|
| 288 | build_old_libs=yes |
|---|
| 289 | continue |
|---|
| 290 | ;; |
|---|
| 291 | esac |
|---|
| 292 | |
|---|
| 293 | case "$user_target" in |
|---|
| 294 | next) |
|---|
| 295 | # The next one is the -o target name |
|---|
| 296 | user_target=yes |
|---|
| 297 | continue |
|---|
| 298 | ;; |
|---|
| 299 | yes) |
|---|
| 300 | # We got the output file |
|---|
| 301 | user_target=set |
|---|
| 302 | libobj="$arg" |
|---|
| 303 | continue |
|---|
| 304 | ;; |
|---|
| 305 | esac |
|---|
| 306 | |
|---|
| 307 | # Accept the current argument as the source file. |
|---|
| 308 | lastarg="$srcfile" |
|---|
| 309 | srcfile="$arg" |
|---|
| 310 | |
|---|
| 311 | # Aesthetically quote the previous argument. |
|---|
| 312 | |
|---|
| 313 | # Backslashify any backslashes, double quotes, and dollar signs. |
|---|
| 314 | # These are the only characters that are still specially |
|---|
| 315 | # interpreted inside of double-quoted scrings. |
|---|
| 316 | lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` |
|---|
| 317 | |
|---|
| 318 | # Double-quote args containing other shell metacharacters. |
|---|
| 319 | # Many Bourne shells cannot handle close brackets correctly in scan |
|---|
| 320 | # sets, so we specify it separately. |
|---|
| 321 | case "$lastarg" in |
|---|
| 322 | *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) |
|---|
| 323 | lastarg="\"$lastarg\"" |
|---|
| 324 | ;; |
|---|
| 325 | esac |
|---|
| 326 | |
|---|
| 327 | # Add the previous argument to base_compile. |
|---|
| 328 | if test -z "$base_compile"; then |
|---|
| 329 | base_compile="$lastarg" |
|---|
| 330 | else |
|---|
| 331 | base_compile="$base_compile $lastarg" |
|---|
| 332 | fi |
|---|
| 333 | done |
|---|
| 334 | |
|---|
| 335 | case "$user_target" in |
|---|
| 336 | set) |
|---|
| 337 | ;; |
|---|
| 338 | no) |
|---|
| 339 | # Get the name of the library object. |
|---|
| 340 | libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` |
|---|
| 341 | ;; |
|---|
| 342 | *) |
|---|
| 343 | $echo "$modename: you must specify a target with \`-o'" 1>&2 |
|---|
| 344 | exit 1 |
|---|
| 345 | ;; |
|---|
| 346 | esac |
|---|
| 347 | |
|---|
| 348 | # Recognize several different file suffixes. |
|---|
| 349 | # If the user specifies -o file.o, it is replaced with file.lo |
|---|
| 350 | xform='[cCFSfmso]' |
|---|
| 351 | case "$libobj" in |
|---|
| 352 | *.ada) xform=ada ;; |
|---|
| 353 | *.adb) xform=adb ;; |
|---|
| 354 | *.ads) xform=ads ;; |
|---|
| 355 | *.asm) xform=asm ;; |
|---|
| 356 | *.c++) xform=c++ ;; |
|---|
| 357 | *.cc) xform=cc ;; |
|---|
| 358 | *.cpp) xform=cpp ;; |
|---|
| 359 | *.cxx) xform=cxx ;; |
|---|
| 360 | *.f90) xform=f90 ;; |
|---|
| 361 | *.for) xform=for ;; |
|---|
| 362 | esac |
|---|
| 363 | |
|---|
| 364 | libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` |
|---|
| 365 | |
|---|
| 366 | case "$libobj" in |
|---|
| 367 | *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; |
|---|
| 368 | *) |
|---|
| 369 | $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 |
|---|
| 370 | exit 1 |
|---|
| 371 | ;; |
|---|
| 372 | esac |
|---|
| 373 | |
|---|
| 374 | if test -z "$base_compile"; then |
|---|
| 375 | $echo "$modename: you must specify a compilation command" 1>&2 |
|---|
| 376 | $echo "$help" 1>&2 |
|---|
| 377 | exit 1 |
|---|
| 378 | fi |
|---|
| 379 | |
|---|
| 380 | # Delete any leftover library objects. |
|---|
| 381 | if test "$build_old_libs" = yes; then |
|---|
| 382 | removelist="$obj $libobj" |
|---|
| 383 | else |
|---|
| 384 | removelist="$libobj" |
|---|
| 385 | fi |
|---|
| 386 | |
|---|
| 387 | $run $rm $removelist |
|---|
| 388 | trap "$run $rm $removelist; exit 1" 1 2 15 |
|---|
| 389 | |
|---|
| 390 | # Calculate the filename of the output object if compiler does |
|---|
| 391 | # not support -o with -c |
|---|
| 392 | if test "$compiler_c_o" = no; then |
|---|
| 393 | output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext} |
|---|
| 394 | lockfile="$output_obj.lock" |
|---|
| 395 | removelist="$removelist $output_obj $lockfile" |
|---|
| 396 | trap "$run $rm $removelist; exit 1" 1 2 15 |
|---|
| 397 | else |
|---|
| 398 | need_locks=no |
|---|
| 399 | lockfile= |
|---|
| 400 | fi |
|---|
| 401 | |
|---|
| 402 | # Lock this critical section if it is needed |
|---|
| 403 | # We use this script file to make the link, it avoids creating a new file |
|---|
| 404 | if test "$need_locks" = yes; then |
|---|
| 405 | until ln "$0" "$lockfile" 2>/dev/null; do |
|---|
| 406 | $show "Waiting for $lockfile to be removed" |
|---|
| 407 | sleep 2 |
|---|
| 408 | done |
|---|
| 409 | elif test "$need_locks" = warn; then |
|---|
| 410 | if test -f "$lockfile"; then |
|---|
| 411 | echo "\ |
|---|
| 412 | *** ERROR, $lockfile exists and contains: |
|---|
| 413 | `cat $lockfile 2>/dev/null` |
|---|
| 414 | |
|---|
| 415 | This indicates that another process is trying to use the same |
|---|
| 416 | temporary object file, and libtool could not work around it because |
|---|
| 417 | your compiler does not support \`-c' and \`-o' together. If you |
|---|
| 418 | repeat this compilation, it may succeed, by chance, but you had better |
|---|
| 419 | avoid parallel builds (make -j) in this platform, or get a better |
|---|
| 420 | compiler." |
|---|
| 421 | |
|---|
| 422 | $run $rm $removelist |
|---|
| 423 | exit 1 |
|---|
| 424 | fi |
|---|
| 425 | echo $srcfile > "$lockfile" |
|---|
| 426 | fi |
|---|
| 427 | |
|---|
| 428 | if test -n "$fix_srcfile_path"; then |
|---|
| 429 | eval srcfile=\"$fix_srcfile_path\" |
|---|
| 430 | fi |
|---|
| 431 | |
|---|
| 432 | # Only build a PIC object if we are building libtool libraries. |
|---|
| 433 | if test "$build_libtool_libs" = yes; then |
|---|
| 434 | # Without this assignment, base_compile gets emptied. |
|---|
| 435 | fbsd_hideous_sh_bug=$base_compile |
|---|
| 436 | |
|---|
| 437 | if test "$pic_mode" != no; then |
|---|
| 438 | # All platforms use -DPIC, to notify preprocessed assembler code. |
|---|
| 439 | command="$base_compile $pic_flag -DPIC $srcfile" |
|---|
| 440 | else |
|---|
| 441 | # Don't build PIC code |
|---|
| 442 | command="$base_compile $srcfile" |
|---|
| 443 | fi |
|---|
| 444 | if test "$build_old_libs" = yes; then |
|---|
| 445 | lo_libobj="$libobj" |
|---|
| 446 | dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` |
|---|
| 447 | if test "X$dir" = "X$libobj"; then |
|---|
| 448 | dir="$objdir" |
|---|
| 449 | else |
|---|
| 450 | dir="$dir/$objdir" |
|---|
| 451 | fi |
|---|
| 452 | libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` |
|---|
| 453 | |
|---|
| 454 | if test -d "$dir"; then |
|---|
| 455 | $show "$rm $libobj" |
|---|
| 456 | $run $rm $libobj |
|---|
| 457 | else |
|---|
| 458 | $show "$mkdir $dir" |
|---|
| 459 | $run $mkdir $dir |
|---|
| 460 | status=$? |
|---|
| 461 | if test $status -ne 0 && test ! -d $dir; then |
|---|
| 462 | exit $status |
|---|
| 463 | fi |
|---|
| 464 | fi |
|---|
| 465 | fi |
|---|
| 466 | if test "$compiler_o_lo" = yes; then |
|---|
| 467 | output_obj="$libobj" |
|---|
| 468 | command="$command -o $output_obj" |
|---|
| 469 | elif test "$compiler_c_o" = yes; then |
|---|
| 470 | output_obj="$obj" |
|---|
| 471 | command="$command -o $output_obj" |
|---|
| 472 | fi |
|---|
| 473 | |
|---|
| 474 | $run $rm "$output_obj" |
|---|
| 475 | $show "$command" |
|---|
| 476 | if $run eval "$command"; then : |
|---|
| 477 | else |
|---|
| 478 | test -n "$output_obj" && $run $rm $removelist |
|---|
| 479 | exit 1 |
|---|
| 480 | fi |
|---|
| 481 | |
|---|
| 482 | if test "$need_locks" = warn && |
|---|
| 483 | test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then |
|---|
| 484 | echo "\ |
|---|
| 485 | *** ERROR, $lockfile contains: |
|---|
| 486 | `cat $lockfile 2>/dev/null` |
|---|
| 487 | |
|---|
| 488 | but it should contain: |
|---|
| 489 | $srcfile |
|---|
| 490 | |
|---|
| 491 | This indicates that another process is trying to use the same |
|---|
| 492 | temporary object file, and libtool could not work around it because |
|---|
| 493 | your compiler does not support \`-c' and \`-o' together. If you |
|---|
| 494 | repeat this compilation, it may succeed, by chance, but you had better |
|---|
| 495 | avoid parallel builds (make -j) in this platform, or get a better |
|---|
| 496 | compiler." |
|---|
| 497 | |
|---|
| 498 | $run $rm $removelist |
|---|
| 499 | exit 1 |
|---|
| 500 | fi |
|---|
| 501 | |
|---|
| 502 | # Just move the object if needed, then go on to compile the next one |
|---|
| 503 | if test x"$output_obj" != x"$libobj"; then |
|---|
| 504 | $show "$mv $output_obj $libobj" |
|---|
| 505 | if $run $mv $output_obj $libobj; then : |
|---|
| 506 | else |
|---|
| 507 | error=$? |
|---|
| 508 | $run $rm $removelist |
|---|
| 509 | exit $error |
|---|
| 510 | fi |
|---|
| 511 | fi |
|---|
| 512 | |
|---|
| 513 | # If we have no pic_flag, then copy the object into place and finish. |
|---|
| 514 | if (test -z "$pic_flag" || test "$pic_mode" != default) && |
|---|
| 515 | test "$build_old_libs" = yes; then |
|---|
| 516 | # Rename the .lo from within objdir to obj |
|---|
| 517 | if test -f $obj; then |
|---|
| 518 | $show $rm $obj |
|---|
| 519 | $run $rm $obj |
|---|
| 520 | fi |
|---|
| 521 | |
|---|
| 522 | $show "$mv $libobj $obj" |
|---|
| 523 | if $run $mv $libobj $obj; then : |
|---|
| 524 | else |
|---|
| 525 | error=$? |
|---|
| 526 | $run $rm $removelist |
|---|
| 527 | exit $error |
|---|
| 528 | fi |
|---|
| 529 | |
|---|
| 530 | xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` |
|---|
| 531 | if test "X$xdir" = "X$obj"; then |
|---|
| 532 | xdir="." |
|---|
| 533 | else |
|---|
| 534 | xdir="$xdir" |
|---|
| 535 | fi |
|---|
| 536 | baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` |
|---|
| 537 | libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` |
|---|
| 538 | fi |
|---|
| 539 | |
|---|
| 540 | # Allow error messages only from the first compilation. |
|---|
| 541 | suppress_output=' >/dev/null 2>&1' |
|---|
| 542 | fi |
|---|
| 543 | |
|---|
| 544 | # Only build a position-dependent object if we build old libraries. |
|---|
| 545 | if test "$build_old_libs" = yes; then |
|---|
| 546 | if test "$pic_mode" != yes; then |
|---|
| 547 | # Don't build PIC code |
|---|
| 548 | command="$base_compile $srcfile" |
|---|
| 549 | else |
|---|
| 550 | # All platforms use -DPIC, to notify preprocessed assembler code. |
|---|
| 551 | command="$base_compile $pic_flag -DPIC $srcfile" |
|---|
| 552 | fi |
|---|
| 553 | if test "$compiler_c_o" = yes; then |
|---|
| 554 | command="$command -o $obj" |
|---|
| 555 | output_obj="$obj" |
|---|
| 556 | fi |
|---|
| 557 | |
|---|
| 558 | # Suppress compiler output if we already did a PIC compilation. |
|---|
| 559 | command="$command$suppress_output" |
|---|
| 560 | $run $rm "$output_obj" |
|---|
| 561 | $show "$command" |
|---|
| 562 | if $run eval "$command"; then : |
|---|
| 563 | else |
|---|
| 564 | $run $rm $removelist |
|---|
| 565 | exit 1 |
|---|
| 566 | fi |
|---|
| 567 | |
|---|
| 568 | if test "$need_locks" = warn && |
|---|
| 569 | test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then |
|---|
| 570 | echo "\ |
|---|
| 571 | *** ERROR, $lockfile contains: |
|---|
| 572 | `cat $lockfile 2>/dev/null` |
|---|
| 573 | |
|---|
| 574 | but it should contain: |
|---|
| 575 | $srcfile |
|---|
| 576 | |
|---|
| 577 | This indicates that another process is trying to use the same |
|---|
| 578 | temporary object file, and libtool could not work around it because |
|---|
| 579 | your compiler does not support \`-c' and \`-o' together. If you |
|---|
| 580 | repeat this compilation, it may succeed, by chance, but you had better |
|---|
| 581 | avoid parallel builds (make -j) in this platform, or get a better |
|---|
| 582 | compiler." |
|---|
| 583 | |
|---|
| 584 | $run $rm $removelist |
|---|
| 585 | exit 1 |
|---|
| 586 | fi |
|---|
| 587 | |
|---|
| 588 | # Just move the object if needed |
|---|
| 589 | if test x"$output_obj" != x"$obj"; then |
|---|
| 590 | $show "$mv $output_obj $obj" |
|---|
| 591 | if $run $mv $output_obj $obj; then : |
|---|
| 592 | else |
|---|
| 593 | error=$? |
|---|
| 594 | $run $rm $removelist |
|---|
| 595 | exit $error |
|---|
| 596 | fi |
|---|
| 597 | fi |
|---|
| 598 | |
|---|
| 599 | # Create an invalid libtool object if no PIC, so that we do not |
|---|
| 600 | # accidentally link it into a program. |
|---|
| 601 | if test "$build_libtool_libs" != yes; then |
|---|
| 602 | $show "echo timestamp > $libobj" |
|---|
| 603 | $run eval "echo timestamp > \$libobj" || exit $? |
|---|
| 604 | else |
|---|
| 605 | # Move the .lo from within objdir |
|---|
| 606 | $show "$mv $libobj $lo_libobj" |
|---|
| 607 | if $run $mv $libobj $lo_libobj; then : |
|---|
| 608 | else |
|---|
| 609 | error=$? |
|---|
| 610 | $run $rm $removelist |
|---|
| 611 | exit $error |
|---|
| 612 | fi |
|---|
| 613 | fi |
|---|
| 614 | fi |
|---|
| 615 | |
|---|
| 616 | # Unlock the critical section if it was locked |
|---|
| 617 | if test "$need_locks" != no; then |
|---|
| 618 | $rm "$lockfile" |
|---|
| 619 | fi |
|---|
| 620 | |
|---|
| 621 | exit 0 |
|---|
| 622 | ;; |
|---|
| 623 | |
|---|
| 624 | # libtool link mode |
|---|
| 625 | link | relink) |
|---|
| 626 | modename="$modename: link" |
|---|
| 627 | relink=no |
|---|
| 628 | test "$mode" = "relink" && relink=yes |
|---|
| 629 | case "$host" in |
|---|
| 630 | *-*-cygwin* | *-*-mingw* | *-*-os2*) |
|---|
| 631 | # It is impossible to link a dll without this setting, and |
|---|
| 632 | # we shouldn't force the makefile maintainer to figure out |
|---|
| 633 | # which system we are compiling for in order to pass an extra |
|---|
| 634 | # flag for every libtool invokation. |
|---|
| 635 | # allow_undefined=no |
|---|
| 636 | |
|---|
| 637 | # FIXME: Unfortunately, there are problems with the above when trying |
|---|
| 638 | # to make a dll which has undefined symbols, in which case not |
|---|
| 639 | # even a static library is built. For now, we need to specify |
|---|
| 640 | # -no-undefined on the libtool link line when we can be certain |
|---|
| 641 | # that all symbols are satisfied, otherwise we get a static library. |
|---|
| 642 | allow_undefined=yes |
|---|
| 643 | ;; |
|---|
| 644 | *) |
|---|
| 645 | allow_undefined=yes |
|---|
| 646 | ;; |
|---|
| 647 | esac |
|---|
| 648 | libtool_args="$nonopt" |
|---|
| 649 | compile_command="$nonopt" |
|---|
| 650 | finalize_command="$nonopt" |
|---|
| 651 | |
|---|
| 652 | compile_rpath= |
|---|
| 653 | finalize_rpath= |
|---|
| 654 | compile_shlibpath= |
|---|
| 655 | finalize_shlibpath= |
|---|
| 656 | convenience= |
|---|
| 657 | old_convenience= |
|---|
| 658 | deplibs= |
|---|
| 659 | old_deplibs= |
|---|
| 660 | compiler_flags= |
|---|
| 661 | linker_flags= |
|---|
| 662 | dllsearchpath= |
|---|
| 663 | lib_search_path=`pwd` |
|---|
| 664 | |
|---|
| 665 | avoid_version=no |
|---|
| 666 | dlfiles= |
|---|
| 667 | dlprefiles= |
|---|
| 668 | dlself=no |
|---|
| 669 | export_dynamic=no |
|---|
| 670 | export_symbols= |
|---|
| 671 | export_symbols_regex= |
|---|
| 672 | generated= |
|---|
| 673 | libobjs= |
|---|
| 674 | ltlibs= |
|---|
| 675 | module=no |
|---|
| 676 | no_install=no |
|---|
| 677 | objs= |
|---|
| 678 | prefer_static_libs=no |
|---|
| 679 | preload=no |
|---|
| 680 | prev= |
|---|
| 681 | prevarg= |
|---|
| 682 | release= |
|---|
| 683 | rpath= |
|---|
| 684 | xrpath= |
|---|
| 685 | perm_rpath= |
|---|
| 686 | temp_rpath= |
|---|
| 687 | thread_safe=no |
|---|
| 688 | vinfo= |
|---|
| 689 | |
|---|
| 690 | # We need to know -static, to get the right output filenames. |
|---|
| 691 | for arg |
|---|
| 692 | do |
|---|
| 693 | case "$arg" in |
|---|
| 694 | -all-static | -static) |
|---|
| 695 | if test "X$arg" = "X-all-static"; then |
|---|
| 696 | if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then |
|---|
| 697 | $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 |
|---|
| 698 | fi |
|---|
| 699 | if test -n "$link_static_flag"; then |
|---|
| 700 | dlopen_self=$dlopen_self_static |
|---|
| 701 | fi |
|---|
| 702 | else |
|---|
| 703 | if test -z "$pic_flag" && test -n "$link_static_flag"; then |
|---|
| 704 | dlopen_self=$dlopen_self_static |
|---|
| 705 | fi |
|---|
| 706 | fi |
|---|
| 707 | build_libtool_libs=no |
|---|
| 708 | build_old_libs=yes |
|---|
| 709 | prefer_static_libs=yes |
|---|
| 710 | break |
|---|
| 711 | ;; |
|---|
| 712 | esac |
|---|
| 713 | done |
|---|
| 714 | |
|---|
| 715 | # See if our shared archives depend on static archives. |
|---|
| 716 | test -n "$old_archive_from_new_cmds" && build_old_libs=yes |
|---|
| 717 | |
|---|
| 718 | # Go through the arguments, transforming them on the way. |
|---|
| 719 | while test $# -gt 0; do |
|---|
| 720 | arg="$1" |
|---|
| 721 | shift |
|---|
| 722 | libtool_args="$libtool_args $arg" |
|---|
| 723 | |
|---|
| 724 | # If the previous option needs an argument, assign it. |
|---|
| 725 | if test -n "$prev"; then |
|---|
| 726 | case "$prev" in |
|---|
| 727 | output) |
|---|
| 728 | compile_command="$compile_command @OUTPUT@" |
|---|
| 729 | finalize_command="$finalize_command @OUTPUT@" |
|---|
| 730 | ;; |
|---|
| 731 | esac |
|---|
| 732 | |
|---|
| 733 | case "$prev" in |
|---|
| 734 | dlfiles|dlprefiles) |
|---|
| 735 | if test "$preload" = no; then |
|---|
| 736 | # Add the symbol object into the linking commands. |
|---|
| 737 | compile_command="$compile_command @SYMFILE@" |
|---|
| 738 | finalize_command="$finalize_command @SYMFILE@" |
|---|
| 739 | preload=yes |
|---|
| 740 | fi |
|---|
| 741 | case "$arg" in |
|---|
| 742 | *.la | *.lo) ;; # We handle these cases below. |
|---|
| 743 | force) |
|---|
| 744 | if test "$dlself" = no; then |
|---|
| 745 | dlself=needless |
|---|
| 746 | export_dynamic=yes |
|---|
| 747 | fi |
|---|
| 748 | prev= |
|---|
| 749 | continue |
|---|
| 750 | ;; |
|---|
| 751 | self) |
|---|
| 752 | if test "$prev" = dlprefiles; then |
|---|
| 753 | dlself=yes |
|---|
| 754 | elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then |
|---|
| 755 | dlself=yes |
|---|
| 756 | else |
|---|
| 757 | dlself=needless |
|---|
| 758 | export_dynamic=yes |
|---|
| 759 | fi |
|---|
| 760 | prev= |
|---|
| 761 | continue |
|---|
| 762 | ;; |
|---|
| 763 | *) |
|---|
| 764 | if test "$prev" = dlfiles; then |
|---|
| 765 | dlfiles="$dlfiles $arg" |
|---|
| 766 | else |
|---|
| 767 | dlprefiles="$dlprefiles $arg" |
|---|
| 768 | fi |
|---|
| 769 | prev= |
|---|
| 770 | ;; |
|---|
| 771 | esac |
|---|
| 772 | ;; |
|---|
| 773 | expsyms) |
|---|
| 774 | export_symbols="$arg" |
|---|
| 775 | if test ! -f "$arg"; then |
|---|
| 776 | $echo "$modename: symbol file \`$arg' does not exist" |
|---|
| 777 | exit 1 |
|---|
| 778 | fi |
|---|
| 779 | prev= |
|---|
| 780 | continue |
|---|
| 781 | ;; |
|---|
| 782 | expsyms_regex) |
|---|
| 783 | export_symbols_regex="$arg" |
|---|
| 784 | prev= |
|---|
| 785 | continue |
|---|
| 786 | ;; |
|---|
| 787 | release) |
|---|
| 788 | release="-$arg" |
|---|
| 789 | prev= |
|---|
| 790 | continue |
|---|
| 791 | ;; |
|---|
| 792 | rpath | xrpath) |
|---|
| 793 | # We need an absolute path. |
|---|
| 794 | case "$arg" in |
|---|
| 795 | [\\/]* | [A-Za-z]:[\\/]*) ;; |
|---|
| 796 | *) |
|---|
| 797 | $echo "$modename: only absolute run-paths are allowed" 1>&2 |
|---|
| 798 | exit 1 |
|---|
| 799 | ;; |
|---|
| 800 | esac |
|---|
| 801 | if test "$prev" = rpath; then |
|---|
| 802 | case "$rpath " in |
|---|
| 803 | *" $arg "*) ;; |
|---|
| 804 | *) rpath="$rpath $arg" ;; |
|---|
| 805 | esac |
|---|
| 806 | else |
|---|
| 807 | case "$xrpath " in |
|---|
| 808 | *" $arg "*) ;; |
|---|
| 809 | *) xrpath="$xrpath $arg" ;; |
|---|
| 810 | esac |
|---|
| 811 | fi |
|---|
| 812 | prev= |
|---|
| 813 | continue |
|---|
| 814 | ;; |
|---|
| 815 | xcompiler) |
|---|
| 816 | arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` |
|---|
| 817 | case "$arg" in |
|---|
| 818 | *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) |
|---|
| 819 | arg="\"$arg\"" |
|---|
| 820 | ;; |
|---|
| 821 | esac |
|---|
| 822 | compiler_flags="$compiler_flags $arg" |
|---|
| 823 | prev= |
|---|
| 824 | continue |
|---|
| 825 | ;; |
|---|
| 826 | xlinker) |
|---|
| 827 | arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` |
|---|
| 828 | case "$arg" in |
|---|
| 829 | *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) |
|---|
| 830 | arg="\"$arg\"" |
|---|
| 831 | ;; |
|---|
| 832 | esac |
|---|
| 833 | linker_flags="$linker_flags $arg" |
|---|
| 834 | compiler_flags="$compiler_flags $wl$arg" |
|---|
| 835 | prev= |
|---|
| 836 | continue |
|---|
| 837 | ;; |
|---|
| 838 | *) |
|---|
| 839 | eval "$prev=\"\$arg\"" |
|---|
| 840 | prev= |
|---|
| 841 | continue |
|---|
| 842 | ;; |
|---|
| 843 | esac |
|---|
| 844 | fi |
|---|
| 845 | |
|---|
| 846 | prevarg="$arg" |
|---|
| 847 | |
|---|
| 848 |
|---|