* configure.in: Check for --enable-shared. If linking against
[platform/upstream/binutils.git] / gas / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2 dnl
3 dnl And be careful when changing it!  If you must add tests with square
4 dnl brackets, be sure changequote invocations surround it.
5 dnl
6 dnl
7 AC_PREREQ(2.3)dnl We only need 2.0, but pre-2.3 loses on some AIX version.
8 AC_INIT(as.h)dnl
9 dnl
10 user_bfd_gas=
11 AC_ARG_ENABLE(bfd-assembler,
12 [  --enable-bfd-assembler  use BFD back end for writing object files],
13 [case "${enableval}" in
14   yes) need_bfd=yes user_bfd_gas=yes ;;
15   no)  user_bfd_gas=no ;;
16   *)   AC_MSG_ERROR(bad value ${enableval} given for bfd-assembler option) ;;
17 esac])dnl
18 AC_ARG_ENABLE(targets,
19 [    targets            alternative target configurations besides the primary],
20 [case "${enableval}" in
21   yes | "") AC_ERROR(enable-targets option must specify target names or 'all')
22             ;;
23   no)       enable_targets= ;;
24   *)        enable_targets=$enableval ;;
25 esac])dnl
26 AC_ARG_ENABLE(shared,
27 [  --enable-shared         build shared BFD library],
28 [case "${enableval}" in
29   yes) shared=true ;;
30   no)  shared=false ;;
31   *)   AC_MSG_ERROR([bad value ${enableval} for BFD shared option]) ;;
32 esac])dnl
33
34 # Generate a header file -- gets more post-processing by Makefile later.
35 AC_CONFIG_HEADER(conf)
36
37 dnl For recursion to work right, this must be an absolute pathname.
38 AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
39 AC_CANONICAL_SYSTEM
40 AC_ARG_PROGRAM
41
42 te_file=generic
43
44 # assign cpu type
45
46 # check for architecture variants
47 case ${target_cpu} in
48   armeb)        cpu_type=arm endian=big ;;
49   arm*)         cpu_type=arm endian=little ;;
50   hppa*)        cpu_type=hppa ;;
51 changequote(,)dnl
52   i[45]86)      cpu_type=i386 ;;
53   m680[012346]0) cpu_type=m68k ;;
54   m68008)       cpu_type=m68k ;;
55   m683??)       cpu_type=m68k ;;
56 changequote([,])dnl
57   m8*)          cpu_type=m88k ;;
58   mips*el)      cpu_type=mips endian=little;;
59   mips*)        cpu_type=mips endian=big ;;
60   powerpcle*)   cpu_type=ppc endian=little ;;
61   powerpc*)     cpu_type=ppc endian=big ;;
62   rs6000*)      cpu_type=ppc ;;
63   sparc64)      cpu_type=sparc
64                 AC_DEFINE(SPARC_V9) ;;
65   sparclite*)   cpu_type=sparc ;;
66   *)            cpu_type=${target_cpu} ;;
67 esac
68
69 # do we need the opcodes library?
70 case ${cpu_type} in
71   alpha | vax)
72     ;;
73   *)
74     OPCODES_DEP=../opcodes/libopcodes.a
75     OPCODES_LIB='-L../opcodes -lopcodes'
76
77     # We need to handle some special cases if opcodes was built shared.
78     if test "${shared}" = "true"; then
79       case "${host}" in
80       *-*-sunos*)
81       # On SunOS, we must link against the name we are going to install,
82       # not -lbfd, since SunOS does not support SONAME.
83       OPCODES_LIB='-L../opcodes -l`echo opcodes | sed '"'"'$(program_transform_name)'"'"'`'
84       ;;
85       esac
86     fi
87     ;;
88 esac
89 AC_SUBST(OPCODES_DEP)
90 AC_SUBST(OPCODES_LIB)
91
92 gas_target=${cpu_type}
93 this_target=${generic_target}
94
95 canon_targets=""
96 if test -n "$enable_targets" ; then
97   for t in `echo $enable_targets | sed 's/,/ /g'`; do
98     result=`$ac_config_sub $t 2>/dev/null`
99     if test -n "$result" ; then
100       canon_targets="$canon_targets $result"
101 #    else
102 #      # Permit "all", etc.  We don't support it yet though.
103 #      canon_targets="$canon_targets $t"
104     fi
105   done
106   GAS_UNIQ(canon_targets)
107 fi
108
109 emulations=""
110
111 for this_target in $target $canon_targets ; do
112
113     eval `echo $this_target | sed 's/^\(.*\)-\(.*\)-\(.*\)$/cpu=\1 vendor=\2 os=\3/'`
114
115     # check for architecture variants
116     case ${cpu} in
117       hppa*)            cpu_type=hppa ;;
118 changequote(,)dnl
119       i[45]86)          cpu_type=i386 ;;
120       m680[012346]0)    cpu_type=m68k ;;
121       m68008)           cpu_type=m68k ;;
122       m683??)           cpu_type=m68k ;;
123 changequote([,])dnl
124       m8*)              cpu_type=m88k ;;
125       mips*el)          cpu_type=mips endian=little;;
126       mips*)            cpu_type=mips endian=big ;;
127       powerpcle*)       cpu_type=ppc endian=little ;;
128       powerpc*)         cpu_type=ppc endian=big ;;
129       rs6000*)          cpu_type=ppc ;;
130       sparc64)          cpu_type=sparc want_sparc_v9=true ;;
131       sparclite*)       cpu_type=sparc ;;
132       *)                cpu_type=${cpu} ;;
133     esac
134
135     if test ${this_target} = $target ; then
136       target_cpu_type=${cpu_type}
137     elif test ${target_cpu_type} != ${cpu_type} ; then
138       continue
139     fi
140
141     targ=${cpu_type}
142     generic_target=${cpu_type}-$vendor-$os
143     dev=no
144     bfd_gas=no
145     em=generic
146
147     # assign object format
148     case ${generic_target} in
149       a29k-amd-udi)         fmt=coff targ=ebmon29k ;;
150       a29k-amd-ebmon)       fmt=coff targ=ebmon29k ;;
151       a29k-nyu-sym1)        fmt=coff targ=ebmon29k ;;
152       a29k-*-vxworks*)      fmt=coff ;;
153
154       alpha-*-netware*)     fmt=ecoff ;;
155       alpha-*-osf*)         fmt=ecoff ;;
156       alpha-*-linux*)       fmt=ecoff ;;
157
158 # start-sanitize-arc
159       arc-*-elf*)           fmt=elf bfd_gas=yes ;;
160 # end-sanitize-arc
161
162       arm-*-riscix*)        fmt=aout targ=arm-lit ;;
163       arm-*-aout)           fmt=aout
164                             case "$endian" in
165                               big)      targ=arm-big ;;
166                               *)        targ=arm-lit ;;
167                             esac
168                             ;;
169       arm-*-coff)           fmt=coff ;;
170       arm-*-riscix*)        fmt=aout ;;
171       arm-*-pe)             fmt=coff targ=armcoff em=pe ;;
172
173       hppa-*-*elf*)         fmt=elf em=hppa ;;
174       hppa-*-lites*)        fmt=elf em=hppa ;;
175       hppa-*-osf*)          fmt=som em=hppa ;;
176       hppa-*-hpux*)         fmt=som em=hppa ;;
177       hppa-*-bsd*)          fmt=som em=hppa ;;
178       hppa-*-hiux*)         fmt=som em=hppa ;;
179
180       h8300-*-coff)         fmt=coff ;;
181
182       i386-ibm-aix*)        fmt=coff targ=i386coff
183                              em=i386aix ;;
184       i386-*-bsd*)          fmt=aout em=386bsd ;;
185       i386-*-netbsd0.8)     fmt=aout em=386bsd ;;
186       i386-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes;;
187       i386-*-linux*aout* | i386-*-linuxoldld)   fmt=aout em=linux ;;
188       i386-*-linux*coff*)   fmt=coff em=linux
189                              targ=i386coff ;;
190       i386-*-linux*)        fmt=elf em=linux ;;
191       i386-*-lynxos*)       fmt=coff targ=i386coff
192                              em=lynx ;;
193       i386-*-sysv4* | i386-*-solaris* | i386-*-elf)
194                             fmt=elf ;;
195       i386-*-sco*elf*)      fmt=elf targ=sco5 ;;
196       i386-*-coff | i386-*-sysv* | i386-*-sco* | i386-*-isc*)
197                             fmt=coff targ=i386coff ;;
198       i386-*-vsta)          fmt=aout ;;
199       i386-*-go32)          fmt=coff targ=i386coff ;;
200       i386-*-gnu*)          fmt=elf ;;
201       i386-*-mach*)
202                             fmt=aout em=mach bfd_gas=yes ;;
203       i386-*-msdos*)        fmt=aout ;;
204       i386-*-moss*)         fmt=elf ;;
205       i386-*-pe)            fmt=coff targ=i386coff em=pe bfd_gas=yes;;
206       i386-*-cygwin32)      fmt=coff targ=i386coff em=pe bfd_gas=yes;;
207       i386-*-*nt)           fmt=coff targ=i386coff em=pe bfd_gas=yes;;
208       i960-*-bout)          fmt=bout ;;
209       i960-*-coff)          fmt=coff em=ic960 targ=ic960coff ;;
210       i960-*-nindy*)        fmt=bout ;;
211       i960-*-vxworks4*)     fmt=bout ;;
212       i960-*-vxworks5.0)    fmt=bout ;;
213       i960-*-vxworks5.*)    fmt=coff em=ic960 targ=ic960coff ;;
214       i960-*-vxworks*)      fmt=bout ;;
215
216       m68k-*-vxworks* | m68k-ericsson-ose | m68k-*-sunos*)
217                             fmt=aout em=sun3 ;;
218       m68k-motorola-sysv*)  fmt=coff targ=m68kcoff em=delta ;;
219       m68k-bull-sysv3*)     fmt=coff targ=m68kcoff em=dpx2 ;;
220       m68k-apollo-*)        fmt=coff targ=apollo em=apollo ;;
221       m68k-*-sysv4 | m68k-*-elf) # must be before -sysv*
222                             fmt=elf ;;
223       m68k-*-coff | m68k-*-sysv*)
224                             fmt=coff targ=m68kcoff ;;
225       m68k-*-hpux*)         fmt=hp300 em=hp300 ;;
226       m68k-*-lynxos*)       fmt=coff targ=m68kcoff
227                              em=lynx ;;
228       m68k-*-netbsd*)       fmt=aout em=nbsd bfd_gas=yes ;;
229       m68*-apple-aux*)      fmt=coff targ=m68kcoff em=aux ;;
230
231       m88k-motorola-sysv3*) fmt=coff targ=m88kcoff em=delt88 ;;
232       m88k-*-coff*)         fmt=coff targ=m88kcoff ;;
233
234       # don't change em like *-*-bsd does
235       mips-dec-netbsd*)     fmt=elf targ=mips-lit endian=little ;;
236       mips-dec-bsd*)        fmt=aout targ=mips-lit ;;
237       mips-sony-bsd*)       fmt=ecoff targ=mips-big ;;
238       mips-*-bsd*)          AC_MSG_ERROR(Unknown vendor for mips-bsd configuration.) ;;
239       mips-*-ultrix*)       fmt=ecoff targ=mips-lit endian=little ;;
240       mips-*-ecoff*)        fmt=ecoff 
241                             case "$endian" in
242                             big) targ=mips-big ;;
243                             *)   targ=mips-lit ;;
244                             esac
245                             ;;
246       mips-*-ecoff*)        fmt=ecoff targ=mips-big ;;
247       mips-*-gnu*)          fmt=aout
248                             case "$endian" in
249                             big) targ=mips-big ;;
250                             *)   targ=mips-lit ;;
251                             esac
252                             ;;
253       mips-*-irix5*)        fmt=elf targ=mips-big ;;
254       mips-*-irix*)         fmt=ecoff targ=mips-big ;;
255       mips-*-riscos*)       fmt=ecoff targ=mips-big ;;
256       mips-*-sysv*)         fmt=ecoff targ=mips-big ;;
257       mips-*-elf*)          fmt=elf 
258                             case "$endian" in
259                             big) targ=mips-big ;;
260                             *)   targ=mips-lit ;;
261                             esac
262                             ;;
263       ppc-*-pe | ppc-*-cygwin32 | ppc-*-winnt*)
264                             fmt=coff em=pe 
265                             case "$endian" in
266                             big) targ=ppc-big ;;
267                             *)   targ=ppc-lit ;;
268                             esac
269                             ;;
270       ppc-*-aix*)           fmt=coff ;;
271       ppc-*-elf* | ppc-*-eabi* | ppc-*-sysv4*)
272                             fmt=elf
273                             case "$endian" in
274                             big)  targ=ppc-big ;;
275                             *)    targ=ppc-lit ;;
276                             esac
277                             ;;
278       ppc-*-macos* | ppc-*-mpw*)
279                             fmt=coff em=macos ;;
280       ppc-*-netware*)       fmt=elf em=ppcnw ;;
281
282       sh-*-coff)            fmt=coff ;;
283
284 # start-sanitize-rce
285       rce-*-aout)           fmt=aout ;;
286 # end-sanitize-rce
287
288       ns32k-pc532-mach* | ns32k-pc532-ux*)    fmt=aout em=pc532mach ;;
289       ns32k-pc532-netbsd* | ns32k-pc532-lites*)  fmt=aout em=nbsd532 ;;
290
291       sparc-*-sunos4*)      fmt=aout em=sun3 ;;
292       sparc-*-aout | sparc*-*-vxworks)
293                             fmt=aout ;;
294       sparc-*-coff)         fmt=coff ;;
295       sparc-*-lynxos*)      fmt=coff em=lynx ;;
296       sparc-fujitsu-none)   fmt=aout ;;
297       sparc-*-elf | sparc*-*-solaris*)
298                             fmt=elf ;;
299       sparc-*-netbsd*)      fmt=aout em=nbsd bfd_gas=yes ;;
300
301       vax-*-bsd* | vax-*-ultrix*)
302                             fmt=aout ;;
303       vax-*-vms)            fmt=vms ;;
304
305       z8k-*-coff | z8k-*-sim)
306                             fmt=coff ;;
307
308       w65-*-*)              fmt=coff ;;
309
310       *-*-aout | *-*-scout)
311                             fmt=aout ;;
312       *-*-nindy*)
313                             fmt=bout ;;
314       *-*-bsd*)
315                             fmt=aout em=sun3 ;;
316       *-*-generic)          fmt=generic ;;
317       *-*-xray | *-*-hms)   fmt=coff ;;
318       *-*-sim)              fmt=coff ;;
319       *-*-elf | *-*-sysv4* | *-*-solaris*)
320                             AC_MSG_WARN(GAS support for ${generic_target} is incomplete.)
321                             fmt=elf dev=yes ;;
322       *-*-vxworks)          fmt=aout ;;
323       *-*-netware)          fmt=elf ;;
324     esac
325
326     case ${cpu_type}-${fmt} in
327       arm-*)    bfd_gas=yes ;;
328     # not yet
329     # i386-aout)        bfd_gas=preferred ;;
330       mips-*)   bfd_gas=yes ;;
331       ns32k-*)  bfd_gas=yes ;;
332       ppc-*)    bfd_gas=yes ;;
333       sparc-*)  bfd_gas=yes ;;
334       *-elf)    bfd_gas=yes ;;
335       *-ecoff)  bfd_gas=yes ;;
336       *-som)    bfd_gas=yes ;;
337       *)                ;;
338     esac
339
340 # Other random stuff.
341
342     test -n "$want_sparc_v9" && AC_DEFINE(SPARC_V9)
343
344     case ${cpu}-${vendor}-${os} in
345       sparc64-*-elf*) AC_DEFINE(SPARC_ARCH64) ;;
346     esac
347
348     case ${cpu_type} in
349       m68k)
350         case ${extra_objects} in
351         *m68k-parse.o*) ;;
352         *) extra_objects="$extra_objects m68k-parse.o" ;;
353         esac
354         ;;
355     esac
356
357 # See if we really can support this configuration with the emulation code.
358
359     if test $this_target = $target ; then
360       primary_bfd_gas=$bfd_gas
361       obj_format=$fmt
362       gas_target=$targ
363       te_file=$em
364
365       if test $bfd_gas = no ; then
366         # Can't support other configurations this way.
367         break
368       fi
369     elif test $bfd_gas = no ; then
370       # Can't support this configuration.
371       break
372     fi
373
374 # From target name and format, produce a list of supported emulations.
375
376     case ${generic_target}-${fmt} in
377       mips-*-irix5*-*)  emulation="mipsbelf mipslelf mipself mipsbecoff mipslecoff mipsecoff" ;;
378       mips-*-*-ecoff)   case "$endian" in
379                         big)    emulation="mipsbecoff mipslecoff mipsecoff" ;;
380                         *)      emulation="mipslecoff mipsbecoff mipsecoff" ;;
381                         esac ;;
382       mips-*-*-elf)     case "$endian" in
383                         big)    emulation="mipsbelf mipslelf mipself" ;;
384                         *)      emulation="mipslelf mipsbelf mipself" ;;
385                         esac ;;
386     esac
387
388     emulations="$emulations $emulation"
389
390 done
391
392 # Assign floating point type.  Most processors with FP support
393 # IEEE FP.  On those that don't support FP at all, usually IEEE
394 # is emulated.
395 case ${target_cpu} in
396   vax | tahoe ) atof=${target_cpu} ;;
397   *)            atof=ieee ;;
398 esac
399
400 case "${obj_format}" in
401   "") AC_MSG_ERROR(GAS does not know what format to use for target ${target}) ;;
402 esac
403
404 dnl
405 dnl Make sure the desired support files exist.
406 dnl
407
408 if test ! -r ${srcdir}/config/tc-${target_cpu_type}.c; then
409   AC_MSG_ERROR(GAS does not support target CPU ${target_cpu_type})
410 fi
411
412 if test ! -r ${srcdir}/config/obj-${obj_format}.c; then
413   AC_MSG_ERROR(GAS does not have support for object file format ${obj_format})
414 fi
415
416 # and target makefile frag
417
418 target_frag=${srcdir}/config/${gas_target}.mt
419 if test ! -r ${target_frag}; then
420   target_frag=/dev/null # ick! but subst_file can't be conditionalized
421 fi
422 AC_SUBST_FILE(target_frag)
423
424 case ${user_bfd_gas}-${primary_bfd_gas} in
425   yes-yes | no-no)
426     # We didn't override user's choice.
427     ;;
428   no-yes)
429     AC_MSG_WARN(Use of BFD is required for ${target}; overriding config options.)
430     ;;
431   no-preferred)
432     primary_bfd_gas=no
433     ;;
434   *-preferred)
435     primary_bfd_gas=yes
436     ;;
437   yes-*)
438     primary_bfd_gas=yes
439     ;;
440   -*)
441     # User specified nothing.
442     ;;
443 esac
444
445 # Some COFF configurations want these random other flags set.
446 case ${obj_format} in
447   coff)
448     case ${target_cpu_type} in
449       i386) AC_DEFINE(I386COFF) ;;
450       m68k) AC_DEFINE(M68KCOFF) ;;
451       m88k) AC_DEFINE(M88KCOFF) ;;
452     esac
453     ;;
454 esac
455
456 # Getting this done right is going to be a bitch.  Each configuration specified
457 # with --enable-targets=... should be checked for environment, format, cpu, and
458 # bfd_gas setting.
459 #
460 # For each configuration, the necessary object file support code must be linked
461 # in.  This might be only one, it might be up to four.  The necessary emulation
462 # code needs to be provided, too.
463 #
464 # And then there's "--enable-targets=all"....
465 #
466 # For now, just always do it for MIPS ELF or ECOFF configurations.  Sigh.
467
468 formats="${obj_format}"
469 emfiles=""
470 EMULATIONS=""
471 GAS_UNIQ(emulations)
472 for em in . $emulations ; do
473   case $em in
474     .)  continue ;;
475     mipsbelf | mipslelf)
476         fmt=elf   file=mipself ;;
477     mipsbecoff | mipslecoff)
478         fmt=ecoff file=mipsecoff ;;
479   esac
480   formats="$formats $fmt"
481   emfiles="$emfiles e-$file.o"
482   EMULATIONS="$EMULATIONS &$em,"
483 done
484 GAS_UNIQ(formats)
485 GAS_UNIQ(emfiles)
486 if test `set . $formats ; shift ; echo $#` -gt 1 ; then
487   for fmt in $formats ; do
488     case $fmt in
489       aout)     AC_DEFINE(OBJ_MAYBE_AOUT)    ;;
490       bout)     AC_DEFINE(OBJ_MAYBE_BOUT)    ;;
491       coff)     AC_DEFINE(OBJ_MAYBE_COFF)    ;;
492       ecoff)    AC_DEFINE(OBJ_MAYBE_ECOFF)   ;;
493       elf)      AC_DEFINE(OBJ_MAYBE_ELF)     ;;
494       generic)  AC_DEFINE(OBJ_MAYBE_GENERIC) ;;
495       hp300)    AC_DEFINE(OBJ_MAYBE_HP300)   ;;
496       ieee)     AC_DEFINE(OBJ_MAYBE_IEEE)    ;;
497       som)      AC_DEFINE(OBJ_MAYBE_SOM)     ;;
498       vms)      AC_DEFINE(OBJ_MAYBE_VMS)     ;;
499     esac
500     extra_objects="$extra_objects obj-$fmt.o"
501   done
502   obj_format=multi
503 fi
504 if test `set . $emfiles ; shift ; echo $#` -gt 0 ; then
505   te_file=multi
506   extra_objects="$extra_objects $emfiles"
507   DEFAULT_EMULATION=`set . $emulations ; echo $2`
508   AC_DEFINE(USE_EMULATIONS)
509 fi
510 AC_SUBST(extra_objects)
511 AC_DEFINE_UNQUOTED(EMULATIONS, $EMULATIONS)
512 AC_DEFINE_UNQUOTED(DEFAULT_EMULATION, "$DEFAULT_EMULATION")
513
514 files="config/tc-${target_cpu_type}.c config/tc-${target_cpu_type}.h \
515         config/obj-${obj_format}.h config/obj-${obj_format}.c \
516         config/te-${te_file}.h config/atof-${atof}.c \
517         $extra_files"
518 links="targ-cpu.c targ-cpu.h obj-format.h obj-format.c targ-env.h atof-targ.c \
519         $extra_links"
520
521 case ${primary_bfd_gas}-${target_cpu_type}-${obj_format} in
522   yes-*-coff)   need_bfd=yes ;;
523   no-*-coff)    need_bfd=yes
524                 AC_DEFINE(MANY_SEGMENTS) ;;
525 esac
526
527 reject_dev_configs=yes
528
529 case ${reject_dev_configs}-${dev} in
530   yes-yes) # Oops.
531     AC_MSG_ERROR(GAS does not support the ${generic_target} configuration.)
532     ;;
533 esac
534
535 AC_SUBST(target_cpu_type)
536 AC_SUBST(obj_format)
537 AC_SUBST(atof)
538 dnl AC_SUBST(emulation)
539
540 AC_LINK_FILES($files, $links)
541
542 case "${primary_bfd_gas}" in
543   yes)  AC_DEFINE(BFD_ASSEMBLER)
544         need_bfd=yes ;;
545 esac
546
547 case "${need_bfd}" in
548   yes)  BFDDEP=../bfd/libbfd.a
549         BFDLIB='-L../bfd -lbfd'
550         ALL_OBJ_DEPS="$ALL_OBJ_DEPS ../bfd/bfd.h"
551
552         # We need to handle some special cases if BFD was built shared.
553         if test "${shared}" = "true"; then
554           case "${host}" in
555           *-*-sunos*)
556           # On SunOS, we must link against the name we are going to install,
557           # not -lbfd, since SunOS does not support SONAME.
558           BFDLIB='-L../bfd -l`echo bfd | sed '"'"'$(program_transform_name)'"'"'`'
559           ;;
560           esac
561         fi
562         ;;
563 esac
564 AC_SUBST(BFDDEP)
565 AC_SUBST(BFDLIB)
566 AC_SUBST(ALL_OBJ_DEPS)
567
568 AC_DEFINE_UNQUOTED(TARGET_ALIAS,        "${target_alias}")
569 AC_DEFINE_UNQUOTED(TARGET_CANONICAL,    "${target}")
570 AC_DEFINE_UNQUOTED(TARGET_CPU,          "${target_cpu}")
571 AC_DEFINE_UNQUOTED(TARGET_VENDOR,       "${target_vendor}")
572 AC_DEFINE_UNQUOTED(TARGET_OS,           "${target_os}")
573
574 AC_PROG_CC
575 AC_PROG_INSTALL
576
577 AC_CHECK_HEADERS(string.h stdlib.h memory.h strings.h unistd.h stdarg.h varargs.h errno.h sys/types.h)
578
579 # Put this here so that autoconf's "cross-compiling" message doesn't confuse
580 # people who are not cross-compiling but are compiling cross-assemblers.
581 AC_MSG_CHECKING(whether compiling a cross-assembler)
582 if test "${host}" = "${target}"; then
583   cross_gas=no
584 else
585   cross_gas=yes
586   AC_DEFINE(CROSS_COMPILE)
587 fi
588 AC_MSG_RESULT($cross_gas)
589
590 dnl ansidecl.h will deal with const
591 dnl AC_CONST
592 AC_FUNC_ALLOCA
593 AC_C_INLINE
594
595 # VMS doesn't have unlink.
596 AC_CHECK_FUNCS(unlink remove, break)
597
598 # Some systems don't have sbrk().
599 AC_CHECK_FUNCS(sbrk)
600
601 # Some non-ANSI preprocessors botch requoting inside strings.  That's bad
602 # enough, but on some of those systems, the assert macro relies on requoting
603 # working properly!
604 GAS_WORKING_ASSERT
605
606 # On some systems, the system header files may not declare malloc, realloc,
607 # and free.  There are places where gas needs these functions to have been
608 # declared -- such as when taking their addresses.
609 gas_test_headers="
610 #ifdef HAVE_MEMORY_H
611 #include <memory.h>
612 #endif
613 #ifdef HAVE_STRING_H
614 #include <string.h>
615 #endif
616 #ifdef HAVE_STDLIB_H
617 #include <stdlib.h>
618 #endif
619 #ifdef HAVE_UNISTD_H
620 #include <unistd.h>
621 #endif
622 "
623 GAS_CHECK_DECL_NEEDED(malloc, f, char *(*f)(), $gas_test_headers)
624 GAS_CHECK_DECL_NEEDED(free, f, void (*f)(), $gas_test_headers)
625
626 # Does errno.h declare errno, or do we have to add a separate declaration
627 # for it?
628 GAS_CHECK_DECL_NEEDED(errno, f, int f, [
629 #ifdef HAVE_ERRNO_H
630 #include <errno.h>
631 #endif
632 ])
633
634 HLDFLAGS=
635 # If we have shared libraries, try to set rpath reasonably.
636 if test "${shared}" = "true"; then
637   case "${host}" in
638   *-*-irix5*)
639     HLDFLAGS='-Wl,-rpath,$(libdir)'
640     ;;
641   *-*-linux*aout*)
642     ;;
643   *-*-linux*)
644     HLDFLAGS='-Wl,-rpath,$(libdir)'
645     ;;
646   *-*-sysv4* | *-*-solaris*)
647     HLDFLAGS='-R $(libdir)'
648     ;;
649   esac
650 fi
651
652 # On SunOS, if the linker supports the -rpath option, use it to
653 # prevent ../bfd and ../opcodes from being included in the run time
654 # search path.
655 case "${host}" in
656   *-*-sunos*)
657     echo 'main () { }' > conftest.c
658     ${CC} -o conftest -Wl,-rpath= conftest.c >/dev/null 2>conftest.t
659     if grep 'unrecognized' conftest.t >/dev/null 2>&1; then
660       :
661     elif grep 'No such file' conftest.t >/dev/null 2>&1; then
662       :
663     elif test "${shared}" = "true"; then
664       HLDFLAGS='-Wl,-rpath=$(libdir)'
665     else
666       HLDFLAGS='-Wl,-rpath='
667     fi
668     rm -f conftest.t conftest.c conftest
669     ;;
670 esac
671 AC_SUBST(HLDFLAGS)
672
673 dnl This must come last.
674 AC_OUTPUT(Makefile doc/Makefile .gdbinit:gdbinit.in)