-# This file is a shell script that supplies the information necessary
-# to tailor a template configure script into the configure script
-# appropriate for this directory. For more information, check any
-# existing configure script.
+dnl Process this file with autoconf to produce a configure script.
+AC_PREREQ(2.3)dnl
+AC_INIT(gprof.c)
-srctrigger=gprof.c
-srcname="gprof"
+AC_ARG_ENABLE(shared,
+[ --enable-shared build shared BFD library],
+[case "${enableval}" in
+ yes) shared=true ;;
+ no) shared=false ;;
+ *bfd*) shared=true ;;
+ *) shared=false ;;
+esac])dnl
-# per-host:
+AC_PROG_CC
+
+AC_CANONICAL_SYSTEM
+AC_ARG_PROGRAM
-# per-target:
case "${target}" in
-i386-*-*) my_target=i386 ;;
-sparc-*-*) my_target=sparc ;;
-tahoe-*-*) my_target=tahoe ;;
-vax-*-*) my_target=vax ;;
-*-*-*) my_target=dummy ;;
+alpha-*-*) MY_TARGET=alpha ;;
+changequote(,)dnl
+i[345]86-*-*) MY_TARGET=i386 ;;
+changequote([,])dnl
+sparc-*-*) MY_TARGET=sparc ;;
+tahoe-*-*) MY_TARGET=tahoe ;;
+vax-*-*) MY_TARGET=vax ;;
+ns32k-*-*) MY_TARGET=ns532;;
+*-*-*) MY_TARGET=dummy ;;
+esac
+
+AC_SUBST(MY_TARGET)
+
+BFDLIB='-L../bfd -lbfd'
+
+# We need to handle some special cases if BFD was built shared.
+case "${host}" in
+ *-*-sunos*)
+ # On SunOS, we must link against the name we are going to install,
+ # not -lbfd, since SunOS does not support SONAME.
+ if test "${shared}" = "true"; then
+ BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`'
+ fi
+ ;;
+alpha*-*-osf*)
+ # On Alpha OSF/1, the native linker searches all the -L
+ # directories for any LIB.so files, and only then searches for any
+ # LIB.a files. That means that if there is an installed
+ # libbfd.so, but this build is not done with --enable-shared, the
+ # link will wind up being against the install libbfd.so rather
+ # than the newly built libbfd. To avoid this, we must explicitly
+ # link against libbfd.a when --enable-shared is not used.
+ if test "${shared}" != "true"; then
+ BFDLIB='../bfd/libbfd.a'
+ fi
+ ;;
esac
+AC_SUBST(BFDLIB)
-target_makefile_frag=config/mt-${my_target}
-if [ ! -f ${srcdir}/${target_makefile_frag} ] ; then
- target_makefile_frag=
+HLDFLAGS=
+# If we have shared libraries, try to set rpath reasonably.
+if test "${shared}" = "true"; then
+ case "${host}" in
+ *-*-hpux*)
+ HLDFLAGS='-Wl,+s,+b,$(libdir)'
+ ;;
+ *-*-irix5*)
+ HLDFLAGS='-Wl,-rpath,$(libdir)'
+ ;;
+ *-*-linux*aout*)
+ ;;
+ *-*-linux*)
+ HLDFLAGS='-Wl,-rpath,$(libdir)'
+ ;;
+ *-*-sysv4* | *-*-solaris*)
+ HLDFLAGS='-R $(libdir)'
+ ;;
+ esac
fi
+
+# On SunOS, if the linker supports the -rpath option, use it to
+# prevent ../bfd and ../opcodes from being included in the run time
+# search path.
+case "${host}" in
+ *-*-sunos*)
+ echo 'main () { }' > conftest.c
+ ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
+ if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
+ :
+ elif grep 'No such file' conftest.t >/dev/null 2>&1; then
+ :
+ elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
+ :
+ elif test "${shared}" = "true"; then
+ HLDFLAGS='-Wl,-rpath=$(libdir)'
+ else
+ HLDFLAGS='-Wl,-rpath='
+ fi
+ rm -f conftest.t conftest.c conftest
+ ;;
+esac
+AC_SUBST(HLDFLAGS)
+
+AC_OUTPUT(Makefile)