Scrap IRIX support
[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         sparc64)
200             test -z "[$]2" || eval "[$]2=ArchSPARC64"
201             ;;
202         arm)
203             GET_ARM_ISA()
204             test -z "[$]2" || eval "[$]2=\"ArchARM {armISA = \$ARM_ISA, armISAExt = \$ARM_ISA_EXT, armABI = \$ARM_ABI}\""
205             ;;
206         aarch64)
207             test -z "[$]2" || eval "[$]2=ArchARM64"
208             ;;
209         alpha)
210             test -z "[$]2" || eval "[$]2=ArchAlpha"
211             ;;
212         mips|mipseb)
213             test -z "[$]2" || eval "[$]2=ArchMipseb"
214             ;;
215         mipsel)
216             test -z "[$]2" || eval "[$]2=ArchMipsel"
217             ;;
218         hppa|hppa1_1|ia64|m68k|rs6000|s390|s390x|sh4|vax)
219             test -z "[$]2" || eval "[$]2=ArchUnknown"
220             ;;
221         *)
222             echo "Unknown arch [$]1"
223             exit 1
224             ;;
225         esac
226     }
227
228     checkVendor() {
229         case [$]1 in
230         dec|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld)
231             ;;
232         *)
233             echo "Unknown vendor [$]1"
234             exit 1
235             ;;
236         esac
237     }
238
239     checkOS() {
240         case [$]1 in
241         linux)
242             test -z "[$]2" || eval "[$]2=OSLinux"
243             ;;
244         ios)
245             test -z "[$]2" || eval "[$]2=OSiOS"
246             ;;
247         darwin)
248             test -z "[$]2" || eval "[$]2=OSDarwin"
249             ;;
250         solaris2)
251             test -z "[$]2" || eval "[$]2=OSSolaris2"
252             ;;
253         mingw32)
254             test -z "[$]2" || eval "[$]2=OSMinGW32"
255             ;;
256         freebsd)
257             test -z "[$]2" || eval "[$]2=OSFreeBSD"
258             ;;
259         dragonfly)
260             test -z "[$]2" || eval "[$]2=OSDragonFly"
261             ;;
262         kfreebsdgnu)
263             test -z "[$]2" || eval "[$]2=OSKFreeBSD"
264             ;;
265         openbsd)
266             test -z "[$]2" || eval "[$]2=OSOpenBSD"
267             ;;
268         netbsd)
269             test -z "[$]2" || eval "[$]2=OSNetBSD"
270             ;;
271         haiku)
272             test -z "[$]2" || eval "[$]2=OSHaiku"
273             ;;
274         osf3)
275             test -z "[$]2" || eval "[$]2=OSOsf3"
276             ;;
277         nto-qnx)
278             test -z "[$]2" || eval "[$]2=OSQNXNTO"
279             ;;
280         dragonfly|osf1|hpux|linuxaout|freebsd2|gnu|nextstep2|nextstep3|sunos4|ultrix)
281             test -z "[$]2" || eval "[$]2=OSUnknown"
282             ;;
283         aix)
284             test -z "[$]2" || eval "[$]2=OSAIX"
285             ;;
286         linux-android)
287             test -z "[$]2" || eval "[$]2=OSAndroid"
288             ;;
289         *)
290             echo "Unknown OS '[$]1'"
291             exit 1
292             ;;
293         esac
294     }
295
296     dnl ** check for Apple-style dead-stripping support
297     dnl    (.subsections-via-symbols assembler directive)
298
299     AC_MSG_CHECKING(for .subsections_via_symbols)
300     AC_COMPILE_IFELSE(
301         [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
302         [AC_MSG_RESULT(yes)
303          HaskellHaveSubsectionsViaSymbols=True
304          AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
305                    [Define to 1 if Apple-style dead-stripping is supported.])
306         ],
307         [HaskellHaveSubsectionsViaSymbols=False
308          AC_MSG_RESULT(no)])
309
310     dnl ** check for .ident assembler directive
311
312     AC_MSG_CHECKING(whether your assembler supports .ident directive)
313     AC_COMPILE_IFELSE(
314         [AC_LANG_SOURCE([__asm__ (".ident \"GHC x.y.z\"");])],
315         [AC_MSG_RESULT(yes)
316          HaskellHaveIdentDirective=True],
317         [AC_MSG_RESULT(no)
318          HaskellHaveIdentDirective=False])
319
320     dnl *** check for GNU non-executable stack note support (ELF only)
321     dnl     (.section .note.GNU-stack,"",@progbits)
322
323     dnl This test doesn't work with "gcc -g" in gcc 4.4 (GHC trac #3889:
324     dnl     Error: can't resolve `.note.GNU-stack' {.note.GNU-stack section} - `.Ltext0' {.text section}
325     dnl so we empty CFLAGS while running this test
326     CFLAGS2="$CFLAGS"
327     CFLAGS=
328     AC_MSG_CHECKING(for GNU non-executable stack support)
329     AC_COMPILE_IFELSE(
330         [AC_LANG_PROGRAM([__asm__ (".section .note.GNU-stack,\"\",@progbits");], [0])],
331         [AC_MSG_RESULT(yes)
332          HaskellHaveGnuNonexecStack=True],
333         [AC_MSG_RESULT(no)
334          HaskellHaveGnuNonexecStack=False])
335     CFLAGS="$CFLAGS2"
336
337     checkArch "$BuildArch" "HaskellBuildArch"
338     checkVendor "$BuildVendor"
339     checkOS "$BuildOS" ""
340
341     checkArch "$HostArch" "HaskellHostArch"
342     checkVendor "$HostVendor"
343     checkOS "$HostOS" ""
344
345     checkArch "$TargetArch" "HaskellTargetArch"
346     checkVendor "$TargetVendor"
347     checkOS "$TargetOS" "HaskellTargetOs"
348
349     AC_SUBST(HaskellTargetArch)
350     AC_SUBST(HaskellTargetOs)
351     AC_SUBST(HaskellHaveSubsectionsViaSymbols)
352     AC_SUBST(HaskellHaveIdentDirective)
353     AC_SUBST(HaskellHaveGnuNonexecStack)
354 ])
355
356
357 # GET_ARM_ISA
358 # ----------------------------------
359 # Get info about the ISA on the ARM arch
360 AC_DEFUN([GET_ARM_ISA],
361 [
362     AC_COMPILE_IFELSE([
363         AC_LANG_PROGRAM(
364             [],
365             [#if defined(__ARM_ARCH_2__)  || \
366                  defined(__ARM_ARCH_3__)  || \
367                  defined(__ARM_ARCH_3M__) || \
368                  defined(__ARM_ARCH_4__)  || \
369                  defined(__ARM_ARCH_4T__) || \
370                  defined(__ARM_ARCH_5__)  || \
371                  defined(__ARM_ARCH_5T__) || \
372                  defined(__ARM_ARCH_5E__) || \
373                  defined(__ARM_ARCH_5TE__)
374                  return 0;
375              #else
376                  not pre arm v6
377              #endif]
378         )],
379         [AC_DEFINE(arm_HOST_ARCH_PRE_ARMv6, 1, [ARM pre v6])
380          AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
381          changequote(, )dnl
382          ARM_ISA=ARMv5
383          ARM_ISA_EXT="[]"
384          changequote([, ])dnl
385         ],
386         [
387             AC_COMPILE_IFELSE([
388                 AC_LANG_PROGRAM(
389                     [],
390                     [#if defined(__ARM_ARCH_6__)   || \
391                          defined(__ARM_ARCH_6J__)  || \
392                          defined(__ARM_ARCH_6T2__) || \
393                          defined(__ARM_ARCH_6Z__)  || \
394                          defined(__ARM_ARCH_6ZK__) || \
395                          defined(__ARM_ARCH_6M__)
396                          return 0;
397                      #else
398                          not pre arm v7
399                      #endif]
400                 )],
401                 [AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
402                  ARM_ISA=ARMv6
403                  AC_COMPILE_IFELSE([
404                         AC_LANG_PROGRAM(
405                                 [],
406                                 [#if defined(__VFP_FP__)
407                                      return 0;
408                                 #else
409                                      no vfp
410                                 #endif]
411                         )],
412                         [changequote(, )dnl
413                          ARM_ISA_EXT="[VFPv2]"
414                          changequote([, ])dnl
415                         ],
416                         [changequote(, )dnl
417                          ARM_ISA_EXT="[]"
418                          changequote([, ])dnl
419                         ]
420                 )],
421                 [changequote(, )dnl
422                  ARM_ISA=ARMv7
423                  ARM_ISA_EXT="[VFPv3,NEON]"
424                  changequote([, ])dnl
425                 ])
426         ])
427
428         AC_COMPILE_IFELSE(
429                [AC_LANG_PROGRAM(
430                        [],
431                        [#if defined(__SOFTFP__)
432                             return 0;
433                        #else
434                             not softfp
435                        #endif]
436                )],
437                [changequote(, )dnl
438                 ARM_ABI="SOFT"
439                 changequote([, ])dnl
440                ],
441                [AC_COMPILE_IFELSE(
442                     [AC_LANG_PROGRAM(
443                        [],
444                        [#if defined(__ARM_PCS_VFP)
445                             return 0;
446                        #else
447                             no hard float ABI
448                        #endif]
449                     )],
450                     [ARM_ABI="HARD"],
451                     [ARM_ABI="SOFTFP"]
452                )]
453         )
454
455         AC_SUBST(ARM_ISA)
456 ])
457
458
459 # FP_SETTINGS
460 # ----------------------------------
461 # Set the variables used in the settings file
462 AC_DEFUN([FP_SETTINGS],
463 [
464     if test "$windows" = YES
465     then
466         mingw_bin_prefix=mingw/bin/
467         SettingsCCompilerCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
468         SettingsHaskellCPPCommand="\$topdir/../${mingw_bin_prefix}gcc.exe"
469         SettingsHaskellCPPFlags="$HaskellCPPArgs"
470         SettingsLdCommand="\$topdir/../${mingw_bin_prefix}ld.exe"
471         SettingsArCommand="\$topdir/../${mingw_bin_prefix}ar.exe"
472         SettingsPerlCommand='$topdir/../perl/perl.exe'
473         SettingsDllWrapCommand="\$topdir/../${mingw_bin_prefix}dllwrap.exe"
474         SettingsWindresCommand="\$topdir/../${mingw_bin_prefix}windres.exe"
475         SettingsTouchCommand='$topdir/bin/touchy.exe'
476     else
477         SettingsCCompilerCommand="$WhatGccIsCalled"
478         SettingsHaskellCPPCommand="$HaskellCPPCmd"
479         SettingsHaskellCPPFlags="$HaskellCPPArgs"
480         SettingsLdCommand="$LdCmd"
481         SettingsArCommand="$ArCmd"
482         SettingsPerlCommand="$PerlCmd"
483         SettingsDllWrapCommand="/bin/false"
484         SettingsWindresCommand="/bin/false"
485         SettingsLibtoolCommand="libtool"
486         SettingsTouchCommand='touch'
487     fi
488     if test -z "$LlcCmd"
489     then
490       SettingsLlcCommand="llc"
491     else
492       SettingsLlcCommand="$LlcCmd"
493     fi
494     if test -z "$OptCmd"
495     then
496       SettingsOptCommand="opt"
497     else
498       SettingsOptCommand="$OptCmd"
499     fi
500     SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
501     SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
502     SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
503     AC_SUBST(SettingsCCompilerCommand)
504     AC_SUBST(SettingsHaskellCPPCommand)
505     AC_SUBST(SettingsHaskellCPPFlags)
506     AC_SUBST(SettingsCCompilerFlags)
507     AC_SUBST(SettingsCCompilerLinkFlags)
508     AC_SUBST(SettingsLdCommand)
509     AC_SUBST(SettingsLdFlags)
510     AC_SUBST(SettingsArCommand)
511     AC_SUBST(SettingsPerlCommand)
512     AC_SUBST(SettingsDllWrapCommand)
513     AC_SUBST(SettingsWindresCommand)
514     AC_SUBST(SettingsLibtoolCommand)
515     AC_SUBST(SettingsTouchCommand)
516     AC_SUBST(SettingsLlcCommand)
517     AC_SUBST(SettingsOptCommand)
518 ])
519
520
521 # FPTOOLS_SET_C_LD_FLAGS
522 # ----------------------------------
523 # Set the C, LD and CPP flags for a given platform
524 # $1 is the platform
525 # $2 is the name of the CC flags variable
526 # $3 is the name of the linker flags variable when linking with gcc
527 # $4 is the name of the linker flags variable when linking with ld
528 # $5 is the name of the CPP flags variable
529 AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
530 [
531     AC_MSG_CHECKING([Setting up $2, $3, $4 and $5])
532     case $$1 in
533     i386-*)
534         # Workaround for #7799
535         $2="$$2 -U__i686"
536         ;;
537     esac
538
539     case $$1 in
540     i386-unknown-mingw32)
541         $2="$$2 -march=i686"
542         ;;
543     i386-portbld-freebsd*)
544         $2="$$2 -march=i686"
545         ;;
546     i386-apple-darwin)
547         $2="$$2 -m32"
548         $3="$$3 -m32"
549         $4="$$4 -arch i386"
550         $5="$$5 -m32"
551         ;;
552     x86_64-apple-darwin)
553         $2="$$2 -m64"
554         $3="$$3 -m64"
555         $4="$$4 -arch x86_64"
556         $5="$$5 -m64"
557         ;;
558     x86_64-unknown-solaris2)
559         $2="$$2 -m64"
560         $3="$$3 -m64"
561         $4="$$4 -m64"
562         $5="$$5 -m64"
563         ;;
564     alpha-*)
565         # For now, to suppress the gcc warning "call-clobbered
566         # register used for global register variable", we simply
567         # disable all warnings altogether using the -w flag. Oh well.
568         $2="$$2 -w -mieee -D_REENTRANT"
569         $3="$$3 -w -mieee -D_REENTRANT"
570         $5="$$5 -w -mieee -D_REENTRANT"
571         ;;
572     hppa*)
573         # ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi!
574         # (very nice, but too bad the HP /usr/include files don't agree.)
575         $2="$$2 -D_HPUX_SOURCE"
576         $3="$$3 -D_HPUX_SOURCE"
577         $5="$$5 -D_HPUX_SOURCE"
578         ;;
579     arm*linux*)
580         # On arm/linux and arm/android, tell gcc to generate Arm
581         # instructions (ie not Thumb) and to link using the gold linker.
582         # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
583         $2="$$2 -marm"
584         $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
585         $4="$$4 -z noexecstack"
586         ;;
587
588     aarch64*linux*)
589         # On aarch64/linux and aarch64/android, tell gcc to link using the
590         # gold linker.
591         # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
592         $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
593         $4="$$4 -z noexecstack"
594         ;;
595
596     powerpc-ibm-aix*)
597         # We need `-D_THREAD_SAFE` to unlock the thread-local `errno`.
598         $2="$$2 -D_THREAD_SAFE"
599         $3="$$3 -D_THREAD_SAFE -Wl,-bnotextro"
600         $4="$$4 -bnotextro"
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  FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-ge], [4.0],
1440   [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fno-builtin"],
1441   [])
1442 ])
1443 AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts)
1444 ])
1445
1446
1447 # FP_SETUP_PROJECT_VERSION
1448 # ---------------------
1449 AC_DEFUN([FP_SETUP_PROJECT_VERSION],
1450 [
1451 if test "$RELEASE" = "NO"; then
1452     AC_MSG_CHECKING([for GHC version date])
1453     if test -f VERSION_DATE; then
1454         PACKAGE_VERSION=${PACKAGE_VERSION}.`cat VERSION_DATE`
1455         AC_MSG_RESULT(given $PACKAGE_VERSION)
1456     elif test -d .git; then
1457         changequote(, )dnl
1458         ver_posixtime=`git log -1 --pretty=format:%ct`
1459         ver_date=`perl -MPOSIX -e "print strftime('%Y%m%d', gmtime($ver_posixtime));"`
1460         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
1461         changequote([, ])dnl
1462                 AC_MSG_ERROR([failed to detect version date: check that git and perl are in your path])
1463         fi
1464         PACKAGE_VERSION=${PACKAGE_VERSION}.$ver_date
1465         AC_MSG_RESULT(inferred $PACKAGE_VERSION)
1466     elif test -f VERSION; then
1467         PACKAGE_VERSION=`cat VERSION`
1468         AC_MSG_RESULT(given $PACKAGE_VERSION)
1469     else
1470         AC_MSG_WARN([cannot determine snapshot version: no .git directory and no VERSION file])
1471         dnl We'd really rather this case didn't happen, but it might
1472         dnl do (in particular, people using lndir trees may find that
1473         dnl the build system can't find any other date). If it does
1474         dnl happen, then we use the current date.
1475         dnl This way we get some idea about how recent a build is.
1476         dnl It also means that packages built for 2 different builds
1477         dnl will probably use different version numbers, so things are
1478         dnl less likely to go wrong.
1479         PACKAGE_VERSION=${PACKAGE_VERSION}.`date +%Y%m%d`
1480     fi
1481 fi
1482
1483     AC_MSG_CHECKING([for GHC Git commit id])
1484     if test -d .git; then
1485         git_commit_id=`git rev-parse HEAD`
1486         if test -n "$git_commit_id" 2>&1 >/dev/null; then true; else
1487             AC_MSG_ERROR([failed to detect revision: check that git is in your path])
1488         fi
1489         PACKAGE_GIT_COMMIT_ID=$git_commit_id
1490         AC_MSG_RESULT(inferred $PACKAGE_GIT_COMMIT_ID)
1491     elif test -f GIT_COMMIT_ID; then
1492         PACKAGE_GIT_COMMIT_ID=`cat GIT_COMMIT_ID`
1493         AC_MSG_RESULT(given $PACKAGE_GIT_COMMIT_ID)
1494     else
1495         AC_MSG_WARN([cannot determine snapshot revision: no .git directory and no 'GIT_COMMIT_ID' file])
1496         PACKAGE_GIT_COMMIT_ID="0000000000000000000000000000000000000000"
1497     fi
1498
1499
1500 # Some renamings
1501 AC_SUBST([ProjectName], [$PACKAGE_NAME])
1502 AC_SUBST([ProjectVersion], [$PACKAGE_VERSION])
1503 AC_SUBST([ProjectGitCommitId], [$PACKAGE_GIT_COMMIT_ID])
1504
1505 # Split PACKAGE_VERSION into (possibly empty) parts
1506 VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
1507 VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
1508 VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
1509 ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
1510
1511 # Calculate project version as an integer, using 2 digits for minor version
1512 case $VERSION_MINOR in
1513   ?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;
1514   ??) ProjectVersionInt=${VERSION_MAJOR}${VERSION_MINOR} ;;
1515   *) AC_MSG_ERROR([bad minor version in $PACKAGE_VERSION]) ;;
1516 esac
1517 AC_SUBST([ProjectVersionInt])
1518
1519 # The project patchlevel is zero unless stated otherwise
1520 test -z "$ProjectPatchLevel" && ProjectPatchLevel=0
1521
1522 # Save split version of ProjectPatchLevel
1523 ProjectPatchLevel1=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1/'`
1524 ProjectPatchLevel2=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3/'`
1525
1526 AC_SUBST([ProjectPatchLevel1])
1527 AC_SUBST([ProjectPatchLevel2])
1528
1529 # Remove dots from the patch level; this allows us to have versions like 6.4.1.20050508
1530 ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'`
1531
1532 AC_SUBST([ProjectPatchLevel])
1533
1534 # The version of the GHC package changes every day, since the
1535 # patchlevel is the current date.  We don't want to force
1536 # recompilation of the entire compiler when this happens, so for
1537 # GHC HEAD we omit the patchlevel from the package version number.
1538 #
1539 # The ProjectPatchLevel1 > 20000000 iff GHC HEAD. If it's for a stable
1540 # release like 7.10.1 or for a release candidate such as 7.10.1.20141224
1541 # then we don't omit the patchlevel components.
1542
1543 ProjectVersionMunged="$ProjectVersion"
1544 if test "$ProjectPatchLevel1" -gt 20000000; then
1545   ProjectVersionMunged="${VERSION_MAJOR}.${VERSION_MINOR}"
1546 fi
1547 AC_SUBST([ProjectVersionMunged])
1548 ])# FP_SETUP_PROJECT_VERSION
1549
1550 # Check for a working timer_create().  We need a pretty detailed check
1551 # here, because there exist partially-working implementations of
1552 # timer_create() in certain versions of Linux (see bug #1933).
1553 #
1554 AC_DEFUN([FP_CHECK_TIMER_CREATE],[
1555 AC_CHECK_FUNC([timer_create],[HAVE_timer_create=yes],[HAVE_timer_create=no])
1556
1557 if test "$HAVE_timer_create" = "yes"
1558 then
1559   if test "$cross_compiling" = "yes"
1560   then
1561     # We can't test timer_create when we're cross-compiling, so we
1562     # optimistiaclly assume that it actually works properly.
1563     AC_DEFINE([USE_TIMER_CREATE], 1,  [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)])
1564   else
1565   AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
1566     [fptools_cv_timer_create_works],
1567     [AC_TRY_RUN([
1568 #include <stdio.h>
1569 #ifdef HAVE_STDLIB_H
1570 #include <stdlib.h>
1571 #endif
1572 #ifdef HAVE_TIME_H
1573 #include <time.h>
1574 #endif
1575 #ifdef HAVE_SIGNAL_H
1576 #include <signal.h>
1577 #endif
1578 #ifdef HAVE_UNISTD_H
1579 #include <unistd.h>
1580 #endif
1581
1582 static volatile int tock = 0;
1583 static void handler(int i)
1584 {
1585    tock = 1;
1586 }
1587
1588 static void timeout(int i)
1589 {
1590   // timer_settime() has been known to hang, so just in case
1591   // we install a 1-second timeout (see #2257)
1592   exit(99);
1593 }
1594
1595 int main(int argc, char *argv[])
1596 {
1597
1598     struct sigevent ev;
1599     timer_t timer;
1600     struct itimerspec it;
1601     struct sigaction action;
1602     int m,n,count = 0;
1603
1604     ev.sigev_notify = SIGEV_SIGNAL;
1605     ev.sigev_signo  = SIGVTALRM;
1606
1607     action.sa_handler = handler;
1608     action.sa_flags = 0;
1609     sigemptyset(&action.sa_mask);
1610     if (sigaction(SIGVTALRM, &action, NULL) == -1) {
1611         fprintf(stderr,"SIGVTALRM problem\n");
1612         exit(3);
1613     }
1614
1615     action.sa_handler = timeout;
1616     action.sa_flags = 0;
1617     sigemptyset(&action.sa_mask);
1618     if (sigaction(SIGALRM, &action, NULL) == -1) {
1619       fprintf(stderr,"SIGALRM problem\n");
1620       exit(3);
1621     }
1622     alarm(1);
1623
1624     if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
1625         fprintf(stderr,"No CLOCK_REALTIME timer\n");
1626         exit(2);
1627     }
1628
1629     tock = 0;
1630
1631     it.it_value.tv_sec = 0;
1632     it.it_value.tv_nsec = 1000000; // 1ms
1633     it.it_interval = it.it_value;
1634     if (timer_settime(timer, 0, &it, NULL) != 0) {
1635         fprintf(stderr,"settime problem\n");
1636         exit(4);
1637     }
1638
1639     // some environments have coarse scheduler/timer granularity of ~10ms and worse
1640     usleep(100000); // 100ms
1641
1642     if (!tock) {
1643         fprintf(stderr,"no CLOCK_REALTIME signal\n");
1644         exit(5);
1645     }
1646
1647     timer_delete(timer);
1648
1649     exit(0);
1650 }
1651      ],
1652      [fptools_cv_timer_create_works=yes],
1653      [fptools_cv_timer_create_works=no])
1654   ])
1655 case $fptools_cv_timer_create_works in
1656     yes) AC_DEFINE([USE_TIMER_CREATE], 1,
1657                    [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
1658 esac
1659   fi
1660 fi
1661 ])
1662
1663 # FP_ICONV
1664 # -------------
1665 AC_DEFUN([FP_ICONV],
1666 [
1667   dnl--------------------------------------------------------------------
1668   dnl * Deal with arguments telling us iconv is somewhere odd
1669   dnl--------------------------------------------------------------------
1670
1671   dnl Note: ICONV_LIB_DIRS and ICONV_INCLUDE_DIRS are not predefined
1672   dnl to the empty string to allow them to be overridden from the
1673   dnl environment.
1674
1675   AC_ARG_WITH([iconv-includes],
1676     [AC_HELP_STRING([--with-iconv-includes],
1677       [directory containing iconv.h])],
1678       [ICONV_INCLUDE_DIRS=$withval])
1679
1680   AC_ARG_WITH([iconv-libraries],
1681     [AC_HELP_STRING([--with-iconv-libraries],
1682       [directory containing iconv library])],
1683       [ICONV_LIB_DIRS=$withval])
1684
1685   AC_SUBST(ICONV_INCLUDE_DIRS)
1686   AC_SUBST(ICONV_LIB_DIRS)
1687 ])# FP_ICONV
1688
1689 # FP_GMP
1690 # -------------
1691 AC_DEFUN([FP_GMP],
1692 [
1693   dnl--------------------------------------------------------------------
1694   dnl * Deal with arguments telling us gmp is somewhere odd
1695   dnl--------------------------------------------------------------------
1696
1697   AC_ARG_WITH([gmp-includes],
1698     [AC_HELP_STRING([--with-gmp-includes],
1699       [directory containing gmp.h])],
1700       [GMP_INCLUDE_DIRS=$withval])
1701
1702   AC_ARG_WITH([gmp-libraries],
1703     [AC_HELP_STRING([--with-gmp-libraries],
1704       [directory containing gmp library])],
1705       [GMP_LIB_DIRS=$withval])
1706
1707   AC_SUBST(GMP_INCLUDE_DIRS)
1708   AC_SUBST(GMP_LIB_DIRS)
1709 ])# FP_GMP
1710
1711 # FP_CURSES
1712 # -------------
1713 AC_DEFUN([FP_CURSES],
1714 [
1715   dnl--------------------------------------------------------------------
1716   dnl * Deal with arguments telling us curses is somewhere odd
1717   dnl--------------------------------------------------------------------
1718
1719   AC_ARG_WITH([curses-includes],
1720     [AC_HELP_STRING([--with-curses-includes],
1721       [directory containing curses headers])],
1722       [CURSES_INCLUDE_DIRS=$withval])
1723
1724   AC_ARG_WITH([curses-libraries],
1725     [AC_HELP_STRING([--with-curses-libraries],
1726       [directory containing curses libraries])],
1727       [CURSES_LIB_DIRS=$withval])
1728
1729   AC_SUBST(CURSES_INCLUDE_DIRS)
1730   AC_SUBST(CURSES_LIB_DIRS)
1731 ])# FP_CURSES
1732
1733 # --------------------------------------------------------------
1734 # Calculate absolute path to build tree
1735 # --------------------------------------------------------------
1736
1737 AC_DEFUN([FP_FIND_ROOT],[
1738 AC_MSG_CHECKING(for path to top of build tree)
1739     if test "$windows" = YES
1740     then
1741       dnl Make sure this is a c:/foo/bar (mixed) style path. Some parts of
1742       dnl the build system might depend on it (such as the sed expression
1743       dnl `"s|$(TOP)/||i"` in addCFileDeps in rules/build-dependencies.mk).
1744       hardtop=$(cygpath -m "$(pwd)")
1745     else
1746       hardtop=$(pwd)
1747     fi
1748
1749     dnl Remove common automounter nonsense
1750     hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|'`
1751
1752     if ! test -d "$hardtop"; then
1753         AC_MSG_ERROR([cannot determine current directory])
1754     fi
1755
1756     dnl We don't support building in directories with spaces.
1757     case "$hardtop" in
1758     *' '*)
1759         AC_MSG_ERROR([
1760         The build system does not support building in a directory
1761         containing space characters.
1762         Suggestion: move the build tree somewhere else.])
1763         ;;
1764     esac
1765
1766     AC_SUBST(hardtop)
1767
1768     AC_MSG_RESULT($hardtop)
1769 ])
1770
1771 # GHC_CONVERT_CPU(cpu, target_var)
1772 # --------------------------------
1773 # converts cpu from gnu to ghc naming, and assigns the result to $target_var
1774 AC_DEFUN([GHC_CONVERT_CPU],[
1775 case "$1" in
1776   aarch64*)
1777     $2="aarch64"
1778     ;;
1779   alpha*)
1780     $2="alpha"
1781     ;;
1782   arm*)
1783     $2="arm"
1784     ;;
1785   hppa1.1*)
1786     $2="hppa1_1"
1787     ;;
1788   hppa*)
1789     $2="hppa"
1790     ;;
1791   i386|i486|i586|i686)
1792     $2="i386"
1793     ;;
1794   ia64)
1795     $2="ia64"
1796     ;;
1797   m68k*)
1798     $2="m68k"
1799     ;;
1800   mipseb*)
1801     $2="mipseb"
1802     ;;
1803   mipsel*)
1804     $2="mipsel"
1805     ;;
1806   mips*)
1807     $2="mips"
1808     ;;
1809   powerpc64le*)
1810     $2="powerpc64le"
1811     ;;
1812   powerpc64*)
1813     $2="powerpc64"
1814     ;;
1815   powerpc*)
1816     $2="powerpc"
1817     ;;
1818   rs6000)
1819     $2="rs6000"
1820     ;;
1821   s390x*)
1822     $2="s390x"
1823     ;;
1824   s390*)
1825     $2="s390"
1826     ;;
1827   sh4)
1828     $2="sh4"
1829     ;;
1830   sparc64*)
1831     $2="sparc64"
1832     ;;
1833   sparc*)
1834     $2="sparc"
1835     ;;
1836   vax)
1837     $2="vax"
1838     ;;
1839   x86_64|amd64)
1840     $2="x86_64"
1841     ;;
1842   *)
1843     echo "Unknown CPU $1"
1844     exit 1
1845     ;;
1846   esac
1847 ])
1848
1849 # GHC_CONVERT_VENDOR(vendor, target_var)
1850 # --------------------------------
1851 # converts vendor from gnu to ghc naming, and assigns the result to $target_var
1852 AC_DEFUN([GHC_CONVERT_VENDOR],[
1853   case "$1" in
1854   pc|gentoo|w64) # like i686-pc-linux-gnu, i686-gentoo-freebsd8, x86_64-w64-mingw32
1855     $2="unknown"
1856     ;;
1857   softfloat) # like armv5tel-softfloat-linux-gnueabi
1858     $2="unknown"
1859     ;;
1860   hardfloat) # like armv7a-hardfloat-linux-gnueabi
1861     $2="unknown"
1862     ;;
1863   *)
1864     #pass thru by default
1865     $2="$1"
1866     ;;
1867   esac
1868 ])
1869
1870 # GHC_CONVERT_OS(os, converted_cpu, target_var)
1871 # --------------------------------
1872 # converts os from gnu to ghc naming, and assigns the result to $target_var
1873 AC_DEFUN([GHC_CONVERT_OS],[
1874 case "$1-$2" in
1875   darwin10-arm|darwin11-i386|darwin14-aarch64)
1876     $3="ios"
1877     ;;
1878   *)
1879     case "$1" in
1880       linux-android*)
1881         $3="linux-android"
1882         ;;
1883       linux-*|linux)
1884         $3="linux"
1885         ;;
1886       # As far as I'm aware, none of these have relevant variants
1887       freebsd|netbsd|openbsd|dragonfly|osf1|osf3|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|haiku)
1888         $3="$1"
1889         ;;
1890       aix*) # e.g. powerpc-ibm-aix7.1.3.0
1891         $3="aix"
1892         ;;
1893       freebsd*) # like i686-gentoo-freebsd7
1894                 #      i686-gentoo-freebsd8
1895                 #      i686-gentoo-freebsd8.2
1896         $3="freebsd"
1897         ;;
1898       nto-qnx*)
1899         $3="nto-qnx"
1900         ;;
1901       *)
1902         echo "Unknown OS $1"
1903         exit 1
1904         ;;
1905       esac
1906       ;;
1907   esac
1908 ])
1909
1910 # BOOTSTRAPPING_GHC_INFO_FIELD
1911 # --------------------------------
1912 # Set the variable $1 to the value of the ghc --info field $2.
1913 AC_DEFUN([BOOTSTRAPPING_GHC_INFO_FIELD],[
1914 $1=`"$WithGhc" --info | grep "^ ,(\"$2\"," | sed -e 's/.*","//' -e 's/")$//'`
1915 tmp=${$1#\$topdir/}
1916 if test "${$1}" != "$tmp"
1917 then
1918     topdir=`"$WithGhc" --print-libdir | sed 's#\\\\#/#g'`
1919     $1="$topdir/$tmp"
1920 fi
1921 AC_SUBST($1)
1922 ])
1923
1924 # LIBRARY_VERSION(lib, [dir])
1925 # --------------------------------
1926 # Gets the version number of a library.
1927 # If $1 is ghc-prim, then we define LIBRARY_ghc_prim_VERSION as 1.2.3
1928 # $2 points to the directory under libraries/
1929 AC_DEFUN([LIBRARY_VERSION],[
1930 dir=m4_default([$2],[$1])
1931 LIBRARY_[]translit([$1], [-], [_])[]_VERSION=`grep -i "^version:" libraries/${dir}/$1.cabal | sed "s/.* //"`
1932 AC_SUBST(LIBRARY_[]translit([$1], [-], [_])[]_VERSION)
1933 ])
1934
1935 # XCODE_VERSION()
1936 # --------------------------------
1937 # Gets the version number of XCode, if on a Mac
1938 AC_DEFUN([XCODE_VERSION],[
1939     if test "$TargetOS_CPP" = "darwin"
1940     then
1941         AC_MSG_CHECKING(XCode version)
1942         XCodeVersion=`xcodebuild -version | grep Xcode | sed "s/Xcode //"`
1943         # Old XCode versions don't actually give the XCode version
1944         if test "$XCodeVersion" = ""
1945         then
1946             AC_MSG_RESULT(not found (too old?))
1947             XCodeVersion1=0
1948             XCodeVersion2=0
1949         else
1950             AC_MSG_RESULT($XCodeVersion)
1951             XCodeVersion1=`echo "$XCodeVersion" | sed 's/\..*//'`
1952             changequote(, )dnl
1953             XCodeVersion2=`echo "$XCodeVersion" | sed 's/[^.]*\.\([^.]*\).*/\1/'`
1954             changequote([, ])dnl
1955             AC_MSG_NOTICE(XCode version component 1: $XCodeVersion1)
1956             AC_MSG_NOTICE(XCode version component 2: $XCodeVersion2)
1957         fi
1958     fi
1959 ])
1960
1961 # FIND_LLVM_PROG()
1962 # --------------------------------
1963 # Find where the llvm tools are. We have a special function to handle when they
1964 # are installed with a version suffix (e.g., llc-3.1).
1965 #
1966 # $1 = the variable to set
1967 # $2 = the with option name
1968 # $3 = the command to look for
1969 # $4 = the version of the command to look for
1970 #
1971 AC_DEFUN([FIND_LLVM_PROG],[
1972     # Test for program with version name.
1973     FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3-$4])
1974     if test -z "$$1"; then
1975         # Test for program without version name.
1976         FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3])
1977         if test -n "$$1"; then
1978             AC_MSG_CHECKING([$$1 is version $4])
1979             if test `$$1 --version | grep -c "version $4"` -gt 0 ; then
1980                 AC_MSG_RESULT(yes)
1981             else
1982                 AC_MSG_RESULT(no)
1983                 $1=""
1984             fi
1985         fi
1986     fi
1987 ])
1988
1989 # FIND_LD
1990 # Find the version of `ld` to use. This is used in both in the top level
1991 # configure.ac and in distrib/configure.ac.in.
1992 #
1993 # $1 = the variable to set
1994 #
1995 AC_DEFUN([FIND_LD],[
1996     FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
1997     case $target in
1998         arm*linux*       | \
1999         aarch64*linux*   )
2000             # Arm and Aarch64 requires use of the binutils ld.gold linker.
2001             # This case should catch at least arm-unknown-linux-gnueabihf,
2002             # arm-linux-androideabi, arm64-unknown-linux and
2003             # aarch64-linux-android
2004             FP_ARG_WITH_PATH_GNU_PROG([LD_GOLD], [ld.gold], [ld.gold])
2005             $1="$LD_GOLD"
2006             ;;
2007         *)
2008             $1="$LD"
2009             ;;
2010     esac
2011 ])
2012
2013 # FIND_GHC_BOOTSTRAP_PROG()
2014 # --------------------------------
2015 # Parse the bootstrap GHC's compier settings file for the location of things
2016 # like the `llc` and `opt` commands.
2017 #
2018 # $1 = the variable to set
2019 # $2 = The bootstrap compiler.
2020 # $3 = The string to grep for to find the correct line.
2021 #
2022 AC_DEFUN([FIND_GHC_BOOTSTRAP_PROG],[
2023     BootstrapTmpCmd=`grep $3 $($2 --print-libdir)/settings 2>/dev/null | sed 's/.*", "//;s/".*//'`
2024     if test -n "$BootstrapTmpCmd" && test `basename $BootstrapTmpCmd` = $BootstrapTmpCmd ; then
2025         AC_PATH_PROG([$1], [$BootstrapTmpCmd], "")
2026     else
2027         $1=$BootstrapTmpCmd
2028     fi
2029 ])
2030
2031
2032 # FIND_GCC()
2033 # --------------------------------
2034 # Finds where gcc is
2035 #
2036 # $1 = the variable to set
2037 # $2 = the with option name
2038 # $3 = the command to look for
2039 AC_DEFUN([FIND_GCC],[
2040     if test "$TargetOS_CPP" = "darwin" &&
2041        test "$XCodeVersion1" -eq 4 &&
2042        test "$XCodeVersion2" -lt 2
2043     then
2044         # In Xcode 4.1, 'gcc-4.2' is the gcc legacy backend (rather
2045         # than the LLVM backend). We prefer the legacy gcc, but in
2046         # Xcode 4.2 'gcc-4.2' was removed.
2047         FP_ARG_WITH_PATH_GNU_PROG([$1], [gcc-4.2], [gcc-4.2])
2048     elif test "$windows" = YES
2049     then
2050         $1="$CC"
2051     else
2052         FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [$2], [$3])
2053         # From Xcode 5 on/, OS X command line tools do not include gcc
2054         # anymore. Use clang.
2055         if test -z "$$1"
2056         then
2057             FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL([$1], [clang], [clang])
2058         fi
2059         if test -z "$$1"
2060         then
2061             AC_MSG_ERROR([cannot find $3 nor clang in your PATH])
2062         fi
2063     fi
2064     AC_SUBST($1)
2065 ])
2066
2067 AC_DEFUN([MAYBE_OVERRIDE_STAGE0],[
2068   if test ! -z "$With_$1" -a "$CrossCompiling" != "YES"; then
2069       AC_MSG_NOTICE([Not cross-compiling, so --with-$1 also sets $2])
2070       $2=$With_$1
2071   fi
2072 ])
2073
2074
2075 # FP_CPP_CMD_WITH_ARGS()
2076 # ----------------------
2077 # sets CPP command and its arguments
2078 #
2079 # $1 = the variable to set to CPP command
2080 # $2 = the varibale to set to CPP command arguments
2081
2082 AC_DEFUN([FP_CPP_CMD_WITH_ARGS],[
2083 dnl ** what cpp to use?
2084 dnl --------------------------------------------------------------
2085 AC_ARG_WITH(hs-cpp,
2086 [AC_HELP_STRING([--with-hs-cpp=ARG],
2087       [Path to the (C) preprocessor for Haskell files [default=autodetect]])],
2088 [
2089     if test "$HostOS" = "mingw32"
2090     then
2091         AC_MSG_WARN([Request to use $withval will be ignored])
2092     else
2093         HS_CPP_CMD=$withval
2094     fi
2095 ],
2096 [
2097
2098     # We can't use $CPP here, since HS_CPP_CMD is expected to be a single
2099     # command (no flags), and AC_PROG_CPP defines CPP as "/usr/bin/gcc -E".
2100     HS_CPP_CMD=$WhatGccIsCalled
2101
2102     SOLARIS_GCC_CPP_BROKEN=NO
2103     SOLARIS_FOUND_GOOD_CPP=NO
2104     case $host in
2105         i386-*-solaris2)
2106         GCC_MAJOR_MINOR=`$WhatGccIsCalled --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
2107         if test "$GCC_MAJOR_MINOR" != "3.4"; then
2108           # this is not 3.4.x release so with broken CPP
2109           SOLARIS_GCC_CPP_BROKEN=YES
2110         fi
2111         ;;
2112     esac
2113
2114     if test "$SOLARIS_GCC_CPP_BROKEN" = "YES"; then
2115       # let's try to find if GNU C 3.4.x is installed
2116       if test -x /usr/sfw/bin/gcc; then
2117         # something executable is in expected path so let's
2118         # see if it's really GNU C
2119         NEW_GCC_MAJOR_MINOR=`/usr/sfw/bin/gcc --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
2120         if test "$NEW_GCC_MAJOR_MINOR" = "3.4"; then
2121           # this is GNU C 3.4.x which provides non-broken CPP on Solaris
2122           # let's use it as CPP then.
2123           HS_CPP_CMD=/usr/sfw/bin/gcc
2124           SOLARIS_FOUND_GOOD_CPP=YES
2125         fi
2126       fi
2127       if test "$SOLARIS_FOUND_GOOD_CPP" = "NO"; then
2128         AC_MSG_WARN([Your GNU C provides broken CPP and you do not have GNU C 3.4.x installed.])
2129         AC_MSG_WARN([Please install GNU C 3.4.x to solve this issue. It will be used as CPP only.])
2130       fi
2131     fi
2132 ]
2133 )
2134
2135
2136
2137 dnl ** what cpp flags to use?
2138 dnl -----------------------------------------------------------
2139 AC_ARG_WITH(hs-cpp-flags,
2140   [AC_HELP_STRING([--with-hs-cpp-flags=ARG],
2141       [Flags to the (C) preprocessor for Haskell files [default=autodetect]])],
2142   [
2143       if test "$HostOS" = "mingw32"
2144       then
2145           AC_MSG_WARN([Request to use $withval will be ignored])
2146       else
2147           HS_CPP_ARGS=$withval
2148       fi
2149   ],
2150 [
2151   $HS_CPP_CMD -x c /dev/null -dM -E > conftest.txt 2>&1
2152   if grep "__clang__" conftest.txt >/dev/null 2>&1; then
2153     HS_CPP_ARGS="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
2154   else
2155       $HS_CPP_CMD  -v > conftest.txt 2>&1
2156       if  grep "gcc" conftest.txt >/dev/null 2>&1; then
2157           HS_CPP_ARGS="-E -undef -traditional"
2158         else
2159           $HS_CPP_CMD  --version > conftest.txt 2>&1
2160           if grep "cpphs" conftest.txt >/dev/null 2>&1; then
2161             HS_CPP_ARGS="--cpp -traditional"
2162           else
2163             AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
2164             HS_CPP_ARGS=""
2165           fi
2166       fi
2167   fi
2168   ]
2169 )
2170
2171 $1=$HS_CPP_CMD
2172 $2=$HS_CPP_ARGS
2173
2174 ])
2175
2176 # FP_BFD_SUPPORT()
2177 # ----------------------
2178 # whether to use libbfd for debugging RTS
2179 AC_DEFUN([FP_BFD_SUPPORT], [
2180     AC_ARG_ENABLE(bfd-debug,
2181         [AC_HELP_STRING([--enable-bfd-debug],
2182               [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
2183         [
2184             # don't pollute general LIBS environment
2185             save_LIBS="$LIBS"
2186             AC_CHECK_HEADERS([bfd.h])
2187             dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
2188             dnl    the order of these tests matters: bfd needs libiberty
2189             AC_CHECK_LIB(iberty, xmalloc)
2190             dnl 'bfd_init' is a rare non-macro in libbfd
2191             AC_CHECK_LIB(bfd,    bfd_init)
2192
2193             AC_TRY_LINK([#include <bfd.h>],
2194                         [
2195                                 /* mimic our rts/Printer.c */
2196                                 bfd* abfd;
2197                                 const char * name;
2198                                 char **matching;
2199
2200                                 name = "some.executable";
2201                                 bfd_init();
2202                                 abfd = bfd_openr(name, "default");
2203                                 bfd_check_format_matches (abfd, bfd_object, &matching);
2204                                 {
2205                                     long storage_needed;
2206                                     storage_needed = bfd_get_symtab_upper_bound (abfd);
2207                                 }
2208                                 {
2209                                     asymbol **symbol_table;
2210                                     long number_of_symbols;
2211                                     symbol_info info;
2212
2213                                     number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
2214                                     bfd_get_symbol_info(abfd,symbol_table[0],&info);
2215                                 }
2216                         ],
2217                         [],dnl bfd seems to work
2218                         [AC_MSG_ERROR([can't use 'bfd' library])])
2219             LIBS="$save_LIBS"
2220         ]
2221     )
2222 ])
2223
2224 # LocalWords:  fi