* configure.in: Set HDLFLAGS for *-*-hpux with --enable-shared.
[external/binutils.git] / gprof / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.3)dnl
3 AC_INIT(gprof.c)
4
5 AC_ARG_ENABLE(shared,
6 [  --enable-shared         build shared BFD library],
7 [case "${enableval}" in
8   yes) shared=true ;;
9   no)  shared=false ;;
10   *)   AC_MSG_ERROR([bad value ${enableval} for BFD shared option]) ;;
11 esac])dnl
12
13 AC_PROG_CC
14
15 AC_CANONICAL_SYSTEM
16 AC_ARG_PROGRAM
17
18 case "${target}" in
19 alpha-*-*)      MY_TARGET=alpha ;;
20 changequote(,)dnl
21 i[345]86-*-*)   MY_TARGET=i386 ;;
22 changequote([,])dnl
23 sparc-*-*)      MY_TARGET=sparc ;;
24 tahoe-*-*)      MY_TARGET=tahoe ;;
25 vax-*-*)        MY_TARGET=vax ;;
26 ns32k-*-*)      MY_TARGET=ns532;;
27 *-*-*)          MY_TARGET=dummy ;;
28 esac
29
30 AC_SUBST(MY_TARGET)
31
32 BFDLIB='-L../bfd -lbfd'
33
34 # We need to handle some special cases if BFD was built shared.
35 if test "${shared}" = "true"; then
36   case "${host}" in
37   *-*-sunos*)
38   # On SunOS, we must link against the name we are going to install,
39   # not -lbfd, since SunOS does not support SONAME.
40   BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`'
41   ;;
42   esac
43 fi
44 AC_SUBST(BFDLIB)
45
46 HLDFLAGS=
47 # If we have shared libraries, try to set rpath reasonably.
48 if test "${shared}" = "true"; then
49   case "${host}" in
50   *-*-hpux*)
51     HLDFLAGS='-Wl,+s,+b,$(libdir)'
52     ;;
53   *-*-irix5*)
54     HLDFLAGS='-Wl,-rpath,$(libdir)'
55     ;;
56   *-*-linux*aout*)
57     ;;
58   *-*-linux*)
59     HLDFLAGS='-Wl,-rpath,$(libdir)'
60     ;;
61   *-*-sysv4* | *-*-solaris*)
62     HLDFLAGS='-R $(libdir)'
63     ;;
64   esac
65 fi
66
67 # On SunOS, if the linker supports the -rpath option, use it to
68 # prevent ../bfd and ../opcodes from being included in the run time
69 # search path.
70 case "${host}" in
71   *-*-sunos*)
72     echo 'main () { }' > conftest.c
73     ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
74     if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
75       :
76     elif grep 'No such file' conftest.t >/dev/null 2>&1; then
77       :
78     elif test "${shared}" = "true"; then
79       HLDFLAGS='-Wl,-rpath=$(libdir)'
80     else
81       HLDFLAGS='-Wl,-rpath='
82     fi
83     rm -f conftest.t conftest.c conftest
84     ;;
85 esac
86 AC_SUBST(HLDFLAGS)
87
88 AC_OUTPUT(Makefile)