ltconfig 94.2 KB
Newer Older
Owen Taylor's avatar
Owen Taylor committed
1 2 3
#! /bin/sh

# ltconfig - Create a system-specific libtool.
4
# Copyright (C) 1996-1999 Free Software Foundation, Inc.
Manish Singh's avatar
Manish Singh committed
5
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
Owen Taylor's avatar
Owen Taylor committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

# A lot of this script is taken from autoconf-2.10.

28 29 30 31 32 33
# Check that we are running under the correct shell.
SHELL=${CONFIG_SHELL-/bin/sh}
echo=echo
if test "X$1" = X--no-reexec; then
  # Discard the --no-reexec flag, and continue.
  shift
34
elif test "X$1" = X--fallback-echo; then
Manish Singh's avatar
Manish Singh committed
35 36
  # Avoid inline document here, it may be left over
  :
37 38 39 40 41 42 43 44
elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
  # Yippee, $echo works!
  :
else
  # Restart under the correct shell.
  exec "$SHELL" "$0" --no-reexec ${1+"$@"}
fi

Manish Singh's avatar
Manish Singh committed
45 46 47 48 49 50 51 52 53
if test "X$1" = X--fallback-echo; then
  # used as fallback echo
  shift
  cat <<EOF
$*
EOF
  exit 0
fi

54 55
# Find the correct PATH separator.  Usually this is `:', but
# DJGPP uses `;' like DOS.
56
if test "X${PATH_SEPARATOR+set}" != Xset; then
57 58 59 60 61 62 63
  UNAME=${UNAME-`uname 2>/dev/null`}
  case X$UNAME in
    *-DOS) PATH_SEPARATOR=';' ;;
    *)     PATH_SEPARATOR=':' ;;
  esac
fi

Owen Taylor's avatar
Owen Taylor committed
64 65
# The HP-UX ksh and POSIX shell print the target directory to stdout
# if CDPATH is set.
66
if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
Owen Taylor's avatar
Owen Taylor committed
67

68
if test "X${echo_test_string+set}" != Xset; then
69 70 71 72 73 74 75 76 77 78 79 80 81
  # find a string as large as possible, as long as the shell can cope with it
  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
       echo_test_string="`eval $cmd`" &&
       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then
      break
    fi
  done
fi

if test "X`($echo '\t') 2>/dev/null`" != 'X\t' ||
   test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then
Owen Taylor's avatar
Owen Taylor committed
82 83 84 85 86
  # The Solaris, AIX, and Digital Unix default echo programs unquote
  # backslashes.  This makes it impossible to quote backslashes using
  #   echo "$something" | sed 's/\\/\\\\/g'
  #
  # So, first we look for a working echo in the user's PATH.
87

88
  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
Owen Taylor's avatar
Owen Taylor committed
89
  for dir in $PATH /usr/ucb; do
Manish Singh's avatar
Manish Singh committed
90
    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
91 92
       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
       test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
Owen Taylor's avatar
Owen Taylor committed
93 94 95 96 97 98 99 100
      echo="$dir/echo"
      break
    fi
  done
  IFS="$save_ifs"

  if test "X$echo" = Xecho; then
    # We didn't find a better echo, so look for alternatives.
101 102
    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
       test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
Owen Taylor's avatar
Owen Taylor committed
103 104
      # This shell has a builtin print -r that does the trick.
      echo='print -r'
Manish Singh's avatar
Manish Singh committed
105 106
    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
	 test "X$CONFIG_SHELL" != X/bin/ksh; then
107
      # If we have ksh, try running ltconfig again with it.
108 109
      ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}"
      export ORIGINAL_CONFIG_SHELL
110 111 112
      CONFIG_SHELL=/bin/ksh
      export CONFIG_SHELL
      exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"}
Owen Taylor's avatar
Owen Taylor committed
113 114
    else
      # Try using printf.
115
      echo='printf "%s\n"'
116
      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
117 118
	 test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
	# Cool, printf works
119 120 121 122 123 124 125 126 127 128
	:
      elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
	   test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
	CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL"
	export CONFIG_SHELL
	SHELL="$CONFIG_SHELL"
	export SHELL
	echo="$CONFIG_SHELL $0 --fallback-echo"
      elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
	   test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
129
	echo="$CONFIG_SHELL $0 --fallback-echo"
130
      else
131
	# maybe with a smaller string...
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
	prev=:

	for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
	  if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then
	    break
	  fi
	  prev="$cmd"
	done

	if test "$prev" != 'sed 50q "$0"'; then
	  echo_test_string=`eval $prev`
	  export echo_test_string
	  exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"}
	else
	  # Oops.  We lost completely, so just stick with echo.
	  echo=echo
	fi
Owen Taylor's avatar
Owen Taylor committed
149 150 151 152 153 154 155 156 157 158 159 160 161
      fi
    fi
  fi
fi

# Sed substitution that helps us do robust quoting.  It backslashifies
# metacharacters that are still active within double-quoted strings.
Xsed='sed -e s/^X//'
sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'

# Same as above, but do not quote variable references.
double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'

162 163 164 165
# Sed substitution to delay expansion of an escaped shell variable in a
# double_quote_subst'ed string.
delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'

Owen Taylor's avatar
Owen Taylor committed
166 167 168 169 170 171
# The name of this program.
progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'`

# Constants:
PROGRAM=ltconfig
PACKAGE=libtool
172 173 174 175
VERSION=1.3.4
TIMESTAMP=" (1.385.2.196 1999/12/07 21:47:57)"
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
Owen Taylor's avatar
Owen Taylor committed
176 177 178 179 180
rm="rm -f"

help="Try \`$progname --help' for more information."

# Global variables:
181
default_ofile=libtool
Owen Taylor's avatar
Owen Taylor committed
182 183
can_build_shared=yes
enable_shared=yes
184 185
# All known linkers require a `.a' archive for static linking (except M$VC,
# which needs '.lib').
Owen Taylor's avatar
Owen Taylor committed
186
enable_static=yes
187 188
enable_fast_install=yes
enable_dlopen=unknown
Manish Singh's avatar
Manish Singh committed
189
enable_win32_dll=no
Owen Taylor's avatar
Owen Taylor committed
190 191 192 193 194 195 196
ltmain=
silent=
srcdir=
ac_config_guess=
ac_config_sub=
host=
nonopt=
197
ofile="$default_ofile"
Owen Taylor's avatar
Owen Taylor committed
198 199 200
verify_host=yes
with_gcc=no
with_gnu_ld=no
201
need_locks=yes
202
ac_ext=c
203 204
objext=o
libext=a
205
exeext=
206
cache_file=
Owen Taylor's avatar
Owen Taylor committed
207 208 209 210 211

old_AR="$AR"
old_CC="$CC"
old_CFLAGS="$CFLAGS"
old_CPPFLAGS="$CPPFLAGS"
Manish Singh's avatar
Manish Singh committed
212
old_LDFLAGS="$LDFLAGS"
Owen Taylor's avatar
Owen Taylor committed
213 214
old_LD="$LD"
old_LN_S="$LN_S"
Manish Singh's avatar
Manish Singh committed
215
old_LIBS="$LIBS"
Owen Taylor's avatar
Owen Taylor committed
216 217
old_NM="$NM"
old_RANLIB="$RANLIB"
218
old_DLLTOOL="$DLLTOOL"
Manish Singh's avatar
Manish Singh committed
219
old_OBJDUMP="$OBJDUMP"
220
old_AS="$AS"
Owen Taylor's avatar
Owen Taylor committed
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240

