* configure.host: Set RPATH_ENVVAR.
[external/binutils.git] / bfd / configure.host
1 # This file is a shell script that overrides some of the tools and
2 # flags used on a host specific basis.
3
4 # Since the "bfd/hosts" directory is shared by the bfd, opcodes, and
5 # binutils directories (at least), the index to it is also shared.
6 # This is that index.  Each configure.in file should source this file
7 # in its per-host part.
8
9 # This sets the following shell variables:
10 #  CC                   compiler to use (only if needed and not already set)
11 #  CFLAGS               override CFLAGS (only if needed and not already set)
12 #  LDFLAGS              override LDFLAGS (only if needed and not already set)
13 #  AR                   archiver to use (only if needed and not already set)
14 #  RANLIB               ranlib to use (only if needed and not already set)
15 #  HDEFINES             host specific compiler options
16 #  host64               set to true if this is a 64 bit host
17 #  HOST_64BIT_TYPE      host 64 bit type
18 #  SHLIB_CC             compiler to use when building shared library
19 #  SHLIB_CFLAGS         flags to use when building shared library
20 #  PICFLAG              may be set to flag to use to compile PIC
21 #  SHLINK               may be set to the name to link the shared library to
22 #  ALLLIBS              may be set to libraries to build
23 #  HLDFLAGS             LDFLAGS specific to the host
24 #  RPATH_ENVVAR         environment variable used to find shared libraries
25
26 HDEFINES=
27 host64=false
28 HOST_64BIT_TYPE=
29
30 case "${host}" in
31 # WHEN ADDING ENTRIES TO THIS MATRIX:
32 #  Make sure that the left side always has two dashes.  Otherwise you
33 #  can get spurious matches.  Even for unambiguous cases, do this as a
34 #  convention, else the table becomes a real mess to understand and maintain.
35 #
36 # Note that these entries cannot be fully alphabetical.  Don't try.
37 # The order of matching is critical when multiple lines could match.
38
39 alpha-*-*)              host64=true; HOST_64BIT_TYPE=long ;;
40
41 a29k-*-*)               CC=${CC-u3cc}; AR=${AR-u3ar} ;;
42
43 hppa*-*-hpux*)          HDEFINES=-DHOST_HPPAHPUX ;;
44 hppa*-*-hiux*)          HDEFINES=-DHOST_HPPAHPUX ;;
45 hppa*-*-bsd*)           HDEFINES=-DHOST_HPPABSD ;;
46 hppa*-*-osf*)           HDEFINES=-DHOST_HPPAOSF ;;
47
48 i[345]86-sequent-bsd*)  HDEFINES=-Dshared=genshared ;;
49 i[345]86-sequent-sysv4*) ;;
50 i[345]86-sequent-sysv*) HDEFINES=-Dshared=genshared ;;
51 i[345]86-ncr*-sysv4*)   CC=${CC-/usr/ccs/ATT/cc}
52                         test -z "$CFLAGS" && CFLAGS=" "
53                         ;;
54 i[345]86-*-go32*)       test -z "$CC" && CC="i386-go32-gcc -fno-omit-frame-pointer -O2 -Wl,-S"
55                         AR=${AR-i386-go32-ar}
56                         RANLIB=${RANLIB-i386-go32-ranlib}
57                         ;;
58 i[345]86-*-win32)       test -z "$CC" && CC="i386-win32-gcc -O2"
59                         AR=${AR-i386-win32-ar}
60                         RANLIB=${RANLIB-i386-win32-ranlib}
61                         ;;
62
63 mips-dec-netbsd*)       ;;
64 mips-dec-*)             HDEFINES="-G 4" ;;
65 mips-sgi-irix3*)        HDEFINES="-G 4"
66                         test -z "$LDFLAGS" && LDFLAGS=-lmalloc
67                         ;;
68 mips-sgi-irix4*)        HDEFINES="-G 4"
69                         test -z "$LDFLAGS" && LDFLAGS=-lmalloc
70                         ;;
71 mips-*-sysv4*)          ;;
72 mips-*-sysv*)           HDEFINES="-G 4" ;;
73 mips-*-riscos*)         HDEFINES="-G 4" ;;
74
75 m68*-apollo*-sysv*)     # sef@cygnus.com says this is how to compile
76                         # on an apollo in the SysV environment.
77                         test -z "$CC" && CC="cc -A nansi -A cpu,3000 -A runtype,any -A systype,any -DSHORT_ENUM_BUG -DUSG -U__STDC__ -Dm68000=mc68000"
78                         ;;
79 m68*-hp-hpux*)          HDEFINES=-DHOST_HP300HPUX ;;
80
81 m88*-*-dgux*)           test -z "$CC" && CC="gcc -Wall -ansi -D__using_DGUX"
82                         ;;
83
84 romp-*-*)               # hc/pcc just can't cut it
85                         CC=${CC-gcc}
86                         ;;
87
88 rs6000-*-aix4)          HDEFINES=-DHOST_AIX ;;
89 rs6000-*-*)             HDEFINES=-DHOST_AIX ;;
90 powerpc-*-aix4*)        HDEFINES=-DHOST_AIX ;;
91 powerpc-*-aix*)         HDEFINES=-DHOST_AIX ;;
92
93 esac
94
95 # If we are configuring with --enable-shared, adjust the shared
96 # library support based on the host.  This support must work for both
97 # the BFD and the opcodes libraries.
98 HLDFLAGS=
99 RPATH_ENVVAR=LD_LIBRARY_PATH
100 SHLIB_CC='$(CC)'
101 SHLIB_CFLAGS='-shared'
102 if [ "${shared}" = "true" ]; then
103   case "${host}" in
104   hppa*-*-*)            picfrag=../config/mh-papic ;;
105   i[3456]86-*-*)        picfrag=../config/mh-x86pic ;;
106   *-*-*)                picfrag=../config/mh-${host_cpu}pic ;;
107   esac
108   if [ -f "${picfrag}" ]; then
109     pic=`sed -n -e 's/^PICFLAG[         ]*=[    ]*\(.*\)$/\1/p' ${picfrag}`
110     if [ -n "${pic}" ]; then
111       PICFLAG=${pic}
112     fi
113   fi
114
115   case "${host}" in
116   *-dec-osf*)
117     # -fpic is not needed on the Alpha.
118     PICFLAG=
119     ;;
120   *-*-hpux*)
121     # HP/UX uses .sl for shared libraries.
122     SHLINK=`echo ${SHLINK} | sed -e 's/so$/sl/'`
123     SHLIB_CFLAGS='-shared $(PICFLAG)'
124     HLDFLAGS='-Wl,+s,+b,$(libdir)'
125     RPATH_ENVVAR=SHLIB_PATH
126     ;;
127   *-*-irix5*)
128     # -fpic is not needed on Irix 5.
129     PICFLAG=
130     SHLIB_CFLAGS='-shared -Wl,-soname,$(SONAME)'
131     HLDFLAGS='-Wl,-rpath,$(libdir)'
132     ;;
133   *-*-linux*aout*)
134     ;;
135   *-*-linux*)
136     SHLIB_CFLAGS='-shared -Wl,-soname,$(SONAME)'
137     HLDFLAGS='-Wl,-rpath,$(libdir)'
138     ;;
139   *-*-sysv4* | *-*-solaris*)
140     SHLIB_CFLAGS='-shared -h $(SONAME)'
141     HLDFLAGS='-R $(libdir)'
142     ;;
143   *-*-sunos*)
144     # Build a libTARGET-bfd.so.VERSION symlink in the object directory.
145     ALLLIBS=`echo ${ALLLIBS} | sed -e 's/\$(SHLINK)/stamp-tshlink/'`
146     ;;
147   esac
148 fi
149
150 # On SunOS, if the linker supports the -rpath option, use it to
151 # prevent ../bfd and ../opcodes from being included in the run time
152 # search path.
153 case "${host}" in
154   *-*-sunos*)
155     echo 'main () { }' > conftest.c
156     ${CC-gcc} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
157     if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
158       :
159     elif grep 'No such file' conftest.t >/dev/null 2>&1; then
160       :
161     elif [ "${shared}" = "true" ]; then
162       HLDFLAGS='-Wl,-rpath=$(libdir)'
163     else
164       HLDFLAGS='-Wl,-rpath='
165     fi
166     rm -f conftest.t conftest.c conftest
167     ;;
168 esac