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