* configure.in: Don't set CC. Look for --enable-shared. Set
[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   *-*-irix5*)
51     HLDFLAGS='-Wl,-rpath,$(libdir)'
52     ;;
53   *-*-linux*aout*)
54     ;;
55   *-*-linux*)
56     HLDFLAGS='-Wl,-rpath,$(libdir)'
57     ;;
58   *-*-sysv4* | *-*-solaris*)
59     HLDFLAGS='-R $(libdir)'
60     ;;
61   esac
62 fi
63
64 # On SunOS, if the linker supports the -rpath option, use it to
65 # prevent ../bfd and ../opcodes from being included in the run time
66 # search path.
67 case "${host}" in
68   *-*-sunos*)
69     echo 'main () { }' > conftest.c
70     ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
71     if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
72       :
73     elif grep 'No such file' conftest.t >/dev/null 2>&1; then
74       :
75     elif test "${shared}" = "true"; then
76       HLDFLAGS='-Wl,-rpath=$(libdir)'
77     else
78       HLDFLAGS='-Wl,-rpath='
79     fi
80     rm -f conftest.t conftest.c conftest
81     ;;
82 esac
83 AC_SUBST(HLDFLAGS)
84
85 AC_OUTPUT(Makefile)