# Parse the command line options.
args=
prev=
for option
do
  case "$option" in
  -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
  *) optarg= ;;
  esac

  # If the previous option needs an argument, assign it.
  if test -n "$prev"; then
    eval "$prev=\$option"
    prev=
    continue
  fi

  case "$option" in
  --help) cat <<EOM
241
Usage: $progname [OPTION]... [HOST [LTMAIN]]
Owen Taylor's avatar
Owen Taylor committed
242 243 244

Generate a system-specific libtool script.

245
    --debug                enable verbose shell tracing
Owen Taylor's avatar
Owen Taylor committed
246 247
    --disable-shared       do not build shared libraries
    --disable-static       do not build static libraries
248 249
    --disable-fast-install do not optimize for fast installation
    --enable-dlopen        enable dlopen support
Manish Singh's avatar
Manish Singh committed
250
    --enable-win32-dll     enable building dlls on win32 hosts
Owen Taylor's avatar
Owen Taylor committed
251 252
    --help                 display this help and exit
    --no-verify            do not verify that HOST is a valid host type
253
-o, --output=FILE          specify the output file [default=$default_ofile]
Owen Taylor's avatar
Owen Taylor committed
254 255 256 257 258 259
    --quiet                same as \`--silent'
    --silent               do not print informational messages
    --srcdir=DIR           find \`config.guess' in DIR
    --version              output version information and exit
    --with-gcc             assume that the GNU C compiler will be used
    --with-gnu-ld          assume that the C compiler uses the GNU linker
260
    --disable-lock         disable file locking
261
    --cache-file=FILE      configure cache file
Owen Taylor's avatar
Owen Taylor committed
262

263 264
LTMAIN is the \`ltmain.sh' shell script fragment or \`ltmain.c' program
that provides basic libtool functionality.
Owen Taylor's avatar
Owen Taylor committed
265 266 267 268 269 270

HOST is the canonical host system name [default=guessed].
EOM
  exit 0
  ;;

271 272 273 274 275
  --debug)
    echo "$progname: enabling shell trace mode"
    set -x
    ;;

Owen Taylor's avatar
Owen Taylor committed
276 277 278 279
  --disable-shared) enable_shared=no ;;

  --disable-static) enable_static=no ;;

280 281 282 283
  --disable-fast-install) enable_fast_install=no ;;

  --enable-dlopen) enable_dlopen=yes ;;

Manish Singh's avatar
Manish Singh committed
284 285
  --enable-win32-dll) enable_win32_dll=yes ;;

Owen Taylor's avatar
Owen Taylor committed
286 287 288 289 290 291 292
  --quiet | --silent) silent=yes ;;

  --srcdir) prev=srcdir ;;
  --srcdir=*) srcdir="$optarg" ;;

  --no-verify) verify_host=no ;;

293 294 295
  --output | -o) prev=ofile ;;
  --output=*) ofile="$optarg" ;;

296
  --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"; exit 0 ;;
Owen Taylor's avatar
Owen Taylor committed
297 298 299 300

  --with-gcc) with_gcc=yes ;;
  --with-gnu-ld) with_gnu_ld=yes ;;

301 302
  --disable-lock) need_locks=no ;;

303 304
  --cache-file=*) cache_file="$optarg" ;;

Owen Taylor's avatar
Owen Taylor committed
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333
  -*)
    echo "$progname: unrecognized option \`$option'" 1>&2
    echo "$help" 1>&2
    exit 1
    ;;

  *)
    if test -z "$ltmain"; then
      ltmain="$option"
    elif test -z "$host"; then
# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1
#      if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then
#        echo "$progname: warning \`$option' is not a valid host type" 1>&2
#      fi
      host="$option"
    else
      echo "$progname: too many arguments" 1>&2
      echo "$help" 1>&2
      exit 1
    fi ;;
  esac
done

if test -z "$ltmain"; then
  echo "$progname: you must specify a LTMAIN file" 1>&2
  echo "$help" 1>&2
  exit 1
fi

334
if test ! -f "$ltmain"; then
Owen Taylor's avatar
Owen Taylor committed
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371
  echo "$progname: \`$ltmain' does not exist" 1>&2
  echo "$help" 1>&2
  exit 1
fi

# Quote any args containing shell metacharacters.
ltconfig_args=
for arg
do
  case "$arg" in
  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
  ltconfig_args="$ltconfig_args '$arg'" ;;
  *) ltconfig_args="$ltconfig_args $arg" ;;
  esac
done

# A relevant subset of AC_INIT.

# File descriptor usage:
# 0 standard input
# 1 file creation
# 2 errors and warnings
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 5 compiler messages saved in config.log
# 6 checking for... messages and results
if test "$silent" = yes; then
  exec 6>/dev/null
else
  exec 6>&1
fi
exec 5>>./config.log

# NLS nuisances.
# Only set LANG and LC_ALL to C if already set.
# These must not be set unconditionally because not all systems understand
# e.g. LANG=C (notably SCO).
372 373
if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi
if test "X${LANG+set}"   = Xset; then LANG=C;   export LANG;   fi
Owen Taylor's avatar
Owen Taylor committed
374

375 376 377 378 379
if test -n "$cache_file" && test -r "$cache_file"; then
  echo "loading cache $cache_file within ltconfig"
  . $cache_file
fi

Owen Taylor's avatar
Owen Taylor committed
380 381 382 383 384 385 386 387 388 389 390 391 392
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
    ac_n= ac_c='
' ac_t='	'
  else
    ac_n=-n ac_c= ac_t=
  fi
else
  ac_n= ac_c='\c' ac_t=
fi

if test -z "$srcdir"; then
393
  # Assume the source directory is the same one as the path to LTMAIN.
394
  srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'`
Owen Taylor's avatar
Owen Taylor committed
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
  test "$srcdir" = "$ltmain" && srcdir=.
fi

trap "$rm conftest*; exit 1" 1 2 15
if test "$verify_host" = yes; then
  # Check for config.guess and config.sub.
  ac_aux_dir=
  for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
    if test -f $ac_dir/config.guess; then
      ac_aux_dir=$ac_dir
      break
    fi
  done
  if test -z "$ac_aux_dir"; then
    echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2
    echo "$help" 1>&2
    exit 1
  fi
  ac_config_guess=$ac_aux_dir/config.guess
  ac_config_sub=$ac_aux_dir/config.sub

  # Make sure we can run config.sub.
417
  if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then :
Owen Taylor's avatar
Owen Taylor committed
418 419 420 421 422 423 424 425 426 427 428
  else
    echo "$progname: cannot run $ac_config_sub" 1>&2
    echo "$help" 1>&2
    exit 1
  fi

  echo $ac_n "checking host system type""... $ac_c" 1>&6

  host_alias=$host
  case "$host_alias" in
  "")
429
    if host_alias=`$SHELL $ac_config_guess`; then :
Owen Taylor's avatar
Owen Taylor committed
430 431 432 433 434 435
    else
      echo "$progname: cannot guess host type; you must specify one" 1>&2
      echo "$help" 1>&2
      exit 1
    fi ;;
  esac
436
  host=`$SHELL $ac_config_sub $host_alias`
Owen Taylor's avatar
Owen Taylor committed
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
  echo "$ac_t$host" 1>&6

  # Make sure the host verified.
  test -z "$host" && exit 1

