* configure.in: Define BSD44_FORMAT if the target looks like a
[platform/upstream/binutils.git] / gprof / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 AC_PREREQ(2.5)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   *bfd*) shared=true ;;
11   *) shared=false ;;
12 esac])dnl
13
14 AC_PROG_CC
15 AC_PROG_INSTALL
16
17 AC_ISC_POSIX
18
19 AC_CANONICAL_SYSTEM
20 AC_ARG_PROGRAM
21
22 case "${target}" in
23 alpha-*-*)      MY_TARGET=alpha ;;
24 changequote(,)dnl
25 i[3456]86-*-*)  MY_TARGET=i386 ;;
26 changequote([,])dnl
27 sparc-*-*)      MY_TARGET=sparc ;;
28 tahoe-*-*)      MY_TARGET=tahoe ;;
29 vax-*-*)        MY_TARGET=vax ;;
30 ns32k-*-*)      MY_TARGET=ns532;;
31 *-*-*)          MY_TARGET=dummy ;;
32 esac
33
34 AC_SUBST(MY_TARGET)
35
36 dnl We need to set BSD44_FORMAT on a host which uses the additional
37 dnl header fields.  This is an attempt to do that.  I can't think of a
38 dnl good feature test for this.
39 case "${target}" in
40 *-*-bsd4.4* | *-*-netbsd* | *-*-freebsd* | *-*-openbsd*)
41   AC_DEFINE(BSD44_FORMAT)
42   ;;
43 esac
44
45 BFDLIB='-L../bfd -lbfd'
46
47 # We need to handle some special cases if BFD was built shared.
48 case "${host}" in
49   *-*-sunos*)
50   # On SunOS, we must link against the name we are going to install,
51   # not -lbfd, since SunOS does not support SONAME.
52   if test "${shared}" = "true"; then
53     BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`'
54   fi
55   ;;
56 alpha*-*-osf*)
57   # On Alpha OSF/1, the native linker searches all the -L
58   # directories for any LIB.so files, and only then searches for any
59   # LIB.a files.  That means that if there is an installed
60   # libbfd.so, but this build is not done with --enable-shared, the
61   # link will wind up being against the install libbfd.so rather
62   # than the newly built libbfd.  To avoid this, we must explicitly
63   # link against libbfd.a when --enable-shared is not used.
64   if test "${shared}" != "true"; then
65     BFDLIB='../bfd/libbfd.a'
66   fi
67   ;;
68 esac
69 AC_SUBST(BFDLIB)
70
71 HLDFLAGS=
72 HLDENV=
73 # If we have shared libraries, try to set rpath reasonably.
74 if test "${shared}" = "true"; then
75   case "${host}" in
76   *-*-hpux*)
77     HLDFLAGS='-Wl,+s,+b,$(libdir)'
78     ;;
79   *-*-irix5*)
80     HLDFLAGS='-Wl,-rpath,$(libdir)'
81     ;;
82   *-*-linux*aout*)
83     ;;
84   *-*-linux*)
85     HLDFLAGS='-Wl,-rpath,$(libdir)'
86     ;;
87   *-*-solaris*)
88     HLDFLAGS='-R $(libdir)'
89     ;;
90   *-*-sysv4*)
91     HLDENV='if test -z "$${LD_RUN_PATH}"; then LD_RUN_PATH=$(libdir); else LD_RUN_PATH=$${LD_RUN_PATH}:$(libdir); fi; export LD_RUN_PATH;'
92     ;;
93   esac
94 fi
95
96 # On SunOS, if the linker supports the -rpath option, use it to
97 # prevent ../bfd and ../opcodes from being included in the run time
98 # search path.
99 case "${host}" in
100   *-*-sunos*)
101     echo 'main () { }' > conftest.c
102     ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
103     if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
104       :
105     elif grep 'No such file' conftest.t >/dev/null 2>&1; then
106       :
107     elif grep 'do not mix' conftest.t >/dev/null 2>&1; then
108       :
109     elif test "${shared}" = "true"; then
110       HLDFLAGS='-Wl,-rpath=$(libdir)'
111     else
112       HLDFLAGS='-Wl,-rpath='
113     fi
114     rm -f conftest.t conftest.c conftest
115     ;;
116 esac
117 AC_SUBST(HLDFLAGS)
118 AC_SUBST(HLDENV)
119
120 AC_OUTPUT(Makefile)