Follow-up fixup to c5d8162d230c373
[ghc.git] / aclocal.m4
1 # Extra autoconf macros for the Glasgow fptools
2 #
3 # To be a good autoconf citizen, names of local macros have prefixed with FP_ to
4 # ensure we don't clash with any pre-supplied autoconf ones.
5
6
7 AC_DEFUN([GHC_SELECT_FILE_EXTENSIONS],
8 [
9     $2=''
10     $3='.so'
11     case $1 in
12     *-unknown-cygwin32)
13         AC_MSG_WARN([GHC does not support the Cygwin target at the moment])
14         AC_MSG_WARN([I'm assuming you wanted to build for i386-unknown-mingw32])
15         exit 1
16         ;;
17     *-unknown-mingw32)
18         windows=YES
19         $2='.exe'
20         $3='.dll'
21         ;;
22     i386-apple-darwin|powerpc-apple-darwin)
23         $3='.dylib'
24         ;;
25     x86_64-apple-darwin)
26         $3='.dylib'
27         ;;
28     arm-apple-darwin10|i386-apple-darwin11|aarch64-apple-darwin14)
29         $2='.a'
30         $3='.dylib'
31         ;;
32     esac
33 ])
34
35 # FPTOOLS_SET_PLATFORM_VARS
36 # ----------------------------------
37 # Set the platform variables
38 AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
39 [
40     # If no argument was given for a configuration variable, then discard
41     # the guessed canonical system and use the configuration of the
42     # bootstrapping ghc. If an argument was given, map it from gnu format
43     # to ghc format.
44     #
45     # For why we do it this way, see: #3637, #1717, #2951
46     #
47     # In bindists, we haven't called AC_CANONICAL_{BUILD,HOST,TARGET}
48     # so this justs uses $bootstrap_target.
49
50     if test "$build_alias" = ""
51     then
52         if test "$bootstrap_target" != ""
53         then
54             build=$bootstrap_target
55             echo "Build platform inferred as: $build"
56         else
57             echo "Can't work out build platform"
58             exit 1
59         fi
60
61         BuildArch=`echo "$build" | sed 's/-.*//'`
62         BuildVendor=`echo "$build" | sed -e 's/.*-\(.*\)-.*/\1/'`
63         BuildOS=`echo "$build" | sed 's/.*-//'`
64     else
65         GHC_CONVERT_CPU([$build_cpu], [BuildArch])
66         GHC_CONVERT_VENDOR([$build_vendor], [BuildVendor])
67         GHC_CONVERT_OS([$build_os], [$BuildArch], [BuildOS])
68     fi
69
70     if test "$host_alias" = ""
71     then
72         if test "$bootstrap_target" != ""
73         then
74             host=$bootstrap_target
75             echo "Host platform inferred as: $host"
76         else
77             echo "Can't work out host platform"
78             exit 1
79         fi
80
81         HostArch=`echo "$host" | sed 's/-.*//'`
82         HostVendor=`echo "$host" | sed -e 's/.*-\(.*\)-.*/\1/'`
83         HostOS=`echo "$host" | sed 's/.*-//'`
84     else
85         GHC_CONVERT_CPU([$host_cpu], [HostArch])
86         GHC_CONVERT_VENDOR([$host_vendor], [HostVendor])
87         GHC_CONVERT_OS([$host_os], [$HostArch], [HostOS])
88     fi
89
90     if test "$target_alias" = ""
91     then
92         if test "$host_alias" != ""
93         then
94             GHC_CONVERT_CPU([$host_cpu], [TargetArch])
95             GHC_CONVERT_VENDOR([$host_vendor], [TargetVendor])
96             GHC_CONVERT_OS([$host_os], [$TargetArch],[TargetOS])
97         else
98             if test "$bootstrap_target" != ""
99             then
100                 target=$bootstrap_target
101                 echo "Target platform inferred as: $target"
102             else
103                 echo "Can't work out target platform"
104                 exit 1
105             fi
106
107             TargetArch=`echo "$target" | sed 's/-.*//'`
108             TargetVendor=`echo "$target" | sed -e 's/.*-\(.*\)-.*/\1/'`
109             TargetOS=`echo "$target" | sed 's/.*-//'`
110         fi
111     else
112         GHC_CONVERT_CPU([$target_cpu], [TargetArch])
113         GHC_CONVERT_VENDOR([$target_vendor], [TargetVendor])
114         GHC_CONVERT_OS([$target_os], [$TargetArch], [TargetOS])
115     fi
116
117     GHC_SELECT_FILE_EXTENSIONS([$host], [exeext_host], [soext_host])
118     GHC_SELECT_FILE_EXTENSIONS([$target], [exeext_target], [soext_target])
119     windows=NO
120     case $host in
121     *-unknown-mingw32)
122         windows=YES
123         ;;
124     esac
125
126     BuildPlatform="$BuildArch-$BuildVendor-$BuildOS"
127     BuildPlatform_CPP=`echo "$BuildPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
128     BuildArch_CPP=`    echo "$BuildArch"     | sed -e 's/\./_/g' -e 's/-/_/g'`
129     BuildVendor_CPP=`  echo "$BuildVendor"   | sed -e 's/\./_/g' -e 's/-/_/g'`
130     BuildOS_CPP=`      echo "$BuildOS"       | sed -e 's/\./_/g' -e 's/-/_/g'`
131
132     HostPlatform="$HostArch-$HostVendor-$HostOS"
133     HostPlatform_CPP=`echo "$HostPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
134     HostArch_CPP=`    echo "$HostArch"     | sed -e 's/\./_/g' -e 's/-/_/g'`
135     HostVendor_CPP=`  echo "$HostVendor"   | sed -e 's/\./_/g' -e 's/-/_/g'`
136     HostOS_CPP=`      echo "$HostOS"       | sed -e 's/\./_/g' -e 's/-/_/g'`
137
138     TargetPlatform="$TargetArch-$TargetVendor-$TargetOS"
139     TargetPlatform_CPP=`echo "$TargetPlatform" | sed -e 's/\./_/g' -e 's/-/_/g'`
140     TargetArch_CPP=`    echo "$TargetArch"     | sed -e 's/\./_/g' -e 's/-/_/g'`
141     TargetVendor_CPP=`  echo "$TargetVendor"   | sed -e 's/\./_/g' -e 's/-/_/g'`
142     TargetOS_CPP=`      echo "$TargetOS"       | sed -e 's/\./_/g' -e 's/-/_/g'`
143
144     echo "GHC build  : $BuildPlatform"
145     echo "GHC host   : $HostPlatform"
146     echo "GHC target : $TargetPlatform"
147
148     AC_SUBST(BuildPlatform)
149     AC_SUBST(HostPlatform)
150     AC_SUBST(TargetPlatform)
151     AC_SUBST(HostPlatform_CPP)
152     AC_SUBST(BuildPlatform_CPP)
153     AC_SUBST(TargetPlatform_CPP)
154
155     AC_SUBST(HostArch_CPP)
156     AC_SUBST(BuildArch_CPP)
157     AC_SUBST(TargetArch_CPP)
158
159     AC_SUBST(HostOS_CPP)
160     AC_SUBST(BuildOS_CPP)
161     AC_SUBST(TargetOS_CPP)
162
163     AC_SUBST(HostVendor_CPP)
164     AC_SUBST(BuildVendor_CPP)
165     AC_SUBST(TargetVendor_CPP)
166
167     AC_SUBST(exeext_host)
168     AC_SUBST(exeext_target)
169     AC_SUBST(soext_host)
170     AC_SUBST(soext_target)
171 ])
172
173
174 # FPTOOLS_SET_HASKELL_PLATFORM_VARS
175 # ----------------------------------
176 # Set the Haskell platform variables
177 AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
178 [
179     checkArch() {
180         case [$]1 in
181         i386)
182             test -z "[$]2" || eval "[$]2=ArchX86"
183             ;;
184         x86_64|amd64)
185             test -z "[$]2" || eval "[$]2=ArchX86_64"
186             ;;
187         powerpc)
188             test -z "[$]2" || eval "[$]2=ArchPPC"
189             ;;
190         powerpc64)
191             test -z "[$]2" || eval "[$]2=\"ArchPPC_64 {ppc_64ABI = ELF_V1}\""
192             ;;
193         powerpc64le)
194             test -z "[$]2" || eval "[$]2=\"ArchPPC_64 {ppc_64ABI = ELF_V2}\""
195             ;;
196         sparc)
197             test -z "[$]2" || eval "[$]2=ArchSPARC"
198             ;;
199         arm)
200             GET_ARM_ISA()
201             test -z "[$]2" || eval "[$]2=\"ArchARM {armISA = \$ARM_ISA, armISAExt = \$ARM_ISA_EXT, armABI = \$ARM_ABI}\""
202             ;;
203         aarch64)
204             test -z "[$]2" || eval "[$]2=ArchARM64"
205             ;;
206         alpha)
207             test -z "[$]2" || eval "[$]2=ArchAlpha"
208             ;;
209         mips|mipseb)
210             test -z "[$]2" || eval "[$]2=ArchMipseb"
211             ;;
212         mipsel)
213             test -z "[$]2" || eval "[$]2=ArchMipsel"
214             ;;
215         hppa|hppa1_1|ia64|m68k|rs6000|s390|s390x|sparc64|vax)
216             test -z "[$]2" || eval "[$]2=ArchUnknown"
217             ;;
218         *)
219             echo "Unknown arch [$]1"
220             exit 1
221             ;;
222         esac
223     }
224
225     checkVendor() {
226         case [$]1 in
227         dec|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld)
228             ;;
229         *)
230             echo "Unknown vendor [$]1"
231             exit 1
232             ;;
233         esac
234     }
235
236     checkOS() {
237         case [$]1 in
238         linux)
239             test -z "[$]2" || eval "[$]2=OSLinux"
240             ;;
241         ios)
242             test -z "[$]2" || eval "[$]2=OSiOS"
243             ;;
244         darwin)
245             test -z "[$]2" || eval "[$]2=OSDarwin"
246             ;;
247         solaris2)
248             test -z "[$]2" || eval "[$]2=OSSolaris2"
249             ;;
250         mingw32)
251             test -z "[$]2" || eval "[$]2=OSMinGW32"
252             ;;
253         freebsd)
254             test -z "[$]2" || eval "[$]2=OSFreeBSD"
255             ;;
256         dragonfly)
257             test -z "[$]2" || eval "[$]2=OSDragonFly"
258             ;;
259         kfreebsdgnu)
260             test -z "[$]2" || eval "[$]2=OSKFreeBSD"
261             ;;
262         openbsd)
263             test -z "[$]2" || eval "[$]2=OSOpenBSD"
264             ;;
265         netbsd)
266             test -z "[$]2" || eval "[$]2=OSNetBSD"
267             ;;
268         haiku)
269             test -z "[$]2" || eval "[$]2=OSHaiku"
270             ;;
271         osf3)
272             test -z "[$]2" || eval "[$]2=OSOsf3"
273             ;;
274         nto-qnx)
275             test -z "[$]2" || eval "[$]2=OSQNXNTO"
276             ;;
277         dragonfly|osf1|hpux|linuxaout|freebsd2|gnu|nextstep2|nextstep3|sunos4|ultrix|irix)
278             test -z "[$]2" || eval "[$]2=OSUnknown"
279             ;;
280         aix)
281             test -z "[$]2" || eval "[$]2=OSAIX"
282             ;;
283         linux-android)
284             test -z "[$]2" || eval "[$]2=OSAndroid"
285             ;;
286         *)
287             echo "Unknown OS '[$]1'"
288             exit 1
289             ;;
290         esac
291     }
292
293     dnl ** check for Apple-style dead-stripping support
294     dnl    (.subsections-via-symbols assembler directive)
295
296     AC_MSG_CHECKING(for .subsections_via_symbols)
297     AC_COMPILE_IFELSE(
298         [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
299         [AC_MSG_RESULT(yes)
300          HaskellHaveSubsectionsViaSymbols=True
301          AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
302                    [Define to 1 if Apple-style dead-stripping is supported.])
303         ],
304         [HaskellHaveSubsectionsViaSymbols=False
305          AC_MSG_RESULT(no)])
306
307     dnl ** check for .ident assembler directive
308
309     AC_MSG_CHECKING(whether your assembler supports .ident directive)
310     AC_COMPILE_IFELSE(
311         [AC_LANG_SOURCE([__asm__ (".ident \"GHC x.y.z\"");])],
312         [AC_MSG_RESULT(yes)
313          HaskellHaveIdentDirective=True],
314         [AC_MSG_RESULT(no)
315          HaskellHaveIdentDirective=False])
316
317     dnl *** check for GNU non-executable stack note support (ELF only)
318     dnl     (.section .note.GNU-stack,"",@progbits)
319
320     dnl This test doesn't work with "gcc -g" in gcc 4.4 (GHC trac #3889:
321     dnl     Error: can't resolve `.note.GNU-stack' {.note.GNU-stack section} - `.Ltext0' {.text section}
322     dnl so we empty CFLAGS while running this test
323     CFLAGS2="$CFLAGS"
324     CFLAGS=
325     AC_MSG_CHECKING(for GNU non-executable stack support)
326     AC_COMPILE_IFELSE(
327         [AC_LANG_PROGRAM([__asm__ (".section .note.GNU-stack,\"\",@progbits");], [0])],
328         [AC_MSG_RESULT(yes)
329          HaskellHaveGnuNonexecStack=True],
330         [AC_MSG_RESULT(no)
331          HaskellHaveGnuNonexecStack=False])
332     CFLAGS="$CFLAGS2"
333
334     checkArch "$BuildArch" "HaskellBuildArch"
335     checkVendor "$BuildVendor"
336     checkOS "$BuildOS" ""
337
338     checkArch "$HostArch" "HaskellHostArch"
339     checkVendor "$HostVendor"
340     checkOS "$HostOS" ""
341
342     checkArch "$TargetArch" "HaskellTargetArch"
343     checkVendor "$TargetVendor"
344     checkOS "$TargetOS" "HaskellTargetOs"
345
346     AC_SUBST(HaskellTargetArch)
347     AC_SUBST(HaskellTargetOs)
348     AC_SUBST(HaskellHaveSubsectionsViaSymbols)
349     AC_SUBST(HaskellHaveIdentDirective)
350     AC_SUBST(HaskellHaveGnuNonexecStack)
351 ])
352
353
354 # GET_ARM_ISA
355 # ----------------------------------
356 # Get info about the ISA on the ARM arch
357 AC_DEFUN([GET_ARM_ISA],
358 [
359     AC_COMPILE_IFELSE([
360         AC_LANG_PROGRAM(
361             [],
362             [#if defined(__ARM_ARCH_2__)  || \
363                  defined(__ARM_ARCH_3__)  || \
364                  defined(__ARM_ARCH_3M__) || \
365                  defined(__ARM_ARCH_4__)  || \
366                  defined(__ARM_ARCH_4T__) || \
367                  defined(__ARM_ARCH_5__)  || \
368                  defined(__ARM_ARCH_5T__) || \
369                  defined(__ARM_ARCH_5E__) || \
370                  defined(__ARM_ARCH_5TE__)
371                  return 0;
372              #else
373                  not pre arm v6
374              #endif]
375         )],
376         [AC_DEFINE(arm_HOST_ARCH_PRE_ARMv6, 1, [ARM pre v6])
377          AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
378          changequote(, )dnl
379          ARM_ISA=ARMv5
380          ARM_ISA_EXT="[]"
381          changequote([, ])dnl
382         ],
383         [
384             AC_COMPILE_IFELSE([
385                 AC_LANG_PROGRAM(
386                     [],
387                     [#if defined(__ARM_ARCH_6__)   || \
388                          defined(__ARM_ARCH_6J__)  || \
389                          defined(__ARM_ARCH_6T2__) || \
390                          defined(__ARM_ARCH_6Z__)  || \
391                          defined(__ARM_ARCH_6ZK__) || \
392                          defined(__ARM_ARCH_6M__)
393                          return 0;
394                      #else
395                          not pre arm v7
396                      #endif]
397                 )],
398                 [AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
399                  ARM_ISA=ARMv6
400                  AC_COMPILE_IFELSE([
401                         AC_LANG_PROGRAM(
402                                 [],
403                                 [#if defined(__VFP_FP__)
404                                      return 0;
405                                 #else
406                                      no vfp
407                                 #endif]
408                         )],
409                         [changequote(, )dnl
410                          ARM_ISA_EXT="[VFPv2]"
411                          changequote([, ])dnl
412                         ],
413                         [changequote(, )dnl
414                          ARM_ISA_EXT="[]"
415                          changequote([, ])dnl
416                         ]
417                 )],
418                 [changequote(, )dnl
419                  ARM_ISA=ARMv7
420                  ARM_ISA_EXT="[VFPv3,NEON]"
421                  changequote([, ])dnl
422                 ])
423         ])
424
425         AC_COMPILE_IFELSE(
426                [AC_LANG_PROGRAM(
427                        [],
428                        [#if defined(__SOFTFP__)
429                             return 0;
430                        #else
431                             not softfp
432                        #endif]
433                )],
434                [changequote(, )dnl
435                 ARM_ABI="SOFT"
436                 changequote([, ])dnl
437                ],
438                [AC_COMPILE_IFELSE(
439                     [AC_LANG_PROGRAM(
440                        [],
441                        [#if defined(__ARM_PCS_VFP)
442                             return 0;
443                        #else
444                             no hard float ABI
445                        #endif]
446                     )],
447                     [ARM_ABI="HARD"],
448                     [ARM_ABI="SOFTFP"]
449                )]
450         )
451 ])
452
453
454 # FP_SETTINGS
455 # ----------------------------------
456 # Set the variables used in the settings file
457 AC_DEFUN([FP_SETTINGS],
458 [
459     if test "$windows" = YES
460     then
461         mingw_bin_prefix=mingw/bin/
462         SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
463         SettingsHaskellCPPCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
464         SettingsHaskellCPPFlags="$HaskellCPPArgs"
465         SettingsLdCommand="\$topdir/../${mingw_bin_prefix}ld.exe"
466         SettingsArCommand="\$topdir/../${mingw_bin_prefix}ar.exe"
467         SettingsPerlCommand='$topdir/../perl/perl.exe'
468         SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe"
469         SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
470         SettingsTouchCommand='$topdir/touchy.exe'
471     else
472         SettingsCCompilerCommand="$WhatGccIsCalled"
473         SettingsHaskellCPPCommand="$HaskellCPPCmd"
474         SettingsHaskellCPPFlags="$HaskellCPPArgs"
475         SettingsLdCommand="$LdCmd"
476         SettingsArCommand="$ArCmd"
477         SettingsPerlCommand="$PerlCmd"
478         SettingsDllWrapCommand="/bin/false"
479         SettingsWindresCommand="/bin/false"
480         SettingsLibtoolCommand="libtool"
481         SettingsTouchCommand='touch'
482     fi
483     if test -z "$LlcCmd"
484     then
485       SettingsLlcCommand="llc"
486     else
487       SettingsLlcCommand="$LlcCmd"
488     fi
489     if test -z "$OptCmd"
490     then
491       SettingsOptCommand="opt"
492     else
493       SettingsOptCommand="$OptCmd"
494     fi
495     SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
496     SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
497     SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
498     AC_SUBST(SettingsCCompilerCommand)
499     AC_SUBST(SettingsHaskellCPPCommand)
500     AC_SUBST(SettingsHaskellCPPFlags)
501     AC_SUBST(SettingsCCompilerFlags)
502     AC_SUBST(SettingsCCompilerLinkFlags)
503     AC_SUBST(SettingsLdCommand)
504     AC_SUBST(SettingsLdFlags)
505     AC_SUBST(SettingsArCommand)
506     AC_SUBST(SettingsPerlCommand)
507     AC_SUBST(SettingsDllWrapCommand)
508     AC_SUBST(SettingsWindresCommand)
509     AC_SUBST(SettingsLibtoolCommand)
510     AC_SUBST(SettingsTouchCommand)
511     AC_SUBST(SettingsLlcCommand)
512     AC_SUBST(SettingsOptCommand)
513 ])
514
515
516 # FPTOOLS_SET_C_LD_FLAGS
517 # ----------------------------------
518 # Set the C, LD and CPP flags for a given platform
519 # $1 is the platform
520 # $2 is the name of the CC flags variable
521 # $3 is the name of the linker flags variable when linking with gcc
522 # $4 is the name of the linker flags variable when linking with ld
523 # $5 is the name of the CPP flags variable
524 AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
525 [
526     AC_MSG_CHECKING([Setting up $2, $3, $4 and $5])
527     case $$1 in
528     i386-*)
529         # Workaround for #7799
530         $2="$$2 -U__i686"
531         ;;
532     esac
533
534     case $$1 in
535     i386-unknown-mingw32)
536         $2="$$2 -march=i686"
537         ;;
538     i386-portbld-freebsd*)
539         $2="$$2 -march=i686"
540         ;;
541     i386-apple-darwin)
542         $2="$$2 -m32"
543         $3="$$3 -m32"
544         $4="$$4 -arch i386"
545         $5="$$5 -m32"
546         ;;
547     x86_64-apple-darwin)
548         $2="$$2 -m64"
549         $3="$$3 -m64"
550         $4="$$4 -arch x86_64"
551         $5="$$5 -m64"
552         ;;
553     x86_64-unknown-solaris2)
554         $2="$$2 -m64"
555         $3="$$3 -m64"
556         $4="$$4 -m64"
557         $5="$$5 -m64"
558         ;;
559     alpha-*)
560         # For now, to suppress the gcc warning "call-clobbered
561         # register used for global register variable", we simply
562         # disable all warnings altogether using the -w flag. Oh well.
563         $2="$$2 -w -mieee -D_REENTRANT"
564         $3="$$3 -w -mieee -D_REENTRANT"
565         $5="$$5 -w -mieee -D_REENTRANT"
566         ;;
567     hppa*)
568         # ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi!
569         # (very nice, but too bad the HP /usr/include files don't agree.)
570         $2="$$2 -D_HPUX_SOURCE"
571         $3="$$3 -D_HPUX_SOURCE"
572         $5="$$5 -D_HPUX_SOURCE"
573         ;;
574     arm*linux*)
575         # On arm/linux and arm/android, tell gcc to generate Arm
576         # instructions (ie not Thumb) and to link using the gold linker.
577         # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
578         $2="$$2 -marm"
579         $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
580         $4="$$4 -z noexecstack"
581         ;;
582
583     aarch64*linux*)
584         # On aarch64/linux and aarch64/android, tell gcc to link using the
585         # gold linker.
586         # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
587         $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
588         $4="$$4 -z noexecstack"
589         ;;
590
591     powerpc-ibm-aix*)
592         # On IBM AIX, we need to workaround XCOFF's limitations. Specifically,
593         # there's a TOC which only supports at most 16k entries (see
594         # http://www.ibm.com/developerworks/rational/library/overview-toc-aix/
595         # for more details), and by using `-mminimal-toc` we use up only one TOC
596         # entry per translation unit, at the cost of an additional pointer
597         # indirection. However, see note in `compiler/ghc.mk` about `Parser.hs`.
598         # Finally, we need `-D_THREAD_SAFE` to unlock a thread-local `errno`.
599         $2="$$2 -mminimal-toc -D_THREAD_SAFE"
600         $3="$$3 -mminimal-toc -D_THREAD_SAFE"
601         $5="$$5 -D_THREAD_SAFE"
602         ;;
603
604     esac
605
606     # If gcc knows about the stack protector, turn it off.
607     # Otherwise the stack-smash handler gets triggered.
608     echo 'int main(void) {return 0;}' > conftest.c
609     if $CC -c conftest.c -fno-stack-protector > /dev/null 2>&1
610     then
611         $2="$$2 -fno-stack-protector"
612     fi
613
614     rm -f conftest.c conftest.o
615     AC_MSG_RESULT([done])
616 ])
617
618
619 # FP_VISIBILITY_HIDDEN
620 # ----------------------------------
621 # Is the visibility hidden attribute supported?
622 AC_DEFUN([FP_VISIBILITY_HIDDEN],
623 [
624     AC_MSG_CHECKING([whether __attribute__((visibility("hidden"))) is supported])
625     echo '__attribute__((visibility("hidden"))) void foo(void) {}' > conftest.c
626     if $CC -Wall -Werror -c conftest.c > /dev/null 2>&1
627     then
628         AC_MSG_RESULT([yes])
629         AC_DEFINE(HAS_VISIBILITY_HIDDEN, 1, [Has visibility hidden])
630     else
631         AC_MSG_RESULT([no])
632     fi
633     rm -f conftest.c conftest.o
634 ])
635
636
637 # FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
638 # ----------------------------------
639 # Little endian ARM on Linux with some ABIs has big endian word order
640 # in doubles. Define FLOAT_WORDS_BIGENDIAN if this is the case.
641 AC_DEFUN([FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN],
642   [AC_CACHE_CHECK([whether float word order is big endian], [fptools_cv_float_word_order_bigendian],
643     [AC_COMPILE_IFELSE(
644       [AC_LANG_PROGRAM(
645         [#include <endian.h>],
646         [#if defined(__FLOAT_WORD_ORDER) && __FLOAT_WORD_ORDER == BIG_ENDIAN
647              return 0;
648          #else
649              not float word order big endian
650          #endif]
651       )],
652       [fptools_cv_float_word_order_bigendian=yes],
653       [fptools_cv_float_word_order_bigendian=no])
654     ])
655   case $fptools_cv_float_word_order_bigendian in
656       yes)
657           AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
658           [Define to 1 if your processor stores words of floats with
659            the most significant byte first]) ;;
660   esac
661 ])
662
663
664 # FP_ARG_WITH_PATH_GNU_PROG_GENERAL
665 # --------------------
666 # Find the specified command on the path or allow a user to set it manually
667 # with a --with-<command> option.
668 #
669 # This is ignored on the mingw32 platform.
670 #
671 # $1 = the variable to set
672 # $2 = the with option name
673 # $3 = the command to look for
674 # $4 = prepend target to program name? if 'no', use the name unchanged
675 # $5 = optional? if 'no', then raise an error if the command isn't found
676 #
677 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG_GENERAL],
678 [
679 AC_ARG_WITH($2,
680 [AC_HELP_STRING([--with-$2=ARG],
681         [Use ARG as the path to $2 [default=autodetect]])],
682 [
683     if test "$HostOS" = "mingw32"
684     then
685         AC_MSG_WARN([Request to use $withval will be ignored])
686     else
687         $1=$withval
688     fi
689
690     # Remember that we set this manually.  Used to override CC_STAGE0
691     # and friends later, if we are not cross-compiling.
692     With_$2=$withval
693 ],
694 [
695     if test "$HostOS" != "mingw32"
696     then
697         if test "$4" = "no" -o "$target_alias" = "" ; then
698             AC_PATH_PROG([$1], [$3])
699         else
700             AC_PATH_PROG([$1], [$target_alias-$3])
701         fi
702         if test "$5" = "no" -a -z "$$1"
703         then
704             AC_MSG_ERROR([cannot find $3 in your PATH])
705         fi
706     fi
707 ]
708 )
709 ]) # FP_ARG_WITH_PATH_GNU_PROG_GENERAL
710
711
712 # FP_ARG_WITH_PATH_GNU_PROG
713 # --------------------
714 # The usual case: prepend the target, and the program is not optional.
715 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG],
716 [FP_ARG_WITH_PATH_GNU_PROG_GENERAL([$1], [$2], [$3], [yes], [no])])
717
718 # FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL
719 # --------------------
720 # Same as FP_ARG_WITH_PATH_GNU_PROG but no error will be thrown if the command
721 # isn't found.
722 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL],
723 [FP_ARG_WITH_PATH_GNU_PROG_GENERAL([$1], [$2], [$3], [yes], [yes])])
724
725 # FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET
726 # --------------------
727 # Same as FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL but don't prepend the target name
728 # (used for LLVM).
729 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET],
730 [FP_ARG_WITH_PATH_GNU_PROG_GENERAL([$1], [$2], [$3], [no], [yes])])
731
732
733 # FP_PROG_CONTEXT_DIFF
734 # --------------------
735 # Figure out how to do context diffs. Sets the output variable ContextDiffCmd.
736 #
737 # Note: NeXTStep thinks diff'ing a file against itself is "trouble".
738 AC_DEFUN([FP_PROG_CONTEXT_DIFF],
739 [AC_CACHE_CHECK([for a working context diff], [fp_cv_context_diff],
740 [echo foo > conftest1
741 echo foo > conftest2
742 fp_cv_context_diff=no
743 for fp_var in '-U 1' '-u1' '-C 1' '-c1'
744 do
745   if diff $fp_var conftest1 conftest2 > /dev/null 2>&1; then
746     fp_cv_context_diff="diff $fp_var"
747     break
748   fi
749 done])
750 if test x"$fp_cv_context_diff" = xno; then
751    AC_MSG_ERROR([cannot figure out how to do context diffs])
752 fi
753 AC_SUBST(ContextDiffCmd, [$fp_cv_context_diff])
754 ])# FP_PROG_CONTEXT_DIFF
755
756
757 # FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
758 # --------------------------------------------------------
759 # Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for
760 # compilation. Execute IF-FAILS when unable to determine the value. Works for
761 # cross-compilation, too.
762 #
763 # Implementation note: We are lazy and use an internal autoconf macro, but it
764 # is supported in autoconf versions 2.50 up to the actual 2.57, so there is
765 # little risk.
766 AC_DEFUN([FP_COMPUTE_INT],
767 [_AC_COMPUTE_INT([$1], [$2], [$3], [$4])[]dnl
768 ])# FP_COMPUTE_INT
769
770
771 # FP_CHECK_ALIGNMENT(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
772 # ------------------------------------------------------------------
773 # A variation of AC_CHECK_SIZEOF for computing the alignment restrictions of a
774 # given type. Defines ALIGNMENT_TYPE.
775 AC_DEFUN([FP_CHECK_ALIGNMENT],
776 [AS_LITERAL_IF(m4_translit([[$1]], [*], [p]), [],
777                [AC_FATAL([$0: requires literal arguments])])[]dnl
778 AC_CHECK_TYPE([$1], [], [], [$3])[]dnl
779 m4_pushdef([fp_Cache], [AS_TR_SH([fp_cv_alignment_$1])])[]dnl
780 AC_CACHE_CHECK([alignment of $1], [fp_Cache],
781 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
782   FP_COMPUTE_INT([offsetof(struct { char c; $1 ty; },ty)],
783                  [fp_Cache],
784                  [AC_INCLUDES_DEFAULT([$3])],
785                  [AC_MSG_ERROR([cannot compute alignment ($1)
786 See `config.log' for more details.], [77])])
787 else
788   fp_Cache=0
789 fi])[]dnl
790 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignment_$1), $fp_Cache, [The alignment of a `$1'.])[]dnl
791 m4_popdef([fp_Cache])[]dnl
792 ])# FP_CHECK_ALIGNMENT
793
794
795 # FP_LEADING_UNDERSCORE
796 # ---------------------
797 # Test for determining whether symbol names have a leading underscore. We assume
798 # that they _haven't_ if anything goes wrong. Sets the output variable
799 # LeadingUnderscore to YES or NO and defines LEADING_UNDERSCORE correspondingly.
800 #
801 # Some nlist implementations seem to try to be compatible by ignoring a leading
802 # underscore sometimes (eg. FreeBSD). We therefore have to work around this by
803 # checking for *no* leading underscore first. Sigh.  --SDM
804 #
805 # Similarly on OpenBSD, but this test doesn't help. -- dons
806 AC_DEFUN([FP_LEADING_UNDERSCORE],
807 [AC_CHECK_LIB([elf], [nlist], [LIBS="-lelf $LIBS"])
808 AC_CACHE_CHECK([leading underscore in symbol names], [fptools_cv_leading_underscore], [
809 # Hack!: nlist() under Digital UNIX insist on there being an _,
810 # but symbol table listings shows none. What is going on here?!?
811 case $HostPlatform in
812 *openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore
813   case $build in
814     i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;;
815     *) fptools_cv_leading_underscore=no ;;
816   esac ;;
817 alpha-dec-osf*) fptools_cv_leading_underscore=no;;
818 i386-unknown-mingw32) fptools_cv_leading_underscore=yes;;
819 x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;;
820
821     # HACK: Apple doesn't seem to provide nlist in the 64-bit-libraries
822 x86_64-apple-darwin*) fptools_cv_leading_underscore=yes;;
823 *-apple-ios) fptools_cv_leading_underscore=yes;;
824
825 *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H
826 #include <nlist.h>
827 struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
828 struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}};
829 #endif
830
831 int main(argc, argv)
832 int argc;
833 char **argv;
834 {
835 #ifdef HAVE_NLIST_H
836     if(nlist(argv[0], xYzzY1) == 0 && xYzzY1[0].n_value != 0)
837         exit(1);
838     if(nlist(argv[0], xYzzY2) == 0 && xYzzY2[0].n_value != 0)
839         exit(0);
840 #endif
841     exit(1);
842 }]])],[fptools_cv_leading_underscore=yes],[fptools_cv_leading_underscore=no],[fptools_cv_leading_underscore=no])
843 ;;
844 esac]);
845 AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`])
846 if test x"$fptools_cv_leading_underscore" = xyes; then
847    AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.])
848 fi])# FP_LEADING_UNDERSCORE
849
850
851 # FP_COMPARE_VERSIONS(VERSION1, TEST, VERSION2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
852 # ----------------------------------------------------------------------------------
853 # Compare dotted version numbers VERSION1 and VERSION2 lexicographically according
854 # to TEST (one of -eq, -ne, -lt, -le, -gt, or -ge).
855 AC_DEFUN([FP_COMPARE_VERSIONS],
856 [fp_version1=$1; fp_version2=$3
857 fp_save_IFS=$IFS; IFS='.'
858 while test x"$fp_version1" != x || test x"$fp_version2" != x
859 do
860
861   set dummy $fp_version1; shift
862   fp_num1=""
863   test $[@%:@] = 0 || { fp_num1="[$]1"; shift; }
864   test x"$fp_num1" = x && fp_num1="0"
865   fp_version1="[$]*"
866
867   set dummy $fp_version2; shift
868   fp_num2=""
869   test $[@%:@] = 0 || { fp_num2="[$]1"; shift; }
870   test x"$fp_num2" = x && fp_num2="0"
871   fp_version2="[$]*"
872
873   test "$fp_num1" = "$fp_num2" || break;
874 done
875 IFS=$fp_save_IFS
876 AS_IF([test "$fp_num1" $2 "$fp_num2"], [$4], [$5])[]dnl
877 ])# FP_COMPARE_VERSIONS
878
879
880 dnl
881 dnl Check for Happy and version.
882 dnl If there's no installed Happy, we look
883 dnl for a happy source tree and point the build system at that instead.
884 dnl If you increase the minimum version requirement, please also update:
885 dnl https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Tools
886 dnl
887 AC_DEFUN([FPTOOLS_HAPPY],
888 [AC_PATH_PROG(HappyCmd,happy,)
889
890 AC_CACHE_CHECK([for version of happy], fptools_cv_happy_version,
891 changequote(, )dnl
892 [if test x"$HappyCmd" != x; then
893    fptools_cv_happy_version=`"$HappyCmd" -v |
894               grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'` ;
895 else
896    fptools_cv_happy_version="";
897 fi;
898 changequote([, ])dnl
899 ])
900 if test ! -f compiler/parser/Parser.hs || test ! -f compiler/cmm/CmmParse.hs
901 then
902     FP_COMPARE_VERSIONS([$fptools_cv_happy_version],[-lt],[1.19.4],
903       [AC_MSG_ERROR([Happy version 1.19.4 or later is required to compile GHC.])])[]
904 fi
905 HappyVersion=$fptools_cv_happy_version;
906 AC_SUBST(HappyVersion)
907 ])
908
909 dnl
910 dnl Check for Alex and version.
911 dnl If you increase the minimum version requirement, please also update:
912 dnl https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Tools
913 dnl
914 AC_DEFUN([FPTOOLS_ALEX],
915 [
916 AC_PATH_PROG(AlexCmd,alex,)
917
918 AC_CACHE_CHECK([for version of alex], fptools_cv_alex_version,
919 changequote(, )dnl
920 [if test x"$AlexCmd" != x; then
921    fptools_cv_alex_version=`"$AlexCmd" -v |
922               grep 'Alex [Vv]ersion' | sed -e 's/Alex [Vv]ersion \([0-9\.]*\).*/\1/g'` ;
923 else
924    fptools_cv_alex_version="";
925 fi;
926 changequote([, ])dnl
927 ])
928 FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-ge],[3.0],
929   [Alex3=YES],[Alex3=NO])
930 if test ! -f compiler/cmm/CmmLex.hs || test ! -f compiler/parser/Lexer.hs
931 then
932     FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.1.0],
933       [AC_MSG_ERROR([Alex version 3.1.0 or later is required to compile GHC.])])[]
934 fi
935 AlexVersion=$fptools_cv_alex_version;
936 AC_SUBST(AlexVersion)
937 AC_SUBST(Alex3)
938 ])
939
940
941 # FP_PROG_LD_FLAG
942 # ---------------
943 # Sets the output variable $2 to $1 if ld supports the $1 flag.
944 # Otherwise the variable's value is empty.
945 AC_DEFUN([FP_PROG_LD_FLAG],
946 [
947 AC_CACHE_CHECK([whether ld understands $1], [fp_cv_$2],
948 [echo 'int foo() { return 0; }' > conftest.c
949 ${CC-cc} -c conftest.c
950 if ${LdCmd} -r $1 -o conftest2.o conftest.o > /dev/null 2>&1; then
951    fp_cv_$2=$1
952 else
953    fp_cv_$2=
954 fi
955 rm -rf conftest*])
956 $2=$fp_cv_$2
957 ])# FP_PROG_LD_FLAG
958
959
960 # FP_PROG_LD_BUILD_ID
961 # ------------
962
963 # Sets the output variable LdHasBuildId to YES if ld supports
964 # --build-id, or NO otherwise.
965 AC_DEFUN([FP_PROG_LD_BUILD_ID],
966 [
967 AC_CACHE_CHECK([whether ld understands --build-id], [fp_cv_ld_build_id],
968 [echo 'int foo() { return 0; }' > conftest.c
969 ${CC-cc} -c conftest.c
970 if ${LdCmd} -r --build-id=none -o conftest2.o conftest.o > /dev/null 2>&1; then
971    fp_cv_ld_build_id=yes
972 else
973    fp_cv_ld_build_id=no
974 fi
975 rm -rf conftest*])
976 if test "$fp_cv_ld_build_id" = yes; then
977   LdHasBuildId=YES
978 else
979   LdHasBuildId=NO
980 fi
981 AC_SUBST([LdHasBuildId])
982 ])# FP_PROG_LD_BUILD_ID
983
984
985 # FP_PROG_LD_IS_GNU
986 # -----------------
987 # Sets the output variable LdIsGNULd to YES or NO, depending on whether it is
988 # GNU ld or not.
989 AC_DEFUN([FP_PROG_LD_IS_GNU],
990 [
991 AC_CACHE_CHECK([whether ld is GNU ld], [fp_cv_gnu_ld],
992 [if ${LdCmd} --version 2> /dev/null | grep "GNU" > /dev/null 2>&1; then
993   fp_cv_gnu_ld=yes
994 else
995   fp_cv_gnu_ld=no
996 fi])
997 AC_SUBST([LdIsGNULd], [`echo $fp_cv_gnu_ld | sed 'y/yesno/YESNO/'`])
998 ])# FP_PROG_LD_IS_GNU
999
1000
1001 # FP_PROG_LD_NO_COMPACT_UNWIND
1002 # ----------------------------
1003
1004 # Sets the output variable LdHasNoCompactUnwind to YES if ld supports
1005 # -no_compact_unwind, or NO otherwise.
1006 AC_DEFUN([FP_PROG_LD_NO_COMPACT_UNWIND],
1007 [
1008 AC_CACHE_CHECK([whether ld understands -no_compact_unwind], [fp_cv_ld_no_compact_unwind],
1009 [echo 'int foo() { return 0; }' > conftest.c
1010 ${CC-cc} -c conftest.c
1011 if ${LdCmd} -r -no_compact_unwind -o conftest2.o conftest.o > /dev/null 2>&1; then
1012    fp_cv_ld_no_compact_unwind=yes
1013 else
1014    fp_cv_ld_no_compact_unwind=no
1015 fi
1016 rm -rf conftest*])
1017 if test "$fp_cv_ld_no_compact_unwind" = yes; then
1018   LdHasNoCompactUnwind=YES
1019 else
1020   LdHasNoCompactUnwind=NO
1021 fi
1022 AC_SUBST([LdHasNoCompactUnwind])
1023 ])# FP_PROG_LD_NO_COMPACT_UNWIND
1024
1025
1026 # FP_PROG_LD_FILELIST
1027 # -------------------
1028
1029 # Sets the output variable LdHasFilelist to YES if ld supports
1030 # -filelist, or NO otherwise.
1031 AC_DEFUN([FP_PROG_LD_FILELIST],
1032 [
1033 AC_CACHE_CHECK([whether ld understands -filelist], [fp_cv_ld_has_filelist],
1034 [
1035     echo 'int foo() { return 0; }' > conftest1.c
1036     echo 'int bar() { return 0; }' > conftest2.c
1037     ${CC-cc} -c conftest1.c
1038     ${CC-cc} -c conftest2.c
1039     echo conftest1.o  > conftest.o-files
1040     echo conftest2.o >> conftest.o-files
1041     if ${LdCmd} -r -filelist conftest.o-files -o conftest.o > /dev/null 2>&1
1042     then
1043         fp_cv_ld_has_filelist=yes
1044     else
1045         fp_cv_ld_has_filelist=no
1046     fi
1047     rm -rf conftest*
1048 ])
1049 if test "$fp_cv_ld_has_filelist" = yes; then
1050     LdHasFilelist=YES
1051 else
1052     LdHasFilelist=NO
1053 fi
1054 AC_SUBST([LdHasFilelist])
1055 ])# FP_PROG_LD_FILELIST
1056
1057
1058 # FP_PROG_AR
1059 # ----------
1060 # Sets fp_prog_ar to a path to ar. Exits if no ar can be found
1061 AC_DEFUN([FP_PROG_AR],
1062 [AC_PATH_PROG([fp_prog_ar], [ar])
1063 if test -z "$fp_prog_ar"; then
1064   AC_MSG_ERROR([cannot find ar in your PATH, no idea how to make a library])
1065 fi
1066 ])# FP_PROG_AR
1067
1068
1069 # FP_PROG_AR_IS_GNU
1070 # -----------------
1071 # Sets fp_prog_ar_is_gnu to yes or no, depending on whether it is GNU ar or not.
1072 AC_DEFUN([FP_PROG_AR_IS_GNU],
1073 [AC_REQUIRE([FP_PROG_AR])
1074 AC_CACHE_CHECK([whether $fp_prog_ar is GNU ar], [fp_cv_prog_ar_is_gnu],
1075 [if "$fp_prog_ar" --version 2> /dev/null | grep "GNU" > /dev/null 2>&1; then
1076   fp_cv_prog_ar_is_gnu=yes
1077 else
1078   fp_cv_prog_ar_is_gnu=no
1079 fi])
1080 fp_prog_ar_is_gnu=$fp_cv_prog_ar_is_gnu
1081 AC_SUBST([ArIsGNUAr], [`echo $fp_prog_ar_is_gnu | tr 'a-z' 'A-Z'`])
1082 ])# FP_PROG_AR_IS_GNU
1083
1084
1085 # FP_PROG_AR_SUPPORTS_ATFILE
1086 # -----------------
1087 # Sets fp_prog_ar_supports_atfile to yes or no, depending on whether
1088 # or not it supports the @file syntax
1089 AC_DEFUN([FP_PROG_AR_SUPPORTS_ATFILE],
1090 [AC_REQUIRE([FP_PROG_AR])
1091  AC_REQUIRE([FP_PROG_AR_ARGS])
1092 AC_CACHE_CHECK([whether $fp_prog_ar supports @file], [fp_cv_prog_ar_supports_atfile],
1093 [
1094 rm -f conftest*
1095 touch conftest.file
1096 echo conftest.file  > conftest.atfile
1097 echo conftest.file >> conftest.atfile
1098 "$fp_prog_ar" $fp_prog_ar_args conftest.a @conftest.atfile > /dev/null 2>&1
1099 fp_prog_ar_supports_atfile_tmp=`"$fp_prog_ar" t conftest.a 2> /dev/null | grep -c conftest.file`
1100 rm -f conftest*
1101 if test "$fp_prog_ar_supports_atfile_tmp" -eq 2
1102 then
1103   fp_cv_prog_ar_supports_atfile=yes
1104 else
1105   fp_cv_prog_ar_supports_atfile=no
1106 fi])
1107 fp_prog_ar_supports_atfile=$fp_cv_prog_ar_supports_atfile
1108 AC_SUBST([ArSupportsAtFile], [`echo $fp_prog_ar_supports_atfile | tr 'a-z' 'A-Z'`])
1109 ])# FP_PROG_AR_SUPPORTS_ATFILE
1110
1111 # FP_PROG_AR_ARGS
1112 # ---------------
1113 # Sets fp_prog_ar_args to the arguments for ar and the output variable ArCmd
1114 # to an invocation of ar including these arguments.
1115 AC_DEFUN([FP_PROG_AR_ARGS],
1116 [AC_REQUIRE([FP_PROG_AR_IS_GNU])
1117 AC_CACHE_CHECK([for ar arguments], [fp_cv_prog_ar_args],
1118 [
1119 # GNU ar needs special treatment: it appears to have problems with
1120 # object files with the same name if you use the 's' modifier, but
1121 # simple 'ar q' works fine, and doesn't need a separate ranlib.
1122 if test $fp_prog_ar_is_gnu = yes; then
1123   fp_cv_prog_ar_args="q"
1124 else
1125   touch conftest.dummy
1126   for fp_var in clqsZ clqs cqs clq cq ; do
1127      rm -f conftest.a
1128      if "$fp_prog_ar" $fp_var conftest.a conftest.dummy > /dev/null 2> /dev/null; then
1129         fp_cv_prog_ar_args=$fp_var
1130         break
1131      fi
1132   done
1133   rm -f conftest*
1134   if test -z "$fp_cv_prog_ar_args"; then
1135     AC_MSG_ERROR([cannot figure out how to use your $fp_prog_ar])
1136   fi
1137 fi])
1138 fp_prog_ar_args=$fp_cv_prog_ar_args
1139 AC_SUBST([ArCmd], ["$fp_prog_ar"])
1140 AC_SUBST([ArArgs], ["$fp_prog_ar_args"])
1141
1142 ])# FP_PROG_AR_ARGS
1143
1144
1145 # FP_PROG_AR_NEEDS_RANLIB
1146 # -----------------------
1147 # Sets the output variable RANLIB_CMD to "ranlib" if it is needed and
1148 # found, to "true" otherwise. Sets REAL_RANLIB_CMD to the ranlib program,
1149 # even if we don't need ranlib (libffi might still need it).
1150 AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[
1151     AC_REQUIRE([FP_PROG_AR_IS_GNU])
1152     AC_REQUIRE([FP_PROG_AR_ARGS])
1153     AC_REQUIRE([AC_PROG_CC])
1154
1155     AC_PROG_RANLIB
1156
1157     if test $fp_prog_ar_is_gnu = yes
1158     then
1159         fp_cv_prog_ar_needs_ranlib=no
1160     elif test "$TargetOS_CPP" = "darwin"
1161     then
1162         # It's quite tedious to check for Apple's crazy timestamps in
1163         # .a files, so we hardcode it.
1164         fp_cv_prog_ar_needs_ranlib=yes
1165     else
1166         case $fp_prog_ar_args in
1167         *s*)
1168             fp_cv_prog_ar_needs_ranlib=no;;
1169         *)
1170             fp_cv_prog_ar_needs_ranlib=yes;;
1171         esac
1172     fi
1173
1174     # workaround for AC_PROG_RANLIB which sets RANLIB to `:' when
1175     # ranlib is missing on the target OS. The problem is that
1176     # ghc-cabal cannot execute `:' which is a shell built-in but can
1177     # execute `true' which is usually simple program supported by the
1178     # OS.
1179     # Fixes #8795
1180     if test "$RANLIB" = ":"
1181     then
1182         RANLIB="true"
1183     fi
1184     REAL_RANLIB_CMD="$RANLIB"
1185     if test $fp_cv_prog_ar_needs_ranlib = yes
1186     then
1187         RANLIB_CMD="$RANLIB"
1188     else
1189         RANLIB_CMD="true"
1190     fi
1191     AC_SUBST([REAL_RANLIB_CMD])
1192     AC_SUBST([RANLIB_CMD])
1193 ])# FP_PROG_AR_NEEDS_RANLIB
1194
1195
1196 # FP_GCC_VERSION
1197 # -----------
1198 # Extra testing of the result AC_PROG_CC, testing the gcc version no. Sets the
1199 # output variable GccVersion.
1200 AC_DEFUN([FP_GCC_VERSION],
1201 [AC_REQUIRE([AC_PROG_CC])
1202 if test -z "$CC"
1203 then
1204   AC_MSG_ERROR([gcc is required])
1205 fi
1206 GccLT34=NO
1207 GccLT46=NO
1208 AC_CACHE_CHECK([version of gcc], [fp_cv_gcc_version],
1209 [
1210     fp_cv_gcc_version="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version [[^0-9]]*\([[0-9.]]*\).*/\1/g'`"
1211     FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [3.0],
1212                         [AC_MSG_ERROR([Need at least gcc version 3.0 (3.4+ recommended)])])
1213     # See #2770: gcc 2.95 doesn't work any more, apparently.  There probably
1214     # isn't a very good reason for that, but for now just make configure
1215     # fail.
1216     FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [3.4], GccLT34=YES)
1217     FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.6], GccLT46=YES)
1218 ])
1219 AC_SUBST([GccVersion], [$fp_cv_gcc_version])
1220 AC_SUBST(GccLT34)
1221 AC_SUBST(GccLT46)
1222 ])# FP_GCC_VERSION
1223
1224 dnl Check to see if the C compiler is clang or llvm-gcc
1225 dnl
1226 GccIsClang=NO
1227 AC_DEFUN([FP_CC_LLVM_BACKEND],
1228 [AC_REQUIRE([AC_PROG_CC])
1229 AC_MSG_CHECKING([whether C compiler is clang])
1230 $CC -x c /dev/null -dM -E > conftest.txt 2>&1
1231 if grep "__clang__" conftest.txt >/dev/null 2>&1; then
1232   AC_SUBST([CC_CLANG_BACKEND], [1])
1233   AC_SUBST([CC_LLVM_BACKEND], [1])
1234   GccIsClang=YES
1235   AC_MSG_RESULT([yes])
1236 else
1237   AC_MSG_RESULT([no])
1238   AC_MSG_CHECKING([whether C compiler has an LLVM back end])
1239   if grep "__llvm__" conftest.txt >/dev/null 2>&1; then
1240     AC_SUBST([CC_CLANG_BACKEND], [0])
1241     AC_SUBST([CC_LLVM_BACKEND], [1])
1242     AC_MSG_RESULT([yes])
1243   else
1244     AC_SUBST([CC_CLANG_BACKEND], [0])
1245     AC_SUBST([CC_LLVM_BACKEND], [0])
1246     AC_MSG_RESULT([no])
1247   fi
1248 fi
1249 AC_SUBST(GccIsClang)
1250
1251 rm -f conftest.txt
1252 ])
1253
1254 dnl Small feature test for perl version. Assumes PerlCmd
1255 dnl contains path to perl binary.
1256 dnl
1257 dnl (Perl versions prior to v5.6 does not contain the string "v5";
1258 dnl instead they display version strings such as "version 5.005".)
1259 dnl
1260 AC_DEFUN([FPTOOLS_CHECK_PERL_VERSION],
1261 [$PerlCmd -v >conftest.out 2>&1
1262    if grep "v5" conftest.out >/dev/null 2>&1; then
1263       :
1264    else
1265       AC_MSG_ERROR([your version of perl probably won't work, try upgrading it.])
1266    fi
1267 rm -fr conftest*
1268 ])
1269
1270
1271 # FP_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
1272 #               [VALUE-IF-NOT-FOUND], [PATH], [REJECT])
1273 # -----------------------------------------------------
1274 # HACK: A small wrapper around AC_CHECK_PROG, setting VARIABLE to the full path
1275 # of PROG-TO-CHECK-FOR when found.
1276 AC_DEFUN([FP_CHECK_PROG],
1277 [AC_CHECK_PROG([$1], [$2], [$as_dir/$ac_word$ac_exec_ext], [$3], [$4], [$5])][]dnl
1278 )# FP_CHECK_PROC
1279
1280
1281 # FP_PROG_FIND
1282 # ------------
1283 # Find a non-WinDoze version of the "find" utility.
1284 AC_DEFUN([FP_PROG_FIND],
1285 [AC_PATH_PROGS([fp_prog_find], [gfind find], find)
1286 echo foo > conftest.txt
1287 $fp_prog_find conftest.txt -print > conftest.out 2>&1
1288 if grep '^conftest.txt$' conftest.out > /dev/null 2>&1 ; then
1289   # OK, looks like a real "find".
1290   FindCmd="$fp_prog_find"
1291 else
1292   # Found a poor WinDoze version of "find", ignore it.
1293   AC_MSG_WARN([$fp_prog_find looks like a non-*nix find, ignoring it])
1294   FP_CHECK_PROG([FindCmd], [find], [], [], [$fp_prog_find])
1295 fi
1296 rm -f conftest.txt conftest.out
1297 AC_SUBST([FindCmd])[]dnl
1298 ])# FP_PROG_FIND
1299
1300
1301 # FP_PROG_SORT
1302 # ------------
1303 # Find a Unix-like sort
1304 AC_DEFUN([FP_PROG_SORT],
1305 [AC_PATH_PROG([fp_prog_sort], [sort])
1306 echo conwip > conftest.txt
1307 $fp_prog_sort -f conftest.txt > conftest.out 2>&1
1308 if grep 'conwip' conftest.out > /dev/null 2>&1 ; then
1309   # The goods
1310   SortCmd="$fp_prog_sort"
1311 else
1312   # Summink else..pick next one.
1313   AC_MSG_WARN([$fp_prog_sort looks like a non-*nix sort, ignoring it])
1314   FP_CHECK_PROG([SortCmd], [sort], [], [], [$fp_prog_sort])
1315 fi
1316 rm -f conftest.txt conftest.out
1317 AC_SUBST([SortCmd])[]dnl
1318 ])# FP_PROG_SORT
1319
1320
1321 dnl
1322 dnl FPTOOLS_NOCACHE_CHECK prints a message, then sets the
1323 dnl values of the second argument to the result of running
1324 dnl the commands given by the third. It does not cache its
1325 dnl result, so it is suitable for checks which should be
1326 dnl run every time.
1327 dnl
1328 AC_DEFUN([FPTOOLS_NOCACHE_CHECK],
1329 [AC_MSG_CHECKING([$1])
1330  $3
1331  AC_MSG_RESULT([$][$2])
1332 ])
1333
1334 dnl
1335 dnl FPTOOLS_GHC_VERSION(version)
1336 dnl FPTOOLS_GHC_VERSION(major, minor [, patchlevel])
1337 dnl FPTOOLS_GHC_VERSION(version, major, minor, patchlevel)
1338 dnl
1339 dnl Test for version of installed ghc.  Uses $GHC.
1340 dnl [original version pinched from c2hs]
1341 dnl
1342 AC_DEFUN([FPTOOLS_GHC_VERSION],
1343 [FPTOOLS_NOCACHE_CHECK([version of ghc], [fptools_version_of_ghc],
1344 ["${WithGhc-ghc}" --version > conftestghc 2>&1
1345   cat conftestghc >&AS_MESSAGE_LOG_FD
1346 #Useless Use Of cat award...
1347   fptools_version_of_ghc=`cat conftestghc | sed -n -e 's/, patchlevel *\([[0-9]]\)/.\1/;s/.* version \([[0-9]][[0-9.]]*\).*/\1/p'`
1348   rm -fr conftest*
1349   if test "[$]fptools_version_of_ghc" = ""
1350   then
1351     fptools_version_of_ghc='unknown'
1352   fi
1353 fptools_version_of_ghc[_major]=`echo [$]fptools_version_of_ghc | sed -e 's/^\([[0-9]]\).*/\1/'`
1354 fptools_version_of_ghc[_minor]=`echo [$]fptools_version_of_ghc | sed -e 's/^[[0-9]]\.\([[0-9]]*\).*/\1/'`
1355 fptools_version_of_ghc[_pl]=`echo [$]fptools_version_of_ghc | sed -n -e 's/^[[0-9]]\.[[0-9]]*\.\([[0-9]]*\)/\1/p'`
1356 #
1357 if test "[$]fptools_version_of_ghc[_pl]" = ""
1358 then
1359   fptools_version_of_ghc[_all]="[$]fptools_version_of_ghc[_major].[$]fptools_version_of_ghc[_minor]"
1360   fptools_version_of_ghc[_pl]="0"
1361 else
1362   fptools_version_of_ghc[_all]="[$]fptools_version_of_ghc[_major].[$]fptools_version_of_ghc[_minor].[$]fptools_version_of_ghc[_pl]"
1363 fi
1364 #
1365 ifelse($#, [1], [dnl
1366 [$1]="[$]fptools_version_of_ghc[_all]"
1367 ], $#, [2], [dnl
1368 [$1]="[$]fptools_version_of_ghc[_major]"
1369 [$2]="[$]fptools_version_of_ghc[_minor]"
1370 ], $#, [3], [dnl
1371 [$1]="[$]fptools_version_of_ghc[_major]"
1372 [$2]="[$]fptools_version_of_ghc[_minor]"
1373 [$3]="[$]fptools_version_of_ghc[_pl]"
1374 ], $#, [4], [dnl
1375 [$1]="[$]fptools_version_of_ghc[_all]"
1376 [$2]="[$]fptools_version_of_ghc[_major]"
1377 [$3]="[$]fptools_version_of_ghc[_minor]"
1378 [$4]="[$]fptools_version_of_ghc[_pl]"
1379 ])
1380 ])
1381 ])dnl
1382
1383
1384 # FP_CHECK_FUNC(FUNCTION, PROLOGUE, BODY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1385 # ---------------------------------------------------------------------------------
1386 # A variant of AC_CHECK_FUNCS, limited to a single FUNCTION, but with the
1387 # additional flexibility of specifying the PROLOGUE and BODY.
1388 AC_DEFUN([FP_CHECK_FUNC],
1389 [AS_VAR_PUSHDEF([fp_func], [fp_cv_func_$1])dnl
1390 AC_CACHE_CHECK([for $1], fp_func,
1391 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], [$3])],
1392                 [AS_VAR_SET(fp_func, yes)],
1393                 [AS_VAR_SET(fp_func, no)])])
1394 AS_IF([test AS_VAR_GET(fp_func) = yes],
1395       [AC_DEFINE(AS_TR_CPP(HAVE_$1), [1],
1396                 [Define to 1 if you have the `]$1[' function.]) $4],
1397       [$5])dnl
1398 AS_VAR_POPDEF([fp_func])dnl
1399 ])# FP_CHECK_FUNC
1400
1401 # FP_PROG_GHC_PKG
1402 # ----------------
1403 # Try to find a ghc-pkg matching the ghc mentioned in the environment variable
1404 # WithGhc. Sets the output variable GhcPkgCmd.
1405 AC_DEFUN([FP_PROG_GHC_PKG],
1406 [AC_CACHE_CHECK([for ghc-pkg matching $WithGhc], fp_cv_matching_ghc_pkg,
1407 [
1408 # If we are told to use ghc-stage2, then we're using an in-tree
1409 # compiler. In this case, we just want ghc-pkg, not ghc-pkg-stage2,
1410 # so we sed off -stage[0-9]$. However, if we are told to use
1411 # ghc-6.12.1 then we want to use ghc-pkg-6.12.1, so we keep any
1412 # other suffix.
1413 fp_ghc_pkg_guess=`echo "$WithGhc" | sed -e 's/-stage@<:@0-9@:>@$//' -e 's,ghc\(@<:@^/\\@:>@*\)$,ghc-pkg\1,'`
1414 if "$fp_ghc_pkg_guess" list > /dev/null 2>&1; then
1415   fp_cv_matching_ghc_pkg=$fp_ghc_pkg_guess
1416 else
1417   AC_MSG_ERROR([Cannot find matching ghc-pkg])
1418 fi])
1419 GhcPkgCmd=$fp_cv_matching_ghc_pkg
1420 AC_SUBST([GhcPkgCmd])
1421 ])# FP_PROG_GHC_PKG
1422
1423
1424 # FP_GCC_EXTRA_FLAGS
1425 # ------------------
1426 # Determine which extra flags we need to pass gcc when we invoke it
1427 # to compile .hc code.
1428 #
1429 # -fwrapv is needed for gcc to emit well-behaved code in the presence of
1430 # integer wrap around. (Trac #952)
1431 #
1432 AC_DEFUN([FP_GCC_EXTRA_FLAGS],
1433 [AC_REQUIRE([FP_GCC_VERSION])
1434 AC_CACHE_CHECK([for extra options to pass gcc when compiling via C], [fp_cv_gcc_extra_opts],
1435 [fp_cv_gcc_extra_opts=
1436  FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-ge], [3.4],
1437   [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fwrapv"],
1438   [])
1439 ])
1440 AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts)
1441 ])
1442
1443
1444 # FP_SETUP_PROJECT_VERSION
1445 # ---------------------
1446 AC_DEFUN([FP_SETUP_PROJECT_VERSION],
1447 [
1448 if test "$RELEASE" = "NO"; then
1449     AC_MSG_CHECKING([for GHC version date])
1450     if test -f VERSION_DATE; then
1451         PACKAGE_VERSION=${PACKAGE_VERSION}.`cat VERSION_DATE`
1452         AC_MSG_RESULT(given $PACKAGE_VERSION)
1453     elif test -d .git; then
1454         changequote(, )dnl
1455         ver_date=`git log -n 1 --date=short --pretty=format:%ci | cut -d ' ' -f 1 | tr -d -`
1456         if echo $ver_date | grep '^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' 2>&1 >/dev/null; then true; else
1457         changequote([, ])dnl
1458                 AC_MSG_ERROR([failed to detect version date: check that git is in your path])
1459         fi
1460         PACKAGE_VERSION=${PACKAGE_VERSION}.$ver_date
1461         AC_MSG_RESULT(inferred $PACKAGE_VERSION)
1462     elif test -f VERSION; then
1463         PACKAGE_VERSION=`cat VERSION`
1464         AC_MSG_RESULT(given $PACKAGE_VERSION)
1465     else
1466         AC_MSG_WARN([cannot determine snapshot version: no .git directory and no VERSION file])
1467         dnl We'd really rather this case didn't happen, but it might
1468         dnl do (in particular, people using lndir trees may find that
1469         dnl the build system can't find any other date). If it does
1470         dnl happen, then we use the current date.
1471         dnl This way we get some idea about how recent a build is.
1472         dnl It also means that packages built for 2 different builds
1473         dnl will probably use different version numbers, so things are
1474         dnl less likely to go wrong.
1475         PACKAGE_VERSION=${PACKAGE_VERSION}.`date +%Y%m%d`
1476     fi
1477 fi
1478
1479     AC_MSG_CHECKING([for GHC Git commit id])
1480     if test -d .git; then
1481         git_commit_id=`git rev-parse HEAD`
1482         if test -n "$git_commit_id" 2>&1 >/dev/null; then true; else
1483             AC_MSG_ERROR([failed to detect revision: check that git is in your path])
1484         fi
1485         PACKAGE_GIT_COMMIT_ID=$git_commit_id
1486         AC_MSG_RESULT(inferred $PACKAGE_GIT_COMMIT_ID)
1487     elif test -f GIT_COMMIT_ID; then
1488         PACKAGE_GIT_COMMIT_ID=`cat GIT_COMMIT_ID`
1489         AC_MSG_RESULT(given $PACKAGE_GIT_COMMIT_ID)
1490     else
1491         AC_MSG_WARN([cannot determine snapshot revision: no .git directory and no 'GIT_COMMIT_ID' file])
1492         PACKAGE_GIT_COMMIT_ID="0000000000000000000000000000000000000000"
1493     fi
1494
1495
1496 # Some renamings
1497 AC_SUBST([ProjectName], [$PACKAGE_NAME])
1498 AC_SUBST([ProjectVersion], [$PACKAGE_VERSION])
1499 AC_SUBST([ProjectGitCommitId], [$PACKAGE_GIT_COMMIT_ID])
1500
1501 # Split PACKAGE_VERSION into (possibly empty) parts
1502 VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
1503 VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
1504 VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
1505 ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
1506
1507 # Calculate project version as an integer, using 2 digits for minor version
1508 case $VERSION_MINOR in
1509   ?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;
1510   ??) ProjectVersionInt=${VERSION_MAJOR}${VERSION_MINOR} ;;
1511   *) AC_MSG_ERROR([bad minor version in $PACKAGE_VERSION]) ;;
1512 esac
1513 AC_SUBST([ProjectVersionInt])
1514
1515 # The project patchlevel is zero unless stated otherwise
1516 test -z "$ProjectPatchLevel" && ProjectPatchLevel=0
1517
1518 # Save split version of ProjectPatchLevel
1519 ProjectPatchLevel1=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1/'`
1520 ProjectPatchLevel2=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3/'`
1521
1522 AC_SUBST([ProjectPatchLevel1])
1523 AC_SUBST([ProjectPatchLevel2])
1524
1525 # Remove dots from the patch level; this allows us to have versions like 6.4.1.20050508
1526 ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'`
1527
1528 AC_SUBST([ProjectPatchLevel])
1529 ])# FP_SETUP_PROJECT_VERSION
1530
1531
1532 # Check for a working timer_create().  We need a pretty detailed check
1533 # here, because there exist partially-working implementations of
1534 # timer_create() in certain versions of Linux (see bug #1933).
1535 #
1536 AC_DEFUN([FP_CHECK_TIMER_CREATE],[
1537 AC_CHECK_FUNC([timer_create],[HAVE_timer_create=yes],[HAVE_timer_create=no])
1538
1539 if test "$HAVE_timer_create" = "yes"
1540 then
1541   if test "$cross_compiling" = "yes"
1542   then
1543     # We can't test timer_create when we're cross-compiling, so we
1544     # optimistiaclly assume that it actually works properly.
1545     AC_DEFINE([USE_TIMER_CREATE], 1,  [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)])
1546   else
1547   AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
1548     [fptools_cv_timer_create_works],
1549     [AC_TRY_RUN([
1550 #include <stdio.h>
1551 #ifdef HAVE_STDLIB_H
1552 #include <stdlib.h>
1553 #endif
1554 #ifdef HAVE_TIME_H
1555 #include <time.h>
1556 #endif
1557 #ifdef HAVE_SIGNAL_H
1558 #include <signal.h>
1559 #endif
1560 #ifdef HAVE_UNISTD_H
1561 #include <unistd.h>
1562 #endif
1563
1564 static volatile int tock = 0;
1565 static void handler(int i)
1566 {
1567    tock = 1;
1568 }
1569
1570 static void timeout(int i)
1571 {
1572   // timer_settime() has been known to hang, so just in case
1573   // we install a 1-second timeout (see #2257)
1574   exit(99);
1575 }
1576
1577 int main(int argc, char *argv[])
1578 {
1579
1580     struct sigevent ev;
1581     timer_t timer;
1582     struct itimerspec it;
1583     struct sigaction action;
1584     int m,n,count = 0;
1585
1586     ev.sigev_notify = SIGEV_SIGNAL;
1587     ev.sigev_signo  = SIGVTALRM;
1588
1589     action.sa_handler = handler;
1590     action.sa_flags = 0;
1591     sigemptyset(&action.sa_mask);
1592     if (sigaction(SIGVTALRM, &action, NULL) == -1) {
1593         fprintf(stderr,"SIGVTALRM problem\n");
1594         exit(3);
1595     }
1596
1597     action.sa_handler = timeout;
1598     action.sa_flags = 0;
1599     sigemptyset(&action.sa_mask);
1600     if (sigaction(SIGALRM, &action, NULL) == -1) {
1601       fprintf(stderr,"SIGALRM problem\n");
1602       exit(3);
1603     }
1604     alarm(1);
1605
1606     if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
1607         fprintf(stderr,"No CLOCK_REALTIME timer\n");
1608         exit(2);
1609     }
1610
1611     tock = 0;
1612
1613     it.it_value.tv_sec = 0;
1614     it.it_value.tv_nsec = 1000000; // 1ms
1615     it.it_interval = it.it_value;
1616     if (timer_settime(timer, 0, &it, NULL) != 0) {
1617         fprintf(stderr,"settime problem\n");
1618         exit(4);
1619     }
1620
1621     // some environments have coarse scheduler/timer granularity of ~10ms and worse
1622     usleep(100000); // 100ms
1623
1624     if (!tock) {
1625         fprintf(stderr,"no CLOCK_REALTIME signal\n");
1626         exit(5);
1627     }
1628
1629     timer_delete(timer);
1630
1631     exit(0);
1632 }
1633      ],
1634      [fptools_cv_timer_create_works=yes],
1635      [fptools_cv_timer_create_works=no])
1636   ])
1637 case $fptools_cv_timer_create_works in
1638     yes) AC_DEFINE([USE_TIMER_CREATE], 1,
1639                    [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
1640 esac
1641   fi
1642 fi
1643 ])
1644
1645 # FP_ICONV
1646 # -------------
1647 AC_DEFUN([FP_ICONV],
1648 [
1649   dnl--------------------------------------------------------------------
1650   dnl * Deal with arguments telling us iconv is somewhere odd
1651   dnl--------------------------------------------------------------------
1652
1653   dnl Note: ICONV_LIB_DIRS and ICONV_INCLUDE_DIRS are not predefined
1654   dnl to the empty string to allow them to be overridden from the
1655   dnl environment.
1656
1657   AC_ARG_WITH([iconv-includes],
1658     [AC_HELP_STRING([--with-iconv-includes],
1659       [directory containing iconv.h])],
1660       [ICONV_INCLUDE_DIRS=$withval])
1661
1662   AC_ARG_WITH([iconv-libraries],
1663     [AC_HELP_STRING([--with-iconv-libraries],
1664       [directory containing iconv library])],
1665       [ICONV_LIB_DIRS=$withval])
1666
1667   AC_SUBST(ICONV_INCLUDE_DIRS)
1668   AC_SUBST(ICONV_LIB_DIRS)
1669 ])# FP_ICONV
1670
1671 # FP_GMP
1672 # -------------
1673 AC_DEFUN([FP_GMP],
1674 [
1675   dnl--------------------------------------------------------------------
1676   dnl * Deal with arguments telling us gmp is somewhere odd
1677   dnl--------------------------------------------------------------------
1678
1679   AC_ARG_WITH([gmp-includes],
1680     [AC_HELP_STRING([--with-gmp-includes],
1681       [directory containing gmp.h])],
1682       [GMP_INCLUDE_DIRS=$withval])
1683
1684   AC_ARG_WITH([gmp-libraries],
1685     [AC_HELP_STRING([--with-gmp-libraries],
1686       [directory containing gmp library])],
1687       [GMP_LIB_DIRS=$withval])
1688
1689   AC_SUBST(GMP_INCLUDE_DIRS)
1690   AC_SUBST(GMP_LIB_DIRS)
1691 ])# FP_GMP
1692
1693 # FP_CURSES
1694 # -------------
1695 AC_DEFUN([FP_CURSES],
1696 [
1697   dnl--------------------------------------------------------------------
1698   dnl * Deal with arguments telling us curses is somewhere odd
1699   dnl--------------------------------------------------------------------
1700
1701   AC_ARG_WITH([curses-includes],
1702     [AC_HELP_STRING([--with-curses-includes],
1703       [directory containing curses headers])],
1704       [CURSES_INCLUDE_DIRS=$withval])
1705
1706   AC_ARG_WITH([curses-libraries],
1707     [AC_HELP_STRING([--with-curses-libraries],
1708       [directory containing curses libraries])],
1709       [CURSES_LIB_DIRS=$withval])
1710
1711   AC_SUBST(CURSES_INCLUDE_DIRS)
1712   AC_SUBST(CURSES_LIB_DIRS)
1713 ])# FP_CURSES
1714
1715 # --------------------------------------------------------------
1716 # Calculate absolute path to build tree
1717 # --------------------------------------------------------------
1718
1719 AC_DEFUN([FP_INTREE_GHC_PWD],[
1720 AC_MSG_NOTICE(Building in-tree ghc-pwd)
1721     dnl This would be
1722     dnl     make -C utils/ghc-pwd clean && make -C utils/ghc-pwd
1723     dnl except we don't want to have to know what make is called. Sigh.
1724     rm -rf utils/ghc-pwd/dist-boot
1725     mkdir  utils/ghc-pwd/dist-boot
1726     dnl If special linker flags are needed to build things, then allow
1727     dnl the user to pass them in via LDFLAGS.
1728     changequote(, )dnl
1729     GHC_LDFLAGS=`perl -e 'foreach (@ARGV) { print "-optl$_ " }' -- $LDFLAGS`
1730     changequote([, ])dnl
1731     if ! "$WithGhc" $GHC_LDFLAGS -v0 -no-user-$GHC_PACKAGE_DB_FLAG -hidir utils/ghc-pwd/dist-boot -odir utils/ghc-pwd/dist-boot -stubdir utils/ghc-pwd/dist-boot --make utils/ghc-pwd/Main.hs -o utils/ghc-pwd/dist-boot/ghc-pwd
1732     then
1733         AC_MSG_ERROR([Building ghc-pwd failed])
1734     fi
1735
1736     GHC_PWD=utils/ghc-pwd/dist-boot/ghc-pwd
1737 ])
1738
1739 AC_DEFUN([FP_BINDIST_GHC_PWD],[
1740     GHC_PWD=utils/ghc-pwd/dist-install/build/tmp/ghc-pwd-bindist
1741 ])
1742
1743 AC_DEFUN([FP_FIND_ROOT],[
1744 AC_MSG_CHECKING(for path to top of build tree)
1745     hardtop=`$GHC_PWD`
1746
1747     dnl Remove common automounter nonsense
1748     hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|'`
1749
1750     if ! test -d "$hardtop"; then
1751         AC_MSG_ERROR([cannot determine current directory])
1752     fi
1753
1754     dnl We don't support building in directories with spaces.
1755     case "$hardtop" in
1756     *' '*)
1757         AC_MSG_ERROR([
1758         The build system does not support building in a directory
1759         containing space characters.
1760         Suggestion: move the build tree somewhere else.])
1761         ;;
1762     esac
1763
1764     AC_SUBST(hardtop)
1765
1766     AC_MSG_RESULT($hardtop)
1767 ])
1768
1769 # GHC_CONVERT_CPU(cpu, target_var)
1770 # --------------------------------
1771 # converts cpu from gnu to ghc naming, and assigns the result to $target_var
1772 AC_DEFUN([GHC_CONVERT_CPU],[
1773 case "$1" in
1774   aarch64*)
1775     $2="aarch64"
1776     ;;
1777   alpha*)
1778     $2="alpha"
1779     ;;
1780   arm*)
1781     $2="arm"
1782     ;;
1783   hppa1.1*)
1784     $2="hppa1_1"
1785     ;;
1786   hppa*)
1787     $2="hppa"
1788     ;;
1789   i386|i486|i586|i686)
1790     $2="i386"
1791     ;;
1792   ia64)
1793     $2="ia64"
1794     ;;
1795   m68k*)
1796     $2="m68k"
1797     ;;
1798   mipseb*)
1799     $2="mipseb"
1800     ;;
1801   mipsel*)
1802     $2="mipsel"
1803     ;;
1804   mips*)
1805     $2="mips"
1806     ;;
1807   powerpc64le*)
1808     $2="powerpc64le"
1809     ;;
1810   powerpc64*)
1811     $2="powerpc64"
1812     ;;
1813   powerpc*)
1814     $2="powerpc"
1815     ;;
1816   rs6000)
1817     $2="rs6000"
1818     ;;
1819   s390x*)
1820     $2="s390x"
1821     ;;
1822   s390*)
1823     $2="s390"
1824     ;;
1825   sparc64*)
1826     $2="sparc64"
1827     ;;
1828   sparc*)
1829     $2="sparc"
1830     ;;
1831   vax)
1832     $2="vax"
1833     ;;
1834   x86_64|amd64)
1835     $2="x86_64"
1836     ;;
1837   *)
1838     echo "Unknown CPU $1"
1839     exit 1
1840     ;;
1841   esac
1842 ])
1843
1844 # GHC_CONVERT_VENDOR(vendor, target_var)
1845 # --------------------------------
1846 # converts vendor from gnu to ghc naming, and assigns the result to $target_var
1847 AC_DEFUN([GHC_CONVERT_VENDOR],[
1848   case "$1" in
1849   pc|gentoo|w64) # like i686-pc-linux-gnu, i686-gentoo-freebsd8, x86_64-w64-mingw32
1850     $2="unknown"
1851     ;;
1852   softfloat) # like armv5tel-softfloat-linux-gnueabi
1853     $2="unknown"
1854     ;;
1855   hardfloat) # like armv7a-hardfloat-linux-gnueabi
1856     $2="unknown"
1857     ;;
1858   *)
1859     #pass thru by default
1860     $2="$1"
1861     ;;
1862   esac
1863 ])
1864
1865 # GHC_CONVERT_OS(os, converted_cpu, target_var)
1866 # --------------------------------
1867 # converts os from gnu to ghc naming, and assigns the result to $target_var
1868 AC_DEFUN([GHC_CONVERT_OS],[
1869 case "$1-$2" in
1870   darwin10-arm|darwin11-i386|darwin14-aarch64)
1871     $3="ios"
1872     ;;
1873   *)
1874     case "$1" in
1875       linux-android*)
1876         $3="linux-android"
1877         ;;
1878       linux-*|linux)
1879         $3="linux"
1880         ;;
1881       # As far as I'm aware, none of these have relevant variants
1882       freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|irix|haiku)
1883         $3="$1"
1884         ;;
1885       aix*) # e.g. powerpc-ibm-aix7.1.3.0
1886         $3="aix"
1887         ;;
1888       freebsd*) # like i686-gentoo-freebsd7
1889                 #      i686-gentoo-freebsd8
1890                 #      i686-gentoo-freebsd8.2
1891         $3="freebsd"
1892         ;;
1893       nto-qnx*)
1894         $3="nto-qnx"
1895         ;;
1896       *)
1897         echo "Unknown OS $1"
1898         exit 1
1899         ;;
1900       esac
1901       ;;
1902   esac
1903 ])
1904
1905 # BOOTSTRAPPING_GHC_INFO_FIELD
1906 # --------------------------------
1907 # Set the variable $1 to the value of the ghc --info field $2.
1908 AC_DEFUN([BOOTSTRAPPING_GHC_INFO_FIELD],[
1909 $1=`"$WithGhc" --info | grep "^ ,(\"$2\"," | sed -e 's/.*","//' -e 's/")$//'`
1910 tmp=${$1#\$topdir/}
1911 if test "${$1}" != "$tmp"
1912 then
1913     topdir=`"$WithGhc" --print-libdir | sed 's#\\\\#/#g'`
1914     $1="$topdir/$tmp"
1915 fi
1916 AC_SUBST($1)
1917 ])
1918
1919 # LIBRARY_VERSION(lib, [dir])
1920 # --------------------------------
1921 # Gets the version number of a library.
1922 # If $1 is ghc-prim, then we define LIBRARY_ghc_prim_VERSION as 1.2.3
1923 # $2 points to the directory under libraries/
1924 AC_DEFUN([LIBRARY_VERSION],[
1925 dir=m4_default([$2],[$1])
1926 LIBRARY_[]translit([$1], [-], [_])[]_VERSION=`grep -i "^version:" libraries/${dir}/$1.cabal | sed "s/.* //"`
1927 AC_SUBST(LIBRARY_[]translit([$1], [-], [_])[]_VERSION)
1928 ])
1929
1930 # XCODE_VERSION()
1931 # --------------------------------
1932 # Gets the version number of XCode, if on a Mac
1933 AC_DEFUN([XCODE_VERSION],[
1934     if test "$TargetOS_CPP" = "darwin"
1935     then
1936         AC_MSG_CHECKING(XCode version)
1937         XCodeVersion=`xcodebuild -version | grep Xcode | sed "s/Xcode //"`
1938         # Old XCode versions don't actually give the XCode version
1939         if test "$XCodeVersion" = ""
1940         then
1941             AC_MSG_RESULT(not found (too old?))
1942             XCodeVersion1=0
1943             XCodeVersion2=0
1944         else
1945             AC_MSG_RESULT($XCodeVersion)
1946             XCodeVersion1=`echo "$XCodeVersion" | sed 's/\..*//'`
1947             changequote(, )dnl
1948             XCodeVersion2=`echo "$XCodeVersion" | sed 's/[^.]*\.\([^.]*\).*/\1/'`
1949             changequote([, ])dnl
1950             AC_MSG_NOTICE(XCode version component 1: $XCodeVersion1)
1951             AC_MSG_NOTICE(XCode version component 2: $XCodeVersion2)
1952         fi
1953     fi
1954 ])
1955
1956 # FIND_LLVM_PROG()
1957 # --------------------------------
1958 # Find where the llvm tools are. We have a special function to handle when they
1959 # are installed with a version suffix (e.g., llc-3.1).
1960 #
1961 # $1 = the variable to set
1962 # $2 = the with option name
1963 # $3 = the command to look for
1964 # $4 = the version of the command to look for
1965 #
1966 AC_DEFUN([FIND_LLVM_PROG],[
1967     # Test for program with version name.
1968     FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3-$4])
1969     if test "$$1" = ""; then
1970         # Test for program without version name.
1971         FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3])
1972         AC_MSG_CHECKING([$$1 is version $4])
1973         if test `$$1 --version | grep -c "version $4"` -gt 0 ; then
1974             AC_MSG_RESULT(yes)
1975         else
1976             AC_MSG_RESULT(no)
1977             $1=""
1978         fi
1979     fi
1980 ])
1981
1982 # FIND_LD
1983 # Find the version of `ld` to use. This is used in both in the top level
1984 # configure.ac and in distrib/configure.ac.in.
1985 #
1986 # $1 = the variable to set
1987 #
1988 AC_DEFUN([FIND_LD],[
1989     FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
1990     case $target in
1991         arm*linux*       | \
1992         aarch64*linux*   )
1993             # Arm and Aarch64 requires use of the binutils ld.gold linker.
1994             # This case should catch at least arm-unknown-linux-gnueabihf,
1995             # arm-linux-androideabi, arm64-unknown-linux and
1996             # aarch64-linux-android
1997             FP_ARG_WITH_PATH_GNU_PROG([LD_GOLD], [ld.gold], [ld.gold])
1998             $1="$LD_GOLD"
1999             ;;
2000         *)
2001             $1="$LD"
2002             ;;
2003     esac
2004 ])
2005
2006 # FIND_GHC_BOOTSTRAP_PROG()
2007 # --------------------------------
2008 # Parse the bootstrap GHC's compier settings file for the location of things
2009 # like the `llc` and `opt` commands.
2010 #
2011 # $1 = the variable to set
2012 # $2 = The bootstrap compiler.
2013 # $3 = The string to grep for to find the correct line.
2014 #
2015 AC_DEFUN([FIND_GHC_BOOTSTRAP_PROG],[
2016     BootstrapTmpCmd=`grep $3 $($2 --print-libdir)/settings 2>/dev/null | sed 's/.*", "//;s/".*//'`
2017     if test -n "$BootstrapTmpCmd" && test `basename $BootstrapTmpCmd` = $BootstrapTmpCmd ; then
2018         AC_PATH_PROG([$1], [$BootstrapTmpCmd], "")
2019     else
2020         $1=$BootstrapTmpCmd
2021     fi
2022 ])
2023
2024
2025 # FIND_GCC()
2026 # --------------------------------
2027 # Finds where gcc is
2028 #
2029 # $1 = the variable to set
2030 # $2 = the with option name
2031 # $3 = the command to look for
2032 AC_DEFUN([FIND_GCC],[
2033     if test "$TargetOS_CPP" = "darwin" &&
2034        test "$XCodeVersion1" -eq 4 &&
2035        test "$XCodeVersion2" -lt 2
2036     then
2037         # In Xcode 4.1, 'gcc-4.2' is the gcc legacy backend (rather
2038         # than the LLVM backend). We prefer the legacy gcc, but in
2039         # Xcode 4.2 'gcc-4.2' was removed.
2040         FP_ARG_WITH_PATH_GNU_PROG([$1], [gcc-4.2], [gcc-4.2])
2041     elif test "$windows" = YES
2042     then
2043         $1="$CC"
2044     else
2045         FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [$2], [$3])
2046         # From Xcode 5 on/, OS X command line tools do not include gcc
2047         # anymore. Use clang.
2048         if test -z "$$1"
2049         then
2050             FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [clang], [clang])
2051         fi
2052         if test -z "$$1"
2053         then
2054             AC_MSG_ERROR([cannot find $3 nor clang in your PATH])
2055         fi
2056     fi
2057     AC_SUBST($1)
2058 ])
2059
2060 AC_DEFUN([MAYBE_OVERRIDE_STAGE0],[
2061   if test ! -z "$With_$1" -a "$CrossCompiling" != "YES"; then
2062       AC_MSG_NOTICE([Not cross-compiling, so --with-$1 also sets $2])
2063       $2=$With_$1
2064   fi
2065 ])
2066
2067
2068 # FP_CPP_CMD_WITH_ARGS()
2069 # ----------------------
2070 # sets CPP command and its arguments
2071 #
2072 # $1 = the variable to set to CPP command
2073 # $2 = the varibale to set to CPP command arguments
2074
2075 AC_DEFUN([FP_CPP_CMD_WITH_ARGS],[
2076 dnl ** what cpp to use?
2077 dnl --------------------------------------------------------------
2078 AC_ARG_WITH(hs-cpp,
2079 [AC_HELP_STRING([--with-hs-cpp=ARG],
2080       [Path to the (C) preprocessor for Haskell files [default=autodetect]])],
2081 [
2082     if test "$HostOS" = "mingw32"
2083     then
2084         AC_MSG_WARN([Request to use $withval will be ignored])
2085     else
2086         HS_CPP_CMD=$withval
2087     fi
2088 ],
2089 [
2090
2091     # We can't use $CPP here, since HS_CPP_CMD is expected to be a single
2092     # command (no flags), and AC_PROG_CPP defines CPP as "/usr/bin/gcc -E".
2093     HS_CPP_CMD=$WhatGccIsCalled
2094
2095     SOLARIS_GCC_CPP_BROKEN=NO
2096     SOLARIS_FOUND_GOOD_CPP=NO
2097     case $host in
2098         i386-*-solaris2)
2099         GCC_MAJOR_MINOR=`$WhatGccIsCalled --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
2100         if test "$GCC_MAJOR_MINOR" != "3.4"; then
2101           # this is not 3.4.x release so with broken CPP
2102           SOLARIS_GCC_CPP_BROKEN=YES
2103         fi
2104         ;;
2105     esac
2106
2107     if test "$SOLARIS_GCC_CPP_BROKEN" = "YES"; then
2108       # let's try to find if GNU C 3.4.x is installed
2109       if test -x /usr/sfw/bin/gcc; then
2110         # something executable is in expected path so let's
2111         # see if it's really GNU C
2112         NEW_GCC_MAJOR_MINOR=`/usr/sfw/bin/gcc --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
2113         if test "$NEW_GCC_MAJOR_MINOR" = "3.4"; then
2114           # this is GNU C 3.4.x which provides non-broken CPP on Solaris
2115           # let's use it as CPP then.
2116           HS_CPP_CMD=/usr/sfw/bin/gcc
2117           SOLARIS_FOUND_GOOD_CPP=YES
2118         fi
2119       fi
2120       if test "$SOLARIS_FOUND_GOOD_CPP" = "NO"; then
2121         AC_MSG_WARN([Your GNU C provides broken CPP and you do not have GNU C 3.4.x installed.])
2122         AC_MSG_WARN([Please install GNU C 3.4.x to solve this issue. It will be used as CPP only.])
2123       fi
2124     fi
2125 ]
2126 )
2127
2128
2129
2130 dnl ** what cpp flags to use?
2131 dnl -----------------------------------------------------------
2132 AC_ARG_WITH(hs-cpp-flags,
2133   [AC_HELP_STRING([--with-hs-cpp-flags=ARG],
2134       [Flags to the (C) preprocessor for Haskell files [default=autodetect]])],
2135   [
2136       if test "$HostOS" = "mingw32"
2137       then
2138           AC_MSG_WARN([Request to use $withval will be ignored])
2139       else
2140           HS_CPP_ARGS=$withval
2141       fi
2142   ],
2143 [
2144   $HS_CPP_CMD -x c /dev/null -dM -E > conftest.txt 2>&1
2145   if grep "__clang__" conftest.txt >/dev/null 2>&1; then
2146     HS_CPP_ARGS="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
2147   else
2148       $HS_CPP_CMD  -v > conftest.txt 2>&1
2149       if  grep "gcc" conftest.txt >/dev/null 2>&1; then
2150           HS_CPP_ARGS="-E -undef -traditional"
2151         else
2152           $HS_CPP_CMD  --version > conftest.txt 2>&1
2153           if grep "cpphs" conftest.txt >/dev/null 2>&1; then
2154             HS_CPP_ARGS="--cpp -traditional"
2155           else
2156             AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
2157             HS_CPP_ARGS=""
2158           fi
2159       fi
2160   fi
2161   ]
2162 )
2163
2164 $1=$HS_CPP_CMD
2165 $2=$HS_CPP_ARGS
2166
2167 ])
2168
2169 # FP_BFD_SUPPORT()
2170 # ----------------------
2171 # whether to use libbfd for debugging RTS
2172 AC_DEFUN([FP_BFD_SUPPORT], [
2173     AC_ARG_ENABLE(bfd-debug,
2174         [AC_HELP_STRING([--enable-bfd-debug],
2175               [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
2176         [
2177             # don't pollute general LIBS environment
2178             save_LIBS="$LIBS"
2179             AC_CHECK_HEADERS([bfd.h])
2180             dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
2181             dnl    the order of these tests matters: bfd needs libiberty
2182             AC_CHECK_LIB(iberty, xmalloc)
2183             dnl 'bfd_init' is a rare non-macro in libbfd
2184             AC_CHECK_LIB(bfd,    bfd_init)
2185
2186             AC_TRY_LINK([#include <bfd.h>],
2187                         [
2188                                 /* mimic our rts/Printer.c */
2189                                 bfd* abfd;
2190                                 const char * name;
2191                                 char **matching;
2192
2193                                 name = "some.executable";
2194                                 bfd_init();
2195                                 abfd = bfd_openr(name, "default");
2196                                 bfd_check_format_matches (abfd, bfd_object, &matching);
2197                                 {
2198                                     long storage_needed;
2199                                     storage_needed = bfd_get_symtab_upper_bound (abfd);
2200                                 }
2201                                 {
2202                                     asymbol **symbol_table;
2203                                     long number_of_symbols;
2204                                     symbol_info info;
2205
2206                                     number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
2207                                     bfd_get_symbol_info(abfd,symbol_table[0],&info);
2208                                 }
2209                         ],
2210                         [],dnl bfd seems to work
2211                         [AC_MSG_ERROR([can't use 'bfd' library])])
2212             LIBS="$save_LIBS"
2213         ]
2214     )
2215 ])
2216
2217 # LocalWords:  fi