elif test -z "$host"; then
  echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2
  echo "$help" 1>&2
  exit 1
else
  host_alias=$host
fi

# Transform linux* to *-*-linux-gnu*, to support old configure scripts.
case "$host_os" in
linux-gnu*) ;;
linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
esac

host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`

case "$host_os" in
aix3*)
  # AIX sometimes has problems with the GCC collect2 program.  For some
  # reason, if we set the COLLECT_NAMES environment variable, the problems
  # vanish in a puff of smoke.
465
  if test "X${COLLECT_NAMES+set}" != Xset; then
Owen Taylor's avatar
Owen Taylor committed
466 467 468 469 470 471 472 473 474 475 476 477 478 479
    COLLECT_NAMES=
    export COLLECT_NAMES
  fi
  ;;
esac

# Determine commands to create old-style static archives.
old_archive_cmds='$AR cru $oldlib$oldobjs'
old_postinstall_cmds='chmod 644 $oldlib'
old_postuninstall_cmds=

# Set a sane default for `AR'.
test -z "$AR" && AR=ar

Manish Singh's avatar
Manish Singh committed
480 481 482
# Set a sane default for `OBJDUMP'.
test -z "$OBJDUMP" && OBJDUMP=objdump

Owen Taylor's avatar
Owen Taylor committed
483 484 485 486 487
# If RANLIB is not set, then run the test.
if test "${RANLIB+set}" != "set"; then
  result=no

  echo $ac_n "checking for ranlib... $ac_c" 1>&6
488
  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
Owen Taylor's avatar
Owen Taylor committed
489 490
  for dir in $PATH; do
    test -z "$dir" && dir=.
Manish Singh's avatar
Manish Singh committed
491
    if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then
Owen Taylor's avatar
Owen Taylor committed
492 493 494 495 496 497 498 499 500 501 502
      RANLIB="ranlib"
      result="ranlib"
      break
    fi
  done
  IFS="$save_ifs"

  echo "$ac_t$result" 1>&6
fi

if test -n "$RANLIB"; then
503 504
  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
  old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
Owen Taylor's avatar
Owen Taylor committed
505 506
fi

Manish Singh's avatar
Manish Singh committed
507
# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin.
508
test -z "$DLLTOOL" && DLLTOOL=dlltool
Manish Singh's avatar
Manish Singh committed
509
test -z "$OBJDUMP" && OBJDUMP=objdump
510 511
test -z "$AS" && AS=as

Owen Taylor's avatar
Owen Taylor committed
512 513 514 515 516
# Check to see if we are using GCC.
if test "$with_gcc" != yes || test -z "$CC"; then
  # If CC is not set, then try to find GCC or a usable CC.
  if test -z "$CC"; then
    echo $ac_n "checking for gcc... $ac_c" 1>&6
517
    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
Owen Taylor's avatar
Owen Taylor committed
518 519
    for dir in $PATH; do
      test -z "$dir" && dir=.
Manish Singh's avatar
Manish Singh committed
520
      if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then
Owen Taylor's avatar
Owen Taylor committed
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536
	CC="gcc"
	break
      fi
    done
    IFS="$save_ifs"

    if test -n "$CC"; then
      echo "$ac_t$CC" 1>&6
    else
      echo "$ac_t"no 1>&6
    fi
  fi

  # Not "gcc", so try "cc", rejecting "/usr/ucb/cc".
  if test -z "$CC"; then
    echo $ac_n "checking for cc... $ac_c" 1>&6
537
    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
Owen Taylor's avatar
Owen Taylor committed
538 539 540
    cc_rejected=no
    for dir in $PATH; do
      test -z "$dir" && dir=.
Manish Singh's avatar
Manish Singh committed
541
      if test -f $dir/cc || test -f $dir/cc$ac_exeext; then
Owen Taylor's avatar
Owen Taylor committed
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580
	if test "$dir/cc" = "/usr/ucb/cc"; then
	  cc_rejected=yes
	  continue
	fi
	CC="cc"
	break
      fi
    done
    IFS="$save_ifs"
    if test $cc_rejected = yes; then
      # We found a bogon in the path, so make sure we never use it.
      set dummy $CC
      shift
      if test $# -gt 0; then
	# We chose a different compiler from the bogus one.
	# However, it has the same name, so the bogon will be chosen
	# first if we set CC to just the name; use the full file name.
	shift
	set dummy "$dir/cc" "$@"
	shift
	CC="$@"
      fi
    fi

    if test -n "$CC"; then
      echo "$ac_t$CC" 1>&6
    else
      echo "$ac_t"no 1>&6
    fi

    if test -z "$CC"; then
      echo "$progname: error: no acceptable cc found in \$PATH" 1>&2
      exit 1
    fi
  fi

  # Now see if the compiler is really GCC.
  with_gcc=no
  echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6
581
  echo "$progname:581: checking whether we are using GNU C" >&5
Owen Taylor's avatar
Owen Taylor committed
582 583 584 585 586 587 588

  $rm conftest.c
  cat > conftest.c <<EOF
#ifdef __GNUC__
  yes;
#endif
EOF
589
  if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:589: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
Owen Taylor's avatar
Owen Taylor committed
590 591 592 593 594 595 596 597 598 599
    with_gcc=yes
  fi
  $rm conftest.c
  echo "$ac_t$with_gcc" 1>&6
fi

# Allow CC to be a program name with arguments.
set dummy $CC
compiler="$2"

600 601 602
echo $ac_n "checking for object suffix... $ac_c" 1>&6
$rm conftest*
echo 'int i = 1;' > conftest.c
603 604
echo "$progname:603: checking for object suffix" >& 5
if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
  # Append any warnings to the config.log.
  cat conftest.err 1>&5

  for ac_file in conftest.*; do
    case $ac_file in
    *.c) ;;
    *) objext=`echo $ac_file | sed -e s/conftest.//` ;;
    esac
  done
else
  cat conftest.err 1>&5
  echo "$progname: failed program was:" >&5
  cat conftest.c >&5
fi
$rm conftest*
echo "$ac_t$objext" 1>&6

622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653
echo $ac_n "checking for executable suffix... $ac_c" 1>&6
if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
  echo $ac_n "(cached) $ac_c" 1>&6
else
  ac_cv_exeext="no"
  $rm conftest*
  echo 'main () { return 0; }' > conftest.c
  echo "$progname:629: checking for executable suffix" >& 5
  if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then
    # Append any warnings to the config.log.
    cat conftest.err 1>&5

    for ac_file in conftest.*; do
      case $ac_file in
      *.c | *.err | *.$objext ) ;;
      *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;;
      esac
    done
  else
    cat conftest.err 1>&5
    echo "$progname: failed program was:" >&5
    cat conftest.c >&5
  fi
  $rm conftest*
fi
if test "X$ac_cv_exeext" = Xno; then
  exeext=""
else
  exeext="$ac_cv_exeext"
fi
echo "$ac_t$ac_cv_exeext" 1>&6

Owen Taylor's avatar
Owen Taylor committed
654 655 656 657 658 659 660 661 662 663 664 665
echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6
pic_flag=
special_shlib_compile_flags=
wl=
link_static_flag=
no_builtin_flag=

if test "$with_gcc" = yes; then
  wl='-Wl,'
  link_static_flag='-static'

  case "$host_os" in
666
  beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
Owen Taylor's avatar
Owen Taylor committed
667 668
    # PIC is the default for these OSes.
    ;;
669 670 671 672 673 674 675 676 677 678
  aix*)
    # Below there is a dirty hack to force normal static linking with -ldl
    # The problem is because libdl dynamically linked with both libc and
    # libC (AIX C++ library), which obviously doesn't included in libraries
    # list by gcc. This cause undefined symbols with -static flags.
    # This hack allows C programs to be linked with "-static -ldl", but
    # we not sure about C++ programs.
    link_static_flag="$link_static_flag ${wl}-lC"
    ;;
  cygwin* | mingw* | os2*)
Owen Taylor's avatar
Owen Taylor committed
679 680 681 682 683 684 685 686
    # We can build DLLs from non-PIC.
    ;;
  amigaos*)
    # FIXME: we need at least 68020 code to build shared libraries, but
    # adding the `-m68020' flag to GCC prevents building anything better,
    # like `-m68040'.
    pic_flag='-m68020 -resident32 -malways-restore-a4'
    ;;
687 688 689 690 691
  sysv4*MP*)
    if test -d /usr/nec; then
       pic_flag=-Kconform_pic
    fi
    ;;
Owen Taylor's avatar
Owen Taylor committed
692 693 694 695 696 697 698 699 700 701 702 703
  *)
    pic_flag='-fPIC'
    ;;
  esac
else
  # PORTME Check for PIC flags for the system compiler.
  case "$host_os" in
  aix3* | aix4*)
    # All AIX code is PIC.
    link_static_flag='-bnso -bI:/lib/syscalls.exp'
    ;;

704
  hpux9* | hpux10* | hpux11*)
Owen Taylor's avatar
Owen Taylor committed
705 706 707 708 709 710 711 712 713 714 715 716
    # Is there a better link_static_flag that works with the bundled CC?
    wl='-Wl,'
    link_static_flag="${wl}-a ${wl}archive"
    pic_flag='+Z'
    ;;

  irix5* | irix6*)
    wl='-Wl,'
    link_static_flag='-non_shared'
    # PIC (with -KPIC) is the default.
    ;;

717
  cygwin* | mingw* | os2*)
Owen Taylor's avatar
Owen Taylor committed
718 719 720
    # We can build DLLs from non-PIC.
    ;;

721
  osf3* | osf4* | osf5*)
Owen Taylor's avatar
Owen Taylor committed
722 723 724 725 726 727 728 729 730 731 732
    # All OSF/1 code is PIC.
    wl='-Wl,'
    link_static_flag='-non_shared'
    ;;

  sco3.2v5*)
    pic_flag='-Kpic'
    link_static_flag='-dn'
    special_shlib_compile_flags='-belf'
    ;;

733
  solaris*)
Owen Taylor's avatar
Owen Taylor committed
734 735 736 737 738 739 740 741 742 743 744
    pic_flag='-KPIC'
    link_static_flag='-Bstatic'
    wl='-Wl,'
    ;;

  sunos4*)
    pic_flag='-PIC'
    link_static_flag='-Bstatic'
    wl='-Qoption ld '
    ;;

Manish Singh's avatar
Manish Singh committed
745
  sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
Owen Taylor's avatar
Owen Taylor committed
746 747 748 749 750 751 752 753 754
    pic_flag='-KPIC'
    link_static_flag='-Bstatic'
    wl='-Wl,'
    ;;

  uts4*)
    pic_flag='-pic'
    link_static_flag='-Bstatic'
    ;;
755 756 757 758 759 760
  sysv4*MP*)
    if test -d /usr/nec ;then
      pic_flag='-Kconform_pic'
      link_static_flag='-Bstatic'
    fi
    ;;
Owen Taylor's avatar
Owen Taylor committed
761 762 763 764 765 766 767 768 769 770 771 772
  *)
    can_build_shared=no
    ;;
  esac
fi

if test -n "$pic_flag"; then
  echo "$ac_t$pic_flag" 1>&6

  # Check to make sure the pic_flag actually works.
  echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6
  $rm conftest*
773
  echo "int some_variable = 0;" > conftest.c
Owen Taylor's avatar
Owen Taylor committed
774 775
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS $pic_flag -DPIC"
776 777
  echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5
  if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then
Owen Taylor's avatar
Owen Taylor committed
778 779
    # Append any warnings to the config.log.
    cat conftest.err 1>&5
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795
    
    case "$host_os" in
    hpux9* | hpux10* | hpux11*)
      # On HP-UX, both CC and GCC only warn that PIC is supported... then they
      # create non-PIC objects.  So, if there were any warnings, we assume that
      # PIC is not supported.
      if test -s conftest.err; then
	echo "$ac_t"no 1>&6
	can_build_shared=no
	pic_flag=
      else
	echo "$ac_t"yes 1>&6
	pic_flag=" $pic_flag"
      fi
      ;;
    *)
Owen Taylor's avatar
Owen Taylor committed
796 797
      echo "$ac_t"yes 1>&6
      pic_flag=" $pic_flag"
798 799
      ;;
    esac
Owen Taylor's avatar
Owen Taylor committed
800 801 802 803 804 805 806 807 808 809 810 811 812
  else
    # Append any errors to the config.log.
    cat conftest.err 1>&5
    can_build_shared=no
    pic_flag=
    echo "$ac_t"no 1>&6
  fi
  CFLAGS="$save_CFLAGS"
  $rm conftest*
else
  echo "$ac_t"none 1>&6
fi

813 814
# Check to see if options -o and -c are simultaneously supported by compiler
echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6
Manish Singh's avatar
Manish Singh committed
815 816 817
$rm -r conftest 2>/dev/null
mkdir conftest
cd conftest
818 819
$rm conftest*
echo "int some_variable = 0;" > conftest.c
Manish Singh's avatar
Manish Singh committed
820 821 822 823 824 825 826
mkdir out
# According to Tom Tromey, Ian Lance Taylor reported there are C compilers
# that will create temporary files in the current directory regardless of
# the output directory.  Thus, making CWD read-only will cause this test
# to fail, enabling locking or at least warning the user not to do parallel
# builds.
chmod -w .
827
save_CFLAGS="$CFLAGS"
Manish Singh's avatar
Manish Singh committed
828
CFLAGS="$CFLAGS -o out/conftest2.o"
829 830
echo "$progname:829: checking if $compiler supports -c -o file.o" >&5
if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then
831 832 833

  # The compiler can only warn and ignore the option if not recognized
  # So say no if there are warnings
Manish Singh's avatar
Manish Singh committed
834
    if test -s out/conftest.err; then
835 836 837 838 839 840 841 842
      echo "$ac_t"no 1>&6
      compiler_c_o=no
    else
      echo "$ac_t"yes 1>&6
      compiler_c_o=yes
    fi
else
  # Append any errors to the config.log.
Manish Singh's avatar
Manish Singh committed
843
  cat out/conftest.err 1>&5
844 845 846 847
  compiler_c_o=no
  echo "$ac_t"no 1>&6
fi
CFLAGS="$save_CFLAGS"
Manish Singh's avatar
Manish Singh committed
848 849 850 851 852 853
chmod u+w .
$rm conftest* out/*
rmdir out
cd ..
rmdir conftest
$rm -r conftest 2>/dev/null
854 855 856 857 858 859 860 861

if test x"$compiler_c_o" = x"yes"; then
  # Check to see if we can write to a .lo
  echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6
  $rm conftest*
  echo "int some_variable = 0;" > conftest.c
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -c -o conftest.lo"
862 863
  echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5
if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then
864 865 866 867 868 869 870

    # The compiler can only warn and ignore the option if not recognized
    # So say no if there are warnings
      if test -s conftest.err; then
	echo "$ac_t"no 1>&6
	compiler_o_lo=no
      else
871 872
	echo "$ac_t"yes 1>&6
	compiler_o_lo=yes
873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913
      fi
  else
    # Append any errors to the config.log.
    cat conftest.err 1>&5
    compiler_o_lo=no
    echo "$ac_t"no 1>&6
  fi
  CFLAGS="$save_CFLAGS"
  $rm conftest*
else
  compiler_o_lo=no
fi

# Check to see if we can do hard links to lock some files if needed
hard_links="nottested"
if test "$compiler_c_o" = no && test "$need_locks" != no; then
  # do not overwrite the value of need_locks provided by the user
  echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6
  hard_links=yes
  $rm conftest*
  ln conftest.a conftest.b 2>/dev/null && hard_links=no
  touch conftest.a
  ln conftest.a conftest.b 2>&5 || hard_links=no
  ln conftest.a conftest.b 2>/dev/null && hard_links=no
  echo "$ac_t$hard_links" 1>&6
  $rm conftest*
  if test "$hard_links" = no; then
    echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2
    need_locks=warn
  fi
else
  need_locks=no
fi

if test "$with_gcc" = yes; then
  # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
  echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6
  $rm conftest*
  echo "int some_variable = 0;" > conftest.c
  save_CFLAGS="$CFLAGS"
  CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c"
914 915
  echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
  if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then
916 917 918 919

    # The compiler can only warn and ignore the option if not recognized
    # So say no if there are warnings
      if test -s conftest.err; then
920 921
	echo "$ac_t"no 1>&6
	compiler_rtti_exceptions=no
922
      else
923 924
	echo "$ac_t"yes 1>&6
	compiler_rtti_exceptions=yes
925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
      fi
  else
    # Append any errors to the config.log.
    cat conftest.err 1>&5
    compiler_rtti_exceptions=no
    echo "$ac_t"no 1>&6
  fi
  CFLAGS="$save_CFLAGS"
  $rm conftest*

  if test "$compiler_rtti_exceptions" = "yes"; then
    no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions'
  else
    no_builtin_flag=' -fno-builtin'
  fi
  
fi

Owen Taylor's avatar
Owen Taylor committed
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957
# Check for any special shared library compilation flags.
if test -n "$special_shlib_compile_flags"; then
  echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2
  if echo "$old_CC $old_CFLAGS " | egrep -e "[ 	]$special_shlib_compile_flags[ 	]" >/dev/null; then :
  else
    echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2
    can_build_shared=no
  fi
fi

echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6
$rm conftest*
echo 'main(){return(0);}' > conftest.c
save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $link_static_flag"
958 959
echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5
if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
Owen Taylor's avatar
Owen Taylor committed
960 961 962 963 964 965 966 967 968 969 970
  echo "$ac_t$link_static_flag" 1>&6
else
  echo "$ac_t"none 1>&6
  link_static_flag=
fi
LDFLAGS="$save_LDFLAGS"
$rm conftest*

if test -z "$LN_S"; then
  # Check to see if we can use ln -s, or we need hard links.
  echo $ac_n "checking whether ln -s works... $ac_c" 1>&6
Manish Singh's avatar
Manish Singh committed
971 972 973
  $rm conftest.dat
  if ln -s X conftest.dat 2>/dev/null; then
    $rm conftest.dat
Owen Taylor's avatar
Owen Taylor committed
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990
    LN_S="ln -s"
  else
    LN_S=ln
  fi
  if test "$LN_S" = "ln -s"; then
    echo "$ac_t"yes 1>&6
  else
    echo "$ac_t"no 1>&6
  fi
fi

# Make sure LD is an absolute path.
if test -z "$LD"; then
  ac_prog=ld
  if test "$with_gcc" = yes; then
    # Check if gcc -print-prog-name=ld gives a path.
    echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6
991
    echo "$progname:991: checking for ld used by GCC" >&5
Owen Taylor's avatar
Owen Taylor committed
992 993 994
    ac_prog=`($CC -print-prog-name=ld) 2>&5`
    case "$ac_prog" in
    # Accept absolute paths.
Manish Singh's avatar
Manish Singh committed
995
    [\\/]* | [A-Za-z]:[\\/]*)
996 997
      re_direlt='/[^/][^/]*/\.\./'
      # Canonicalize the path of ld
998
      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
999
      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
1000
	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
1001
      done
1002
      test -z "$LD" && LD="$ac_prog"
Owen Taylor's avatar
Owen Taylor committed
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014
      ;;
    "")
      # If it fails, then pretend we are not using GCC.
      ac_prog=ld
      ;;
    *)
      # If it is relative, then search for the first ld in PATH.
      with_gnu_ld=unknown
      ;;
    esac
  elif test "$with_gnu_ld" = yes; then
    echo $ac_n "checking for GNU ld... $ac_c" 1>&6
1015
    echo "$progname:1015: checking for GNU ld" >&5
Owen Taylor's avatar
Owen Taylor committed
1016 1017
  else
    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
1018
    echo "$progname:1018: checking for non-GNU ld" >&5
Owen Taylor's avatar
Owen Taylor committed
1019 1020 1021
  fi

  if test -z "$LD"; then
1022
    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
Owen Taylor's avatar
Owen Taylor committed
1023 1024
    for ac_dir in $PATH; do
      test -z "$ac_dir" && ac_dir=.
Manish Singh's avatar
Manish Singh committed
1025
      if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
Owen Taylor's avatar
Owen Taylor committed
1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
	LD="$ac_dir/$ac_prog"
	# Check to see if the program is GNU ld.  I'd rather use --version,
	# but apparently some GNU ld's only accept -v.
	# Break only if it was the GNU/non-GNU ld that we prefer.
	if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
	  test "$with_gnu_ld" != no && break
	else
	  test "$with_gnu_ld" != yes && break
	fi
      fi
    done
    IFS="$ac_save_ifs"
  fi

  if test -n "$LD"; then
    echo "$ac_t$LD" 1>&6
  else
    echo "$ac_t"no 1>&6
  fi

  if test -z "$LD"; then
    echo "$progname: error: no acceptable ld found in \$PATH" 1>&2
    exit 1
  fi
fi

# Check to see if it really is or is not GNU ld.
echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6
# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
  with_gnu_ld=yes
else
  with_gnu_ld=no
fi
echo "$ac_t$with_gnu_ld" 1>&6

# See if the linker supports building shared libraries.
echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6

allow_undefined_flag=
no_undefined_flag=
1067 1068 1069 1070
need_lib_prefix=unknown
need_version=unknown
# when you set need_version to no, make sure it does not cause -set_version
# flags to be left without arguments
Owen Taylor's avatar
Owen Taylor committed
1071
archive_cmds=
1072
archive_expsym_cmds=
Owen Taylor's avatar
Owen Taylor committed
1073 1074
old_archive_from_new_cmds=
export_dynamic_flag_spec=
1075
whole_archive_flag_spec=
1076
thread_safe_flag_spec=
Owen Taylor's avatar
Owen Taylor committed
1077 1078 1079 1080 1081 1082
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
hardcode_shlibpath_var=unsupported
runpath_var=
1083
always_export_symbols=no
1084
export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
1085 1086 1087 1088 1089 1090 1091
# include_expsyms should be a list of space-separated symbols to be *always*
# included in the symbol list
include_expsyms=
# exclude_expsyms can be an egrep regular expression of symbols to exclude
# it will be wrapped by ` (' and `)$', so one must not match beginning or
# end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
# as well as any symbol that contains `d'.
Manish Singh's avatar
Manish Singh committed
1092 1093 1094 1095 1096 1097
exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
# platforms (ab)use it in PIC code, but their linkers get confused if
# the symbol is explicitly referenced.  Since portable code cannot
# rely on this symbol name, it's probably fine to never include it in
# preloaded symbol tables.
Owen Taylor's avatar
Owen Taylor committed
1098

1099
case "$host_os" in
1100 1101 1102 1103 1104 1105 1106
cygwin* | mingw*)
  # FIXME: the MSVC++ port hasn't been tested in a loooong time
  # When not using gcc, we currently assume that we are using
  # Microsoft Visual C++.
  if test "$with_gcc" != yes; then
    with_gnu_ld=no
  fi
1107
  ;;
1108

1109 1110
esac

Owen Taylor's avatar
Owen Taylor committed
1111
ld_shlibs=yes
1112
if test "$with_gnu_ld" = yes; then
1113 1114
  # If archive_cmds runs LD, not CC, wlarc should be empty
  wlarc='${wl}'
Owen Taylor's avatar
Owen Taylor committed
1115 1116

  # See if GNU ld supports shared libraries.
1117
  case "$host_os" in
1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131
  aix3* | aix4*)
    # On AIX, the GNU linker is very broken
    ld_shlibs=no
    cat <<EOF 1>&2

*** Warning: the GNU linker, at least up to release 2.9.1, is reported
*** to be unable to reliably create shared libraries on AIX.
*** Therefore, libtool is disabling shared libraries support.  If you
*** really care for shared libraries, you may want to modify your PATH
*** so that a non-GNU linker is found, and then restart.

EOF
    ;;

1132
  amigaos*)
1133
    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
1134 1135 1136
    hardcode_libdir_flag_spec='-L$libdir'
    hardcode_minus_L=yes

Manish Singh's avatar
Manish Singh committed
1137 1138 1139 1140 1141 1142 1143
    # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
    # that the semantics of dynamic libraries on AmigaOS, at least up
    # to version 4, is to share data among multiple programs linked
    # with the same dynamic library.  Since this doesn't match the
    # behavior of shared libraries on other platforms, we can use
    # them.
    ld_shlibs=no
1144 1145
    ;;

1146 1147
  beos*)
    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
Manish Singh's avatar
Manish Singh committed
1148 1149 1150
      allow_undefined_flag=unsupported
      # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
      # support --undefined.  This deserves some investigation.  FIXME
1151 1152 1153
      archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
    else
      ld_shlibs=no
1154
    fi
1155 1156
    ;;

1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
  cygwin* | mingw*)
    # hardcode_libdir_flag_spec is actually meaningless, as there is
    # no search path for DLLs.
    hardcode_libdir_flag_spec='-L$libdir'
    allow_undefined_flag=unsupported
    always_export_symbols=yes

    # Extract the symbol export list from an `--export-all' def file,
    # then regenerate the def file from the symbol export list, so that
    # the compiled dll only exports the symbol export list.
1167 1168 1169
    export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
      $DLLTOOL --export-all --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def  $objdir/$soname-ltdll.$objext $libobjs $convenience~
1170 1171 1172 1173 1174
      sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ; *//" < $objdir/$soname-def > $export_symbols'

    archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~
      _lt_hint=1;
      for symbol in `cat $export_symbols`; do
Manish Singh's avatar
Manish Singh committed
1175
	echo "	\$symbol @ \$_lt_hint ; " >> $objdir/$soname-def;
1176 1177
	_lt_hint=`expr 1 + \$_lt_hint`;
      done~
1178 1179
      test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
1180 1181 1182 1183 1184 1185
      $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
      $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
      $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts'

1186
      old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a' 
1187 1188
    ;;

Manish Singh's avatar
Manish Singh committed
1189
  netbsd*)
1190
    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
Manish Singh's avatar
Manish Singh committed
1191 1192 1193 1194 1195 1196 1197 1198
      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
    else
      archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib'
      # can we support soname and/or expsyms with a.out? -oliva
    fi
    ;;

1199
  solaris* | sysv5*)
1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219
    if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
      ld_shlibs=no
      cat <<EOF 1>&2

*** Warning: The releases 2.8.* of the GNU linker cannot reliably
*** create shared libraries on Solaris systems.  Therefore, libtool
*** is disabling shared libraries support.  We urge you to upgrade GNU
*** binutils to release 2.9.1 or newer.  Another option is to modify
*** your PATH or compiler configuration so that the native linker is
*** used, and then restart.

EOF
    elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
    else
      ld_shlibs=no
    fi
    ;;      

Manish Singh's avatar
Manish Singh committed
1220 1221 1222 1223 1224 1225 1226
  sunos4*)
    archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts'
    wlarc=
    hardcode_direct=yes
    hardcode_shlibpath_var=no
    ;;

1227 1228
  *)
    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
1229 1230
      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
1231 1232 1233 1234 1235
    else
      ld_shlibs=no
    fi
    ;;
  esac
Owen Taylor's avatar
Owen Taylor committed
1236

1237
  if test "$ld_shlibs" = yes; then
1238
    runpath_var=LD_RUN_PATH
Owen Taylor's avatar
Owen Taylor committed
1239 1240
    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
    export_dynamic_flag_spec='${wl}--export-dynamic'
1241 1242 1243 1244 1245 1246
    case $host_os in
    cygwin* | mingw*)
      # dlltool doesn't understand --whole-archive et. al.
      whole_archive_flag_spec=
      ;;
    *)
1247 1248 1249 1250 1251 1252
      # ancient GNU ld didn't support --whole-archive et. al.
      if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then
        whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
      else
        whole_archive_flag_spec=
      fi
1253 1254
      ;;
    esac
Owen Taylor's avatar
Owen Taylor committed
1255 1256 1257 1258 1259 1260
  fi
else
  # PORTME fill in a description of your system's linker (not GNU ld)
  case "$host_os" in
  aix3*)
    allow_undefined_flag=unsupported
1261 1262
    always_export_symbols=yes
    archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname'
Owen Taylor's avatar
Owen Taylor committed
1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273
    # Note: this linker hardcodes the directories in LIBPATH if there
    # are no directories specified by -L.
    hardcode_minus_L=yes
    if test "$with_gcc" = yes && test -z "$link_static_flag"; then
      # Neither direct hardcoding nor static linking is supported with a
      # broken collect2.
      hardcode_direct=unsupported
    fi
    ;;

  aix4*)
Manish Singh's avatar
Manish Singh committed
1274 1275
    hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib'
    hardcode_libdir_separator=':'
1276
    if test "$with_gcc" = yes; then
Manish Singh's avatar
Manish Singh committed
1277 1278 1279
      collect2name=`${CC} -print-prog-name=collect2`
      if test -f "$collect2name" && \
	 strings "$collect2name" | grep resolve_lib_name >/dev/null
1280 1281 1282 1283 1284 1285
      then
	# We have reworked collect2
	hardcode_direct=yes
      else
	# We have old collect2
	hardcode_direct=unsupported
Manish Singh's avatar
Manish Singh committed
1286 1287 1288 1289 1290 1291
	# It fails to find uninstalled libraries when the uninstalled
	# path is not listed in the libpath.  Setting hardcode_minus_L
	# to unsupported forces relinking
	hardcode_minus_L=yes
	hardcode_libdir_flag_spec='-L$libdir'
	hardcode_libdir_separator=
1292
      fi
Manish Singh's avatar
Manish Singh committed
1293
      shared_flag='-shared'
1294
    else
Manish Singh's avatar
Manish Singh committed
1295
      shared_flag='${wl}-bM:SRE'
1296 1297
      hardcode_direct=yes
    fi
Manish Singh's avatar
Manish Singh committed
1298 1299 1300 1301 1302 1303 1304
    allow_undefined_flag=' ${wl}-berok'
    archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}'
    archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}'
    case "$host_os" in aix4.[01]|aix4.[01].*)
      # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on
      always_export_symbols=yes ;;
    esac
1305
   ;;
Owen Taylor's avatar
Owen Taylor committed
1306 1307

  amigaos*)
1308
    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
Owen Taylor's avatar
Owen Taylor committed
1309 1310
    hardcode_libdir_flag_spec='-L$libdir'
    hardcode_minus_L=yes
Manish Singh's avatar
Manish Singh committed
1311 1312
    # see comment about different semantics on the GNU ld section
    ld_shlibs=no
Owen Taylor's avatar
Owen Taylor committed
1313 1314
    ;;

1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331
  cygwin* | mingw*)
    # When not using gcc, we currently assume that we are using
    # Microsoft Visual C++.
    # hardcode_libdir_flag_spec is actually meaningless, as there is
    # no search path for DLLs.
    hardcode_libdir_flag_spec=' '
    allow_undefined_flag=unsupported
    # Tell ltmain to make .lib files, not .a files.
    libext=lib
    # FIXME: Setting linknames here is a bad hack.
    archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames='
    # The linker will automatically build a .lib file if we build a DLL.
    old_archive_from_new_cmds='true'
    # FIXME: Should let the user specify the lib program.
    old_archive_cmds='lib /OUT:$oldlib$oldobjs'
    fix_srcfile_path='`cygpath -w $srcfile`'
    ;;
1332

1333 1334
  freebsd1*)
    ld_shlibs=no
1335 1336
    ;;

Owen Taylor's avatar
Owen Taylor committed
1337 1338 1339 1340 1341
  # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
  # support.  Future versions do this automatically, but an explicit c++rt0.o
  # does not break anything, and helps significantly (at the cost of a little
  # extra space).
  freebsd2.2*)
1342
    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o'
Owen Taylor's avatar
Owen Taylor committed
1343 1344 1345 1346 1347 1348 1349
    hardcode_libdir_flag_spec='-R$libdir'
    hardcode_direct=yes
    hardcode_shlibpath_var=no
    ;;

  # Unfortunately, older versions of FreeBSD 2 do not have this feature.
  freebsd2*)
1350
    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
Owen Taylor's avatar
Owen Taylor committed
1351 1352 1353 1354 1355
    hardcode_direct=yes
    hardcode_minus_L=yes
    hardcode_shlibpath_var=no
    ;;

1356 1357 1358
  # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
  freebsd*)
    archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts'
Owen Taylor's avatar
Owen Taylor committed
1359 1360 1361 1362 1363
    hardcode_libdir_flag_spec='-R$libdir'
    hardcode_direct=yes
    hardcode_shlibpath_var=no
    ;;

Manish Singh's avatar
Manish Singh committed
1364 1365 1366 1367 1368
  hpux9* | hpux10* | hpux11*)
    case "$host_os" in
    hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;;
    *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;;
    esac
Owen Taylor's avatar
Owen Taylor committed
1369
    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
Manish Singh's avatar
Manish Singh committed
1370
    hardcode_libdir_separator=:
Owen Taylor's avatar
Owen Taylor committed
1371
    hardcode_direct=yes
Manish Singh's avatar
Manish Singh committed
1372 1373
    hardcode_minus_L=yes # Not in the search PATH, but as the default
			 # location of the library.
Owen Taylor's avatar
Owen Taylor committed
1374 1375 1376 1377
    export_dynamic_flag_spec='${wl}-E'
    ;;

  irix5* | irix6*)
1378
    if test "$with_gcc" = yes; then
Manish Singh's avatar
Manish Singh committed
1379
      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
1380
    else
Manish Singh's avatar
Manish Singh committed
1381
      archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
1382
    fi
Owen Taylor's avatar
Owen Taylor committed
1383
    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
1384
    hardcode_libdir_separator=:
Owen Taylor's avatar
Owen Taylor committed
1385 1386 1387
    ;;

  netbsd*)
1388 1389 1390 1391 1392 1393
    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'  # a.out
    else
      archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts'      # ELF
    fi
    hardcode_libdir_flag_spec='${wl}-R$libdir'
Owen Taylor's avatar
Owen Taylor committed
1394 1395 1396 1397 1398
    hardcode_direct=yes
    hardcode_shlibpath_var=no
    ;;

  openbsd*)
1399
    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
Owen Taylor's avatar
Owen Taylor committed
1400 1401 1402 1403 1404 1405 1406 1407 1408
    hardcode_libdir_flag_spec='-R$libdir'
    hardcode_direct=yes
    hardcode_shlibpath_var=no
    ;;

  os2*)
    hardcode_libdir_flag_spec='-L$libdir'
    hardcode_minus_L=yes
    allow_undefined_flag=unsupported
1409
    archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def'
Owen Taylor's avatar
Owen Taylor committed
1410 1411 1412
    old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def'
    ;;

1413
  osf3*)
1414 1415
    if test "$with_gcc" = yes; then
      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
Manish Singh's avatar
Manish Singh committed
1416
      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
1417 1418
    else
      allow_undefined_flag=' -expect_unresolved \*'
Manish Singh's avatar
Manish Singh committed
1419
      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
1420
    fi
Owen Taylor's avatar
Owen Taylor committed
1421 1422 1423 1424
    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
    hardcode_libdir_separator=:
    ;;

1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436
  osf4* | osf5*)  # As osf3* with the addition of the -msym flag
    if test "$with_gcc" = yes; then
      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
    else
      allow_undefined_flag=' -expect_unresolved \*'
      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
    fi
    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
    hardcode_libdir_separator=:
    ;;

Owen Taylor's avatar
Owen Taylor committed
1437
  sco3.2v5*)
Manish Singh's avatar
Manish Singh committed
1438 1439 1440 1441
    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
    hardcode_shlibpath_var=no
    runpath_var=LD_RUN_PATH
    hardcode_runpath_var=yes
Owen Taylor's avatar
Owen Taylor committed
1442 1443
    ;;

1444
  solaris*)
Owen Taylor's avatar
Owen Taylor committed
1445
    no_undefined_flag=' -z text'
1446 1447
    # $CC -shared without GNU ld will not create a library from C++
    # object files and a static libstdc++, better avoid it by now
1448 1449 1450
    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
Owen Taylor's avatar
Owen Taylor committed
1451 1452
    hardcode_libdir_flag_spec='-R$libdir'
    hardcode_shlibpath_var=no
Manish Singh's avatar
Manish Singh committed
1453 1454 1455
    case "$host_os" in
    solaris2.[0-5] | solaris2.[0-5].*) ;;
    *) # Supported since Solaris 2.6 (maybe 2.5.1?)
1456
      whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
Manish Singh's avatar
Manish Singh committed
1457
    esac
Owen Taylor's avatar
Owen Taylor committed
1458 1459 1460
    ;;

  sunos4*)
Manish Singh's avatar
Manish Singh committed
1461
    archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts'
Owen Taylor's avatar
Owen Taylor committed
1462 1463 1464 1465 1466 1467
    hardcode_libdir_flag_spec='-L$libdir'
    hardcode_direct=yes
    hardcode_minus_L=yes
    hardcode_shlibpath_var=no
    ;;

Manish Singh's avatar
Manish Singh committed
1468 1469 1470 1471 1472 1473 1474
  sysv4)
    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
    runpath_var='LD_RUN_PATH'
    hardcode_shlibpath_var=no
    hardcode_direct=no #Motorola manual says yes, but my tests say they lie 
    ;;  

1475 1476 1477 1478 1479 1480
  sysv4.3*)
    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
    hardcode_shlibpath_var=no
    export_dynamic_flag_spec='-Bexport'
    ;;

1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
  sysv5*)
    no_undefined_flag=' -z text'
    # $CC -shared without GNU ld will not create a library from C++
    # object files and a static libstdc++, better avoid it by now
    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
    hardcode_libdir_flag_spec=
    hardcode_shlibpath_var=no
    runpath_var='LD_RUN_PATH'
    ;;

Owen Taylor's avatar
Owen Taylor committed
1493
  uts4*)
1494
    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
1495 1496 1497 1498 1499
    hardcode_libdir_flag_spec='-L$libdir'
    hardcode_shlibpath_var=no
    ;;

  dgux*)
1500
    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
Owen Taylor's avatar
Owen Taylor committed
1501 1502 1503 1504
    hardcode_libdir_flag_spec='-L$libdir'
    hardcode_shlibpath_var=no
    ;;

1505
  sysv4*MP*)
1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518
    if test -d /usr/nec; then
      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
      hardcode_shlibpath_var=no
      runpath_var=LD_RUN_PATH
      hardcode_runpath_var=yes
      ld_shlibs=yes
    fi
    ;;

  sysv4.2uw2*)
    archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts'
    hardcode_direct=yes
    hardcode_minus_L=no
1519 1520
    hardcode_shlibpath_var=no
    hardcode_runpath_var=yes
1521 1522 1523 1524 1525 1526 1527
    runpath_var=LD_RUN_PATH
    ;;

  unixware7*)
    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
    runpath_var='LD_RUN_PATH'
    hardcode_shlibpath_var=no
1528 1529
    ;;

Owen Taylor's avatar
Owen Taylor committed
1530 1531 1532 1533 1534 1535
  *)
    ld_shlibs=no
    ;;
  esac
fi
echo "$ac_t$ld_shlibs" 1>&6
Manish Singh's avatar
Manish Singh committed
1536
test "$ld_shlibs" = no && can_build_shared=no
Owen Taylor's avatar
Owen Taylor committed
1537 1538 1539 1540

if test -z "$NM"; then
  echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6
  case "$NM" in
Manish Singh's avatar
Manish Singh committed
1541
  [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path.
Owen Taylor's avatar
Owen Taylor committed
1542
  *)
1543 1544
    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
    for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do
Owen Taylor's avatar
Owen Taylor committed
1545
      test -z "$ac_dir" && ac_dir=.
Manish Singh's avatar
Manish Singh committed
1546
      if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then
1547 1548 1549 1550 1551 1552 1553 1554 1555
	# Check to see if the nm accepts a BSD-compat flag.
	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
	#   nm: unknown option "B" ignored
	if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
	  NM="$ac_dir/nm -B"
	  break
	elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
	  NM="$ac_dir/nm -p"
	  break
Owen Taylor's avatar
Owen Taylor committed
1556
	else
1557 1558
	  NM=${NM="$ac_dir/nm"} # keep the first match, but
	  continue # so that we can try to find one that supports BSD flags
Owen Taylor's avatar
Owen Taylor committed
1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575
	fi
      fi
    done
    IFS="$ac_save_ifs"
    test -z "$NM" && NM=nm
    ;;
  esac
  echo "$ac_t$NM" 1>&6
fi

# Check for command to grab the raw symbol name followed by C symbol from nm.
echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6

# These are sane defaults that work on at least a few old systems.
# [They come from Ultrix.  What could be older than Ultrix?!! ;)]

# Character class describing NM global symbol codes.
1576
symcode='[BCDEGRST]'
Owen Taylor's avatar
Owen Taylor committed
1577 1578 1579 1580 1581

# Regexp to match symbols that can be accessed directly from C.
sympat='\([_A-Za-z][_A-Za-z0-9]*\)'

# Transform the above into a raw symbol and a C symbol.
1582 1583 1584 1585
symxfrm='\1 \2\3 \3'

# Transform an extracted symbol line into a proper C declaration
global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
Owen Taylor's avatar
Owen Taylor committed
1586 1587 1588 1589

# Define system-specific variables.
case "$host_os" in
aix*)
1590 1591 1592 1593
  symcode='[BCDT]'
  ;;
cygwin* | mingw*)
  symcode='[ABCDGISTW]'
Owen Taylor's avatar
Owen Taylor committed
1594
  ;;
1595 1596
hpux*) # Its linker distinguishes data from code symbols
  global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
1597
  ;;
Owen Taylor's avatar
Owen Taylor committed
1598 1599 1600
irix*)
  symcode='[BCDEGRST]'
  ;;
1601
solaris*)
1602
  symcode='[BDT]'
Owen Taylor's avatar
Owen Taylor committed
1603
  ;;
Manish Singh's avatar
Manish Singh committed
1604 1605 1606
sysv4)
  symcode='[DFNSTU]'
  ;;
Owen Taylor's avatar
Owen Taylor committed
1607 1608 1609 1610
esac

# If we're using GNU nm, then use its standard symbol codes.
if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
1611
  symcode='[ABCDGISTW]'
Owen Taylor's avatar
Owen Taylor committed
1612 1613
fi

1614 1615
# Try without a prefix undercore, then with it.
for ac_symprfx in "" "_"; do
1616

1617 1618
  # Write the raw and C identifiers.
  global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode\)[ 	][ 	]*\($ac_symprfx\)$sympat$/$symxfrm/p'"
Owen Taylor's avatar
Owen Taylor committed
1619

1620 1621 1622 1623
  # Check to see that the pipe works correctly.
  pipe_works=no
  $rm conftest*
  cat > conftest.c <<EOF
Owen Taylor's avatar
Owen Taylor committed
1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634
#ifdef __cplusplus
extern "C" {
#endif
char nm_test_var;
void nm_test_func(){}
#ifdef __cplusplus
}
#endif
main(){nm_test_var='a';nm_test_func();return(0);}
EOF

1635 1636
  echo "$progname:1635: checking if global_symbol_pipe works" >&5
  if { (eval echo $progname:1636: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then
1637 1638
    # Now try to grab the symbols.
    nlist=conftest.nm
1639
    if { echo "$progname:1639: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then
Owen Taylor's avatar
Owen Taylor committed
1640