1 # Extra autoconf macros for the Glasgow fptools
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.
7 AC_DEFUN([GHC_SELECT_FILE_EXTENSIONS],
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])
22 i386-apple-darwin|powerpc-apple-darwin)
28 arm-apple-darwin10|i386-apple-darwin11|aarch64-apple-darwin14|x86_64-apple-darwin14)
35 # FPTOOLS_SET_PLATFORM_VARS
36 # ----------------------------------
37 # Set the platform variables
38 AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS],
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
45 # For why we do it this way, see: #3637, #1717, #2951
47 # In bindists, we haven't called AC_CANONICAL_{BUILD,HOST,TARGET}
48 # so this justs uses $bootstrap_target.
50 if test "$build_alias" = ""
52 if test "$bootstrap_target" != ""
54 build=$bootstrap_target
55 echo "Build platform inferred as: $build"
57 echo "Can't work out build platform"
61 BuildArch=`echo "$build" | sed 's/-.*//'`
62 BuildVendor=`echo "$build" | sed -e 's/.*-\(.*\)-.*/\1/'`
63 BuildOS=`echo "$build" | sed 's/.*-//'`
65 GHC_CONVERT_CPU([$build_cpu], [BuildArch])
66 GHC_CONVERT_VENDOR([$build_vendor], [BuildVendor])
67 GHC_CONVERT_OS([$build_os], [$BuildArch], [BuildOS])
70 if test "$host_alias" = ""
72 if test "$bootstrap_target" != ""
74 host=$bootstrap_target
75 echo "Host platform inferred as: $host"
77 echo "Can't work out host platform"
81 HostArch=`echo "$host" | sed 's/-.*//'`
82 HostVendor=`echo "$host" | sed -e 's/.*-\(.*\)-.*/\1/'`
83 HostOS=`echo "$host" | sed 's/.*-//'`
85 GHC_CONVERT_CPU([$host_cpu], [HostArch])
86 GHC_CONVERT_VENDOR([$host_vendor], [HostVendor])
87 GHC_CONVERT_OS([$host_os], [$HostArch], [HostOS])
90 if test "$target_alias" = ""
92 if test "$host_alias" != ""
94 GHC_CONVERT_CPU([$host_cpu], [TargetArch])
95 GHC_CONVERT_VENDOR([$host_vendor], [TargetVendor])
96 GHC_CONVERT_OS([$host_os], [$TargetArch],[TargetOS])
98 if test "$bootstrap_target" != ""
100 target=$bootstrap_target
101 echo "Target platform inferred as: $target"
103 echo "Can't work out target platform"
107 TargetArch=`echo "$target" | sed 's/-.*//'`
108 TargetVendor=`echo "$target" | sed -e 's/.*-\(.*\)-.*/\1/'`
109 TargetOS=`echo "$target" | sed 's/.*-//'`
112 GHC_CONVERT_CPU([$target_cpu], [TargetArch])
113 GHC_CONVERT_VENDOR([$target_vendor], [TargetVendor])
114 GHC_CONVERT_OS([$target_os], [$TargetArch], [TargetOS])
117 GHC_SELECT_FILE_EXTENSIONS([$host], [exeext_host], [soext_host])
118 GHC_SELECT_FILE_EXTENSIONS([$target], [exeext_target], [soext_target])
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'`
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'`
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'`
144 echo "GHC build : $BuildPlatform"
145 echo "GHC host : $HostPlatform"
146 echo "GHC target : $TargetPlatform"
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)
155 AC_SUBST(HostArch_CPP)
156 AC_SUBST(BuildArch_CPP)
157 AC_SUBST(TargetArch_CPP)
160 AC_SUBST(BuildOS_CPP)
161 AC_SUBST(TargetOS_CPP)
163 AC_SUBST(HostVendor_CPP)
164 AC_SUBST(BuildVendor_CPP)
165 AC_SUBST(TargetVendor_CPP)
167 AC_SUBST(exeext_host)
168 AC_SUBST(exeext_target)
170 AC_SUBST(soext_target)
174 # FPTOOLS_SET_HASKELL_PLATFORM_VARS
175 # ----------------------------------
176 # Set the Haskell platform variables
177 AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS],
182 test -z "[$]2" || eval "[$]2=ArchX86"
185 test -z "[$]2" || eval "[$]2=ArchX86_64"
188 test -z "[$]2" || eval "[$]2=ArchPPC"
191 test -z "[$]2" || eval "[$]2=\"ArchPPC_64 {ppc_64ABI = ELF_V1}\""
194 test -z "[$]2" || eval "[$]2=\"ArchPPC_64 {ppc_64ABI = ELF_V2}\""
197 test -z "[$]2" || eval "[$]2=ArchSPARC"
200 test -z "[$]2" || eval "[$]2=ArchSPARC64"
204 test -z "[$]2" || eval "[$]2=\"ArchARM {armISA = \$ARM_ISA, armISAExt = \$ARM_ISA_EXT, armABI = \$ARM_ABI}\""
207 test -z "[$]2" || eval "[$]2=ArchARM64"
210 test -z "[$]2" || eval "[$]2=ArchAlpha"
213 test -z "[$]2" || eval "[$]2=ArchMipseb"
216 test -z "[$]2" || eval "[$]2=ArchMipsel"
218 hppa|hppa1_1|ia64|m68k|rs6000|s390|s390x|sh4|vax)
219 test -z "[$]2" || eval "[$]2=ArchUnknown"
222 echo "Unknown arch [$]1"
230 dec|unknown|hp|apple|next|sun|sgi|ibm|montavista|portbld)
233 echo "Unknown vendor [$]1"
242 test -z "[$]2" || eval "[$]2=OSLinux"
245 test -z "[$]2" || eval "[$]2=OSiOS"
248 test -z "[$]2" || eval "[$]2=OSDarwin"
251 test -z "[$]2" || eval "[$]2=OSSolaris2"
254 test -z "[$]2" || eval "[$]2=OSMinGW32"
257 test -z "[$]2" || eval "[$]2=OSFreeBSD"
260 test -z "[$]2" || eval "[$]2=OSDragonFly"
263 test -z "[$]2" || eval "[$]2=OSKFreeBSD"
266 test -z "[$]2" || eval "[$]2=OSOpenBSD"
269 test -z "[$]2" || eval "[$]2=OSNetBSD"
272 test -z "[$]2" || eval "[$]2=OSHaiku"
275 test -z "[$]2" || eval "[$]2=OSQNXNTO"
277 dragonfly|hpux|linuxaout|freebsd2|gnu|nextstep2|nextstep3|sunos4|ultrix)
278 test -z "[$]2" || eval "[$]2=OSUnknown"
281 test -z "[$]2" || eval "[$]2=OSAIX"
284 test -z "[$]2" || eval "[$]2=OSAndroid"
287 echo "Unknown OS '[$]1'"
293 dnl ** check for Apple-style dead-stripping support
294 dnl (.subsections-via-symbols assembler directive)
296 AC_MSG_CHECKING(for .subsections_via_symbols)
298 [AC_LANG_PROGRAM([], [__asm__ (".subsections_via_symbols");])],
300 HaskellHaveSubsectionsViaSymbols=True
301 AC_DEFINE([HAVE_SUBSECTIONS_VIA_SYMBOLS],[1],
302 [Define to 1 if Apple-style dead-stripping is supported.])
304 [HaskellHaveSubsectionsViaSymbols=False
307 dnl ** check for .ident assembler directive
309 AC_MSG_CHECKING(whether your assembler supports .ident directive)
311 [AC_LANG_SOURCE([__asm__ (".ident \"GHC x.y.z\"");])],
313 HaskellHaveIdentDirective=True],
315 HaskellHaveIdentDirective=False])
317 dnl *** check for GNU non-executable stack note support (ELF only)
318 dnl (.section .note.GNU-stack,"",@progbits)
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
325 AC_MSG_CHECKING(for GNU non-executable stack support)
327 [AC_LANG_PROGRAM([__asm__ (".section .note.GNU-stack,\"\",@progbits");], [0])],
329 HaskellHaveGnuNonexecStack=True],
331 HaskellHaveGnuNonexecStack=False])
334 checkArch "$BuildArch" "HaskellBuildArch"
335 checkVendor "$BuildVendor"
336 checkOS "$BuildOS" ""
338 checkArch "$HostArch" "HaskellHostArch"
339 checkVendor "$HostVendor"
342 checkArch "$TargetArch" "HaskellTargetArch"
343 checkVendor "$TargetVendor"
344 checkOS "$TargetOS" "HaskellTargetOs"
346 AC_SUBST(HaskellTargetArch)
347 AC_SUBST(HaskellTargetOs)
348 AC_SUBST(HaskellHaveSubsectionsViaSymbols)
349 AC_SUBST(HaskellHaveIdentDirective)
350 AC_SUBST(HaskellHaveGnuNonexecStack)
355 # ----------------------------------
356 # Get info about the ISA on the ARM arch
357 AC_DEFUN([GET_ARM_ISA],
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__)
376 [AC_DEFINE(arm_HOST_ARCH_PRE_ARMv6, 1, [ARM pre v6])
377 AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
387 [#if defined(__ARM_ARCH_6__) || \
388 defined(__ARM_ARCH_6J__) || \
389 defined(__ARM_ARCH_6T2__) || \
390 defined(__ARM_ARCH_6Z__) || \
391 defined(__ARM_ARCH_6ZK__) || \
392 defined(__ARM_ARCH_6M__)
398 [AC_DEFINE(arm_HOST_ARCH_PRE_ARMv7, 1, [ARM pre v7])
403 [#if defined(__VFP_FP__)
410 ARM_ISA_EXT="[VFPv2]"
420 ARM_ISA_EXT="[VFPv3,NEON]"
428 [#if defined(__SOFTFP__)
441 [#if defined(__ARM_PCS_VFP)
457 # ----------------------------------
458 # Set the variables used in the settings file
459 AC_DEFUN([FP_SETTINGS],
461 SettingsCCompilerCommand="$CC"
462 SettingsHaskellCPPCommand="$HaskellCPPCmd"
463 SettingsHaskellCPPFlags="$HaskellCPPArgs"
464 SettingsLdCommand="$LdCmd"
465 SettingsArCommand="$ArCmd"
466 SettingsPerlCommand="$PerlCmd"
468 if test -z "$DllWrap"
470 SettingsDllWrapCommand="/bin/false"
472 SettingsDllWrapCommand="$DllWrap"
475 if test -z "$Windres"
477 SettingsWindresCommand="/bin/false"
479 SettingsWindresCommand="$Windres"
482 if test -z "$Libtool"
484 SettingsLibtoolCommand="libtool"
486 SettingsLibtoolCommand="$Libtool"
491 SettingsTouchCommand='touch'
493 SettingsTouchCommand='$Touch'
498 SettingsLlcCommand="llc"
500 SettingsLlcCommand="$LlcCmd"
505 SettingsOptCommand="opt"
507 SettingsOptCommand="$OptCmd"
510 SettingsCCompilerFlags="$CONF_CC_OPTS_STAGE2"
511 SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
512 SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE"
513 SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
514 AC_SUBST(SettingsCCompilerCommand)
515 AC_SUBST(SettingsHaskellCPPCommand)
516 AC_SUBST(SettingsHaskellCPPFlags)
517 AC_SUBST(SettingsCCompilerFlags)
518 AC_SUBST(SettingsCCompilerLinkFlags)
519 AC_SUBST(SettingsCCompilerSupportsNoPie)
520 AC_SUBST(SettingsLdCommand)
521 AC_SUBST(SettingsLdFlags)
522 AC_SUBST(SettingsArCommand)
523 AC_SUBST(SettingsPerlCommand)
524 AC_SUBST(SettingsDllWrapCommand)
525 AC_SUBST(SettingsWindresCommand)
526 AC_SUBST(SettingsLibtoolCommand)
527 AC_SUBST(SettingsTouchCommand)
528 AC_SUBST(SettingsLlcCommand)
529 AC_SUBST(SettingsOptCommand)
532 # Helper for cloning a shell variable's state
533 AC_DEFUN([FP_COPY_SHELLVAR],
534 [if test -n "${$1+set}"; then $2="$$1"; else unset $2; fi ])
537 # ----------------------------------
538 # figure out which CFLAGS are needed to place the compiler into C99 mode
539 # $1 is name of CC variable (unmodified)
540 # $2 is name of CC flags variable (augmented if needed)
541 # $3 is name of CPP flags variable (augmented if needed)
542 AC_DEFUN([FP_SET_CFLAGS_C99],
544 dnl save current state of AC_PROG_CC_C99
545 FP_COPY_SHELLVAR([CC],[fp_save_CC])
546 FP_COPY_SHELLVAR([CFLAGS],[fp_save_CFLAGS])
547 FP_COPY_SHELLVAR([CPPFLAGS],[fp_save_CPPFLAGS])
548 FP_COPY_SHELLVAR([ac_cv_prog_cc_c99],[fp_save_cc_c99])
553 unset ac_cv_prog_cc_c99
554 dnl perform detection
556 fp_cc_c99="$ac_cv_prog_cc_c99"
557 case "x$ac_cv_prog_cc_c99" in
559 xno) AC_MSG_ERROR([C99-compatible compiler needed]) ;;
560 *) $2="$$2 $ac_cv_prog_cc_c99"
561 $3="$$3 $ac_cv_prog_cc_c99"
564 dnl restore saved state
565 FP_COPY_SHELLVAR([fp_save_CC],[CC])
566 FP_COPY_SHELLVAR([fp_save_CFLAGS],[CFLAGS])
567 FP_COPY_SHELLVAR([fp_save_CPPFLAGS],[CPPFLAGS])
568 FP_COPY_SHELLVAR([fp_save_cc_c99],[ac_cv_prog_cc_c99])
575 # FPTOOLS_SET_C_LD_FLAGS
576 # ----------------------------------
577 # Set the C, LD and CPP flags for a given platform
579 # $2 is the name of the CC flags variable
580 # $3 is the name of the linker flags variable when linking with gcc
581 # $4 is the name of the linker flags variable when linking with ld
582 # $5 is the name of the CPP flags variable
583 AC_DEFUN([FPTOOLS_SET_C_LD_FLAGS],
585 AC_MSG_CHECKING([Setting up $2, $3, $4 and $5])
588 # Workaround for #7799
594 i386-unknown-mingw32)
597 i386-portbld-freebsd*)
609 $4="$$4 -arch x86_64"
612 x86_64-unknown-solaris2)
619 # For now, to suppress the gcc warning "call-clobbered
620 # register used for global register variable", we simply
621 # disable all warnings altogether using the -w flag. Oh well.
622 $2="$$2 -w -mieee -D_REENTRANT"
623 $3="$$3 -w -mieee -D_REENTRANT"
624 $5="$$5 -w -mieee -D_REENTRANT"
627 # ___HPUX_SOURCE, not _HPUX_SOURCE, is #defined if -ansi!
628 # (very nice, but too bad the HP /usr/include files don't agree.)
629 $2="$$2 -D_HPUX_SOURCE"
630 $3="$$3 -D_HPUX_SOURCE"
631 $5="$$5 -D_HPUX_SOURCE"
634 # On arm/linux and arm/android, tell gcc to generate Arm
635 # instructions (ie not Thumb) and to link using the gold linker.
636 # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
638 $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
639 $4="$$4 -z noexecstack"
643 # On aarch64/linux and aarch64/android, tell gcc to link using the
645 # Forcing LD to be ld.gold is done in FIND_LD m4 macro.
646 $3="$$3 -fuse-ld=gold -Wl,-z,noexecstack"
647 $4="$$4 -z noexecstack"
651 # We need `-D_THREAD_SAFE` to unlock the thread-local `errno`.
652 $2="$$2 -D_THREAD_SAFE"
653 $3="$$3 -D_THREAD_SAFE -Wl,-bnotextro"
655 $5="$$5 -D_THREAD_SAFE"
659 # We need -z wxneeded at least to link ghc-stage2 to workaround
660 # W^X issue in GHCi on OpenBSD current (as of Aug 2016)
661 $3="$$3 -Wl,-z,wxneeded"
667 # If gcc knows about the stack protector, turn it off.
668 # Otherwise the stack-smash handler gets triggered.
669 echo 'int main(void) {return 0;}' > conftest.c
670 if $CC -c conftest.c -fno-stack-protector > /dev/null 2>&1
672 $2="$$2 -fno-stack-protector"
675 rm -f conftest.c conftest.o
676 AC_MSG_RESULT([done])
680 # FP_VISIBILITY_HIDDEN
681 # ----------------------------------
682 # Is the visibility hidden attribute supported?
683 AC_DEFUN([FP_VISIBILITY_HIDDEN],
685 AC_MSG_CHECKING([whether __attribute__((visibility("hidden"))) is supported])
686 echo '__attribute__((visibility("hidden"))) void foo(void) {}' > conftest.c
687 if $CC -Wall -Werror -c conftest.c > /dev/null 2>&1
690 AC_DEFINE(HAS_VISIBILITY_HIDDEN, 1, [Has visibility hidden])
694 rm -f conftest.c conftest.o
698 # FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
699 # ----------------------------------
700 # Little endian ARM on Linux with some ABIs has big endian word order
701 # in doubles. Define FLOAT_WORDS_BIGENDIAN if this is the case.
702 AC_DEFUN([FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN],
703 [AC_CACHE_CHECK([whether float word order is big endian], [fptools_cv_float_word_order_bigendian],
706 [#include <endian.h>],
707 [#if defined(__FLOAT_WORD_ORDER) && __FLOAT_WORD_ORDER == BIG_ENDIAN
710 not float word order big endian
713 [fptools_cv_float_word_order_bigendian=yes],
714 [fptools_cv_float_word_order_bigendian=no])
716 case $fptools_cv_float_word_order_bigendian in
718 AC_DEFINE([FLOAT_WORDS_BIGENDIAN], 1,
719 [Define to 1 if your processor stores words of floats with
720 the most significant byte first]) ;;
725 # FP_ARG_WITH_PATH_GNU_PROG_GENERAL
726 # --------------------
727 # Find the specified command on the path or allow a user to set it manually
728 # with a --with-<command> option.
730 # This is ignored on the mingw32 platform.
732 # $1 = the variable to set
733 # $2 = the with option name
734 # $3 = the command to look for
735 # $4 = prepend target to program name? if 'no', use the name unchanged
736 # $5 = optional? if 'no', then raise an error if the command isn't found
738 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG_GENERAL],
741 [AC_HELP_STRING([--with-$2=ARG],
742 [Use ARG as the path to $2 [default=autodetect]])],
744 if test "$HostOS" = "mingw32"
746 AC_MSG_WARN([Request to use $withval will be ignored])
751 # Remember that we set this manually. Used to override CC_STAGE0
752 # and friends later, if we are not cross-compiling.
756 if test "$HostOS" != "mingw32"
758 if test "$4" = "no" -o "$target_alias" = "" ; then
759 AC_PATH_PROG([$1], [$3])
761 AC_PATH_PROG([$1], [$target_alias-$3])
763 if test "$5" = "no" -a -z "$$1"
765 AC_MSG_ERROR([cannot find $3 in your PATH])
770 ]) # FP_ARG_WITH_PATH_GNU_PROG_GENERAL
773 # FP_ARG_WITH_PATH_GNU_PROG
774 # --------------------
775 # The usual case: prepend the target, and the program is not optional.
776 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG],
777 [FP_ARG_WITH_PATH_GNU_PROG_GENERAL([$1], [$2], [$3], [yes], [no])])
779 # FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL
780 # --------------------
781 # Same as FP_ARG_WITH_PATH_GNU_PROG but no error will be thrown if the command
783 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL],
784 [FP_ARG_WITH_PATH_GNU_PROG_GENERAL([$1], [$2], [$3], [yes], [yes])])
786 # FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET
787 # --------------------
788 # Same as FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL but don't prepend the target name
790 AC_DEFUN([FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET],
791 [FP_ARG_WITH_PATH_GNU_PROG_GENERAL([$1], [$2], [$3], [no], [yes])])
794 # FP_PROG_CONTEXT_DIFF
795 # --------------------
796 # Figure out how to do context diffs. Sets the output variable ContextDiffCmd.
798 # Note: NeXTStep thinks diff'ing a file against itself is "trouble".
799 AC_DEFUN([FP_PROG_CONTEXT_DIFF],
800 [AC_CACHE_CHECK([for a working context diff], [fp_cv_context_diff],
801 [echo foo > conftest1
803 fp_cv_context_diff=no
804 for fp_var in '-U 1' '-u1' '-C 1' '-c1'
806 if diff $fp_var conftest1 conftest2 > /dev/null 2>&1; then
807 fp_cv_context_diff="diff $fp_var"
811 if test x"$fp_cv_context_diff" = xno; then
812 AC_MSG_ERROR([cannot figure out how to do context diffs])
814 AC_SUBST(ContextDiffCmd, [$fp_cv_context_diff])
815 ])# FP_PROG_CONTEXT_DIFF
818 # FP_COMPUTE_INT(EXPRESSION, VARIABLE, INCLUDES, IF-FAILS)
819 # --------------------------------------------------------
820 # Assign VARIABLE the value of the compile-time EXPRESSION using INCLUDES for
821 # compilation. Execute IF-FAILS when unable to determine the value. Works for
822 # cross-compilation, too.
824 # Implementation note: We are lazy and use an internal autoconf macro, but it
825 # is supported in autoconf versions 2.50 up to the actual 2.57, so there is
827 AC_DEFUN([FP_COMPUTE_INT],
828 [_AC_COMPUTE_INT([$1], [$2], [$3], [$4])[]dnl
832 # FP_CHECK_ALIGNMENT(TYPE, [IGNORED], [INCLUDES = DEFAULT-INCLUDES])
833 # ------------------------------------------------------------------
834 # A variation of AC_CHECK_SIZEOF for computing the alignment restrictions of a
835 # given type. Defines ALIGNMENT_TYPE.
836 AC_DEFUN([FP_CHECK_ALIGNMENT],
837 [AS_LITERAL_IF(m4_translit([[$1]], [*], [p]), [],
838 [AC_FATAL([$0: requires literal arguments])])[]dnl
839 AC_CHECK_TYPE([$1], [], [], [$3])[]dnl
840 m4_pushdef([fp_Cache], [AS_TR_SH([fp_cv_alignment_$1])])[]dnl
841 AC_CACHE_CHECK([alignment of $1], [fp_Cache],
842 [if test "$AS_TR_SH([ac_cv_type_$1])" = yes; then
843 FP_COMPUTE_INT([offsetof(struct { char c; $1 ty; },ty)],
845 [AC_INCLUDES_DEFAULT([$3])],
846 [AC_MSG_ERROR([cannot compute alignment ($1)
847 See `config.log' for more details.], [77])])
851 AC_DEFINE_UNQUOTED(AS_TR_CPP(alignment_$1), $fp_Cache, [The alignment of a `$1'.])[]dnl
852 m4_popdef([fp_Cache])[]dnl
853 ])# FP_CHECK_ALIGNMENT
857 # FP_CHECK_SIZEOF_AND_ALIGNMENT(TYPE)
858 # ------------------------------------------------------------------
859 # Combines AC_CHECK_SIZEOF and FP_CHECK_ALIGNMENT.
860 AC_DEFUN([FP_CHECK_SIZEOF_AND_ALIGNMENT],
861 [AC_CHECK_SIZEOF([$1])
862 FP_CHECK_ALIGNMENT([$1])
863 ])# FP_CHECK_SIZEOF_AND_ALIGNMENT
866 # FP_LEADING_UNDERSCORE
867 # ---------------------
868 # Test for determining whether symbol names have a leading underscore. We assume
869 # that they _haven't_ if anything goes wrong. Sets the output variable
870 # LeadingUnderscore to YES or NO and defines LEADING_UNDERSCORE correspondingly.
872 # Some nlist implementations seem to try to be compatible by ignoring a leading
873 # underscore sometimes (eg. FreeBSD). We therefore have to work around this by
874 # checking for *no* leading underscore first. Sigh. --SDM
876 # Similarly on OpenBSD, but this test doesn't help. -- dons
877 AC_DEFUN([FP_LEADING_UNDERSCORE],
878 [AC_CHECK_LIB([elf], [nlist], [LIBS="-lelf $LIBS"])
879 AC_CACHE_CHECK([leading underscore in symbol names], [fptools_cv_leading_underscore], [
880 # Hack!: nlist() under Digital UNIX insist on there being an _,
881 # but symbol table listings shows none. What is going on here?!?
882 case $HostPlatform in
883 *openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore
885 i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;;
886 *) fptools_cv_leading_underscore=no ;;
888 i386-unknown-mingw32) fptools_cv_leading_underscore=yes;;
889 x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;;
891 # HACK: Apple doesn't seem to provide nlist in the 64-bit-libraries
892 x86_64-apple-darwin*) fptools_cv_leading_underscore=yes;;
893 *-apple-ios) fptools_cv_leading_underscore=yes;;
895 *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H
897 struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}};
898 struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}};
906 if(nlist(argv[0], xYzzY1) == 0 && xYzzY1[0].n_value != 0)
908 if(nlist(argv[0], xYzzY2) == 0 && xYzzY2[0].n_value != 0)
912 }]])],[fptools_cv_leading_underscore=yes],[fptools_cv_leading_underscore=no],[fptools_cv_leading_underscore=no])
915 AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`])
916 if test x"$fptools_cv_leading_underscore" = xyes; then
917 AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.])
918 fi])# FP_LEADING_UNDERSCORE
921 # FP_COMPARE_VERSIONS(VERSION1, TEST, VERSION2, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
922 # ----------------------------------------------------------------------------------
923 # Compare dotted version numbers VERSION1 and VERSION2 lexicographically according
924 # to TEST (one of -eq, -ne, -lt, -le, -gt, or -ge).
925 AC_DEFUN([FP_COMPARE_VERSIONS],
926 [fp_version1=$1; fp_version2=$3
927 fp_save_IFS=$IFS; IFS='.'
928 while test x"$fp_version1" != x || test x"$fp_version2" != x
931 set dummy $fp_version1; shift
933 test $[@%:@] = 0 || { fp_num1="[$]1"; shift; }
934 test x"$fp_num1" = x && fp_num1="0"
937 set dummy $fp_version2; shift
939 test $[@%:@] = 0 || { fp_num2="[$]1"; shift; }
940 test x"$fp_num2" = x && fp_num2="0"
943 test "$fp_num1" = "$fp_num2" || break;
946 AS_IF([test "$fp_num1" $2 "$fp_num2"], [$4], [$5])[]dnl
947 ])# FP_COMPARE_VERSIONS
951 dnl Check for Happy and version.
952 dnl If there's no installed Happy, we look
953 dnl for a happy source tree and point the build system at that instead.
954 dnl If you increase the minimum version requirement, please also update:
955 dnl https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Tools
957 AC_DEFUN([FPTOOLS_HAPPY],
958 [AC_PATH_PROG(HappyCmd,happy,)
960 AC_CACHE_CHECK([for version of happy], fptools_cv_happy_version,
962 [if test x"$HappyCmd" != x; then
963 fptools_cv_happy_version=`"$HappyCmd" -v |
964 grep 'Happy Version' | sed -e 's/Happy Version \([^ ]*\).*/\1/g'` ;
966 fptools_cv_happy_version="";
970 if test ! -f compiler/parser/Parser.hs || test ! -f compiler/cmm/CmmParse.hs
972 FP_COMPARE_VERSIONS([$fptools_cv_happy_version],[-lt],[1.19.4],
973 [AC_MSG_ERROR([Happy version 1.19.4 or later is required to compile GHC.])])[]
975 HappyVersion=$fptools_cv_happy_version;
976 AC_SUBST(HappyVersion)
980 dnl Check for Alex and version.
981 dnl If you increase the minimum version requirement, please also update:
982 dnl https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Tools
984 AC_DEFUN([FPTOOLS_ALEX],
986 AC_PATH_PROG(AlexCmd,alex,)
988 AC_CACHE_CHECK([for version of alex], fptools_cv_alex_version,
990 [if test x"$AlexCmd" != x; then
991 fptools_cv_alex_version=`"$AlexCmd" -v |
992 grep 'Alex [Vv]ersion' | sed -e 's/Alex [Vv]ersion \([0-9\.]*\).*/\1/g'` ;
994 fptools_cv_alex_version="";
998 FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-ge],[3.0],
999 [Alex3=YES],[Alex3=NO])
1000 if test ! -f compiler/cmm/CmmLex.hs || test ! -f compiler/parser/Lexer.hs
1002 FP_COMPARE_VERSIONS([$fptools_cv_alex_version],[-lt],[3.1.0],
1003 [AC_MSG_ERROR([Alex version 3.1.0 or later is required to compile GHC.])])[]
1005 AlexVersion=$fptools_cv_alex_version;
1006 AC_SUBST(AlexVersion)
1013 # Sets the output variable $2 to $1 if ld supports the $1 flag.
1014 # Otherwise the variable's value is empty.
1015 AC_DEFUN([FP_PROG_LD_FLAG],
1017 AC_CACHE_CHECK([whether ld understands $1], [fp_cv_$2],
1018 [echo 'int foo() { return 0; }' > conftest.c
1019 ${CC-cc} -c conftest.c
1020 if ${LdCmd} -r $1 -o conftest2.o conftest.o > /dev/null 2>&1; then
1030 # FP_PROG_LD_BUILD_ID
1033 # Sets the output variable LdHasBuildId to YES if ld supports
1034 # --build-id, or NO otherwise.
1035 AC_DEFUN([FP_PROG_LD_BUILD_ID],
1037 AC_CACHE_CHECK([whether ld understands --build-id], [fp_cv_ld_build_id],
1038 [echo 'int foo() { return 0; }' > conftest.c
1039 ${CC-cc} -c conftest.c
1040 if ${LdCmd} -r --build-id=none -o conftest2.o conftest.o > /dev/null 2>&1; then
1041 fp_cv_ld_build_id=yes
1043 fp_cv_ld_build_id=no
1046 if test "$fp_cv_ld_build_id" = yes; then
1051 AC_SUBST([LdHasBuildId])
1052 ])# FP_PROG_LD_BUILD_ID
1057 # Sets the output variable LdIsGNULd to YES or NO, depending on whether it is
1059 AC_DEFUN([FP_PROG_LD_IS_GNU],
1061 AC_CACHE_CHECK([whether ld is GNU ld], [fp_cv_gnu_ld],
1062 [if ${LdCmd} --version 2> /dev/null | grep "GNU" > /dev/null 2>&1; then
1067 AC_SUBST([LdIsGNULd], [`echo $fp_cv_gnu_ld | sed 'y/yesno/YESNO/'`])
1068 ])# FP_PROG_LD_IS_GNU
1071 # FP_PROG_LD_NO_COMPACT_UNWIND
1072 # ----------------------------
1074 # Sets the output variable LdHasNoCompactUnwind to YES if ld supports
1075 # -no_compact_unwind, or NO otherwise.
1076 AC_DEFUN([FP_PROG_LD_NO_COMPACT_UNWIND],
1078 AC_CACHE_CHECK([whether ld understands -no_compact_unwind], [fp_cv_ld_no_compact_unwind],
1079 [echo 'int foo() { return 0; }' > conftest.c
1080 ${CC-cc} -c conftest.c
1081 if ${LdCmd} -r -no_compact_unwind -o conftest2.o conftest.o > /dev/null 2>&1; then
1082 fp_cv_ld_no_compact_unwind=yes
1084 fp_cv_ld_no_compact_unwind=no
1087 if test "$fp_cv_ld_no_compact_unwind" = yes; then
1088 LdHasNoCompactUnwind=YES
1090 LdHasNoCompactUnwind=NO
1092 AC_SUBST([LdHasNoCompactUnwind])
1093 ])# FP_PROG_LD_NO_COMPACT_UNWIND
1096 # FP_PROG_LD_FILELIST
1097 # -------------------
1099 # Sets the output variable LdHasFilelist to YES if ld supports
1100 # -filelist, or NO otherwise.
1101 AC_DEFUN([FP_PROG_LD_FILELIST],
1103 AC_CACHE_CHECK([whether ld understands -filelist], [fp_cv_ld_has_filelist],
1105 echo 'int foo() { return 0; }' > conftest1.c
1106 echo 'int bar() { return 0; }' > conftest2.c
1107 ${CC-cc} -c conftest1.c
1108 ${CC-cc} -c conftest2.c
1109 echo conftest1.o > conftest.o-files
1110 echo conftest2.o >> conftest.o-files
1111 if ${LdCmd} -r -filelist conftest.o-files -o conftest.o > /dev/null 2>&1
1113 fp_cv_ld_has_filelist=yes
1115 fp_cv_ld_has_filelist=no
1119 if test "$fp_cv_ld_has_filelist" = yes; then
1124 AC_SUBST([LdHasFilelist])
1125 ])# FP_PROG_LD_FILELIST
1130 # Sets fp_prog_ar to a path to ar. Exits if no ar can be found
1131 AC_DEFUN([FP_PROG_AR],
1132 [AC_PATH_PROG([fp_prog_ar], [ar])
1133 if test -z "$fp_prog_ar"; then
1134 AC_MSG_ERROR([cannot find ar in your PATH, no idea how to make a library])
1141 # Sets fp_prog_ar_is_gnu to yes or no, depending on whether it is GNU ar or not.
1142 AC_DEFUN([FP_PROG_AR_IS_GNU],
1143 [AC_REQUIRE([FP_PROG_AR])
1144 AC_CACHE_CHECK([whether $fp_prog_ar is GNU ar], [fp_cv_prog_ar_is_gnu],
1145 [if "$fp_prog_ar" --version 2> /dev/null | grep "GNU" > /dev/null 2>&1; then
1146 fp_cv_prog_ar_is_gnu=yes
1148 fp_cv_prog_ar_is_gnu=no
1150 fp_prog_ar_is_gnu=$fp_cv_prog_ar_is_gnu
1151 AC_SUBST([ArIsGNUAr], [`echo $fp_prog_ar_is_gnu | tr 'a-z' 'A-Z'`])
1152 ])# FP_PROG_AR_IS_GNU
1155 # FP_PROG_AR_SUPPORTS_ATFILE
1157 # Sets fp_prog_ar_supports_atfile to yes or no, depending on whether
1158 # or not it supports the @file syntax
1159 AC_DEFUN([FP_PROG_AR_SUPPORTS_ATFILE],
1160 [AC_REQUIRE([FP_PROG_AR])
1161 AC_REQUIRE([FP_PROG_AR_ARGS])
1162 AC_CACHE_CHECK([whether $fp_prog_ar supports @file], [fp_cv_prog_ar_supports_atfile],
1166 echo conftest.file > conftest.atfile
1167 echo conftest.file >> conftest.atfile
1168 "$fp_prog_ar" $fp_prog_ar_args conftest.a @conftest.atfile > /dev/null 2>&1
1169 fp_prog_ar_supports_atfile_tmp=`"$fp_prog_ar" t conftest.a 2> /dev/null | grep -c conftest.file`
1171 if test "$fp_prog_ar_supports_atfile_tmp" -eq 2
1173 fp_cv_prog_ar_supports_atfile=yes
1175 fp_cv_prog_ar_supports_atfile=no
1177 fp_prog_ar_supports_atfile=$fp_cv_prog_ar_supports_atfile
1178 AC_SUBST([ArSupportsAtFile], [`echo $fp_prog_ar_supports_atfile | tr 'a-z' 'A-Z'`])
1179 ])# FP_PROG_AR_SUPPORTS_ATFILE
1183 # Sets fp_prog_ar_args to the arguments for ar and the output variable ArCmd
1184 # to an invocation of ar including these arguments.
1185 AC_DEFUN([FP_PROG_AR_ARGS],
1186 [AC_REQUIRE([FP_PROG_AR_IS_GNU])
1187 AC_CACHE_CHECK([for ar arguments], [fp_cv_prog_ar_args],
1189 # GNU ar needs special treatment: it appears to have problems with
1190 # object files with the same name if you use the 's' modifier, but
1191 # simple 'ar q' works fine, and doesn't need a separate ranlib.
1192 if test $fp_prog_ar_is_gnu = yes; then
1193 fp_cv_prog_ar_args="q"
1195 touch conftest.dummy
1196 for fp_var in clqsZ clqs cqs clq cq ; do
1198 if "$fp_prog_ar" $fp_var conftest.a conftest.dummy > /dev/null 2> /dev/null; then
1199 fp_cv_prog_ar_args=$fp_var
1204 if test -z "$fp_cv_prog_ar_args"; then
1205 AC_MSG_ERROR([cannot figure out how to use your $fp_prog_ar])
1208 fp_prog_ar_args=$fp_cv_prog_ar_args
1209 AC_SUBST([ArCmd], ["$fp_prog_ar"])
1210 AC_SUBST([ArArgs], ["$fp_prog_ar_args"])
1215 # FP_PROG_AR_NEEDS_RANLIB
1216 # -----------------------
1217 # Sets the output variable RANLIB_CMD to "ranlib" if it is needed and
1218 # found, to "true" otherwise. Sets REAL_RANLIB_CMD to the ranlib program,
1219 # even if we don't need ranlib (libffi might still need it).
1220 AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[
1221 AC_REQUIRE([FP_PROG_AR_IS_GNU])
1222 AC_REQUIRE([FP_PROG_AR_ARGS])
1223 AC_REQUIRE([AC_PROG_CC])
1227 if test $fp_prog_ar_is_gnu = yes
1229 fp_cv_prog_ar_needs_ranlib=no
1230 elif test "$TargetOS_CPP" = "darwin"
1232 # It's quite tedious to check for Apple's crazy timestamps in
1233 # .a files, so we hardcode it.
1234 fp_cv_prog_ar_needs_ranlib=yes
1236 case $fp_prog_ar_args in
1238 fp_cv_prog_ar_needs_ranlib=no;;
1240 fp_cv_prog_ar_needs_ranlib=yes;;
1244 # workaround for AC_PROG_RANLIB which sets RANLIB to `:' when
1245 # ranlib is missing on the target OS. The problem is that
1246 # ghc-cabal cannot execute `:' which is a shell built-in but can
1247 # execute `true' which is usually simple program supported by the
1250 if test "$RANLIB" = ":"
1254 REAL_RANLIB_CMD="$RANLIB"
1255 if test $fp_cv_prog_ar_needs_ranlib = yes
1257 RANLIB_CMD="$RANLIB"
1261 AC_SUBST([REAL_RANLIB_CMD])
1262 AC_SUBST([RANLIB_CMD])
1263 ])# FP_PROG_AR_NEEDS_RANLIB
1268 # Extra testing of the result AC_PROG_CC, testing the gcc version no. Sets the
1269 # output variable GccVersion.
1270 AC_DEFUN([FP_GCC_VERSION],
1271 [AC_REQUIRE([AC_PROG_CC])
1274 AC_MSG_ERROR([gcc is required])
1279 AC_CACHE_CHECK([version of gcc], [fp_cv_gcc_version],
1281 fp_cv_gcc_version="`$CC -v 2>&1 | grep 'version ' | sed -e 's/.*version [[^0-9]]*\([[0-9.]]*\).*/\1/g'`"
1282 FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [3.0],
1283 [AC_MSG_ERROR([Need at least gcc version 3.0 (3.4+ recommended)])])
1284 # See #2770: gcc 2.95 doesn't work any more, apparently. There probably
1285 # isn't a very good reason for that, but for now just make configure
1287 FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [3.4], GccLT34=YES)
1288 FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.4], GccLT44=YES)
1289 FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-lt], [4.6], GccLT46=YES)
1291 AC_SUBST([GccVersion], [$fp_cv_gcc_version])
1297 dnl Check to see if the C compiler is clang or llvm-gcc
1300 AC_DEFUN([FP_CC_LLVM_BACKEND],
1301 [AC_REQUIRE([AC_PROG_CC])
1302 AC_MSG_CHECKING([whether C compiler is clang])
1303 $CC -x c /dev/null -dM -E > conftest.txt 2>&1
1304 if grep "__clang__" conftest.txt >/dev/null 2>&1; then
1305 AC_SUBST([CC_CLANG_BACKEND], [1])
1306 AC_SUBST([CC_LLVM_BACKEND], [1])
1308 AC_MSG_RESULT([yes])
1311 AC_MSG_CHECKING([whether C compiler has an LLVM back end])
1312 if grep "__llvm__" conftest.txt >/dev/null 2>&1; then
1313 AC_SUBST([CC_CLANG_BACKEND], [0])
1314 AC_SUBST([CC_LLVM_BACKEND], [1])
1315 AC_MSG_RESULT([yes])
1317 AC_SUBST([CC_CLANG_BACKEND], [0])
1318 AC_SUBST([CC_LLVM_BACKEND], [0])
1322 AC_SUBST(GccIsClang)
1327 # FP_GCC_SUPPORTS_NO_PIE
1328 # ----------------------
1329 # Does gcc support the -no-pie option? If so we should pass it to gcc when
1330 # joining objects since -pie may be enabled by default.
1331 AC_DEFUN([FP_GCC_SUPPORTS_NO_PIE],
1333 AC_REQUIRE([AC_PROG_CC])
1334 AC_MSG_CHECKING([whether GCC supports -no-pie])
1335 echo 'int main() { return 0; }' > conftest.c
1336 # Some GCC versions only warn when passed an unrecognized flag.
1337 if $CC -no-pie -x c /dev/null -dM -E > conftest.txt 2>&1 && ! grep -i unrecognized conftest.txt > /dev/null 2>&1; then
1338 CONF_GCC_SUPPORTS_NO_PIE=YES
1339 AC_MSG_RESULT([yes])
1341 CONF_GCC_SUPPORTS_NO_PIE=NO
1344 rm -f conftest.c conftest.o conftest
1347 dnl Small feature test for perl version. Assumes PerlCmd
1348 dnl contains path to perl binary.
1350 dnl (Perl versions prior to v5.6 does not contain the string "v5";
1351 dnl instead they display version strings such as "version 5.005".)
1353 AC_DEFUN([FPTOOLS_CHECK_PERL_VERSION],
1354 [$PerlCmd -v >conftest.out 2>&1
1355 if grep "v5" conftest.out >/dev/null 2>&1; then
1358 AC_MSG_ERROR([your version of perl probably won't work, try upgrading it.])
1364 # FP_CHECK_PROG(VARIABLE, PROG-TO-CHECK-FOR,
1365 # [VALUE-IF-NOT-FOUND], [PATH], [REJECT])
1366 # -----------------------------------------------------
1367 # HACK: A small wrapper around AC_CHECK_PROG, setting VARIABLE to the full path
1368 # of PROG-TO-CHECK-FOR when found.
1369 AC_DEFUN([FP_CHECK_PROG],
1370 [AC_CHECK_PROG([$1], [$2], [$as_dir/$ac_word$ac_exec_ext], [$3], [$4], [$5])][]dnl
1376 # Find a non-WinDoze version of the "find" utility.
1377 AC_DEFUN([FP_PROG_FIND],
1378 [AC_PATH_PROGS([fp_prog_find], [gfind find], find)
1379 echo foo > conftest.txt
1380 $fp_prog_find conftest.txt -print > conftest.out 2>&1
1381 if grep '^conftest.txt$' conftest.out > /dev/null 2>&1 ; then
1382 # OK, looks like a real "find".
1383 FindCmd="$fp_prog_find"
1385 # Found a poor WinDoze version of "find", ignore it.
1386 AC_MSG_WARN([$fp_prog_find looks like a non-*nix find, ignoring it])
1387 FP_CHECK_PROG([FindCmd], [find], [], [], [$fp_prog_find])
1389 rm -f conftest.txt conftest.out
1390 AC_SUBST([FindCmd])[]dnl
1396 # Find a Unix-like sort
1397 AC_DEFUN([FP_PROG_SORT],
1398 [AC_PATH_PROG([fp_prog_sort], [sort])
1399 echo conwip > conftest.txt
1400 $fp_prog_sort -f conftest.txt > conftest.out 2>&1
1401 if grep 'conwip' conftest.out > /dev/null 2>&1 ; then
1403 SortCmd="$fp_prog_sort"
1405 # Summink else..pick next one.
1406 AC_MSG_WARN([$fp_prog_sort looks like a non-*nix sort, ignoring it])
1407 FP_CHECK_PROG([SortCmd], [sort], [], [], [$fp_prog_sort])
1409 rm -f conftest.txt conftest.out
1410 AC_SUBST([SortCmd])[]dnl
1415 dnl FPTOOLS_NOCACHE_CHECK prints a message, then sets the
1416 dnl values of the second argument to the result of running
1417 dnl the commands given by the third. It does not cache its
1418 dnl result, so it is suitable for checks which should be
1421 AC_DEFUN([FPTOOLS_NOCACHE_CHECK],
1422 [AC_MSG_CHECKING([$1])
1424 AC_MSG_RESULT([$][$2])
1428 dnl FPTOOLS_GHC_VERSION(version)
1429 dnl FPTOOLS_GHC_VERSION(major, minor [, patchlevel])
1430 dnl FPTOOLS_GHC_VERSION(version, major, minor, patchlevel)
1432 dnl Test for version of installed ghc. Uses $GHC.
1433 dnl [original version pinched from c2hs]
1435 AC_DEFUN([FPTOOLS_GHC_VERSION],
1436 [FPTOOLS_NOCACHE_CHECK([version of ghc], [fptools_version_of_ghc],
1437 ["${WithGhc-ghc}" --version > conftestghc 2>&1
1438 cat conftestghc >&AS_MESSAGE_LOG_FD
1439 #Useless Use Of cat award...
1440 fptools_version_of_ghc=`cat conftestghc | sed -n -e 's/, patchlevel *\([[0-9]]\)/.\1/;s/.* version \([[0-9]][[0-9.]]*\).*/\1/p'`
1442 if test "[$]fptools_version_of_ghc" = ""
1444 fptools_version_of_ghc='unknown'
1446 fptools_version_of_ghc[_major]=`echo [$]fptools_version_of_ghc | sed -e 's/^\([[0-9]]\).*/\1/'`
1447 fptools_version_of_ghc[_minor]=`echo [$]fptools_version_of_ghc | sed -e 's/^[[0-9]]\.\([[0-9]]*\).*/\1/'`
1448 fptools_version_of_ghc[_pl]=`echo [$]fptools_version_of_ghc | sed -n -e 's/^[[0-9]]\.[[0-9]]*\.\([[0-9]]*\)/\1/p'`
1450 if test "[$]fptools_version_of_ghc[_pl]" = ""
1452 fptools_version_of_ghc[_all]="[$]fptools_version_of_ghc[_major].[$]fptools_version_of_ghc[_minor]"
1453 fptools_version_of_ghc[_pl]="0"
1455 fptools_version_of_ghc[_all]="[$]fptools_version_of_ghc[_major].[$]fptools_version_of_ghc[_minor].[$]fptools_version_of_ghc[_pl]"
1458 ifelse($#, [1], [dnl
1459 [$1]="[$]fptools_version_of_ghc[_all]"
1461 [$1]="[$]fptools_version_of_ghc[_major]"
1462 [$2]="[$]fptools_version_of_ghc[_minor]"
1464 [$1]="[$]fptools_version_of_ghc[_major]"
1465 [$2]="[$]fptools_version_of_ghc[_minor]"
1466 [$3]="[$]fptools_version_of_ghc[_pl]"
1468 [$1]="[$]fptools_version_of_ghc[_all]"
1469 [$2]="[$]fptools_version_of_ghc[_major]"
1470 [$3]="[$]fptools_version_of_ghc[_minor]"
1471 [$4]="[$]fptools_version_of_ghc[_pl]"
1477 # FP_CHECK_FUNC(FUNCTION, PROLOGUE, BODY, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
1478 # ---------------------------------------------------------------------------------
1479 # A variant of AC_CHECK_FUNCS, limited to a single FUNCTION, but with the
1480 # additional flexibility of specifying the PROLOGUE and BODY.
1481 AC_DEFUN([FP_CHECK_FUNC],
1482 [AS_VAR_PUSHDEF([fp_func], [fp_cv_func_$1])dnl
1483 AC_CACHE_CHECK([for $1], fp_func,
1484 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], [$3])],
1485 [AS_VAR_SET(fp_func, yes)],
1486 [AS_VAR_SET(fp_func, no)])])
1487 AS_IF([test AS_VAR_GET(fp_func) = yes],
1488 [AC_DEFINE(AS_TR_CPP(HAVE_$1), [1],
1489 [Define to 1 if you have the `]$1[' function.]) $4],
1491 AS_VAR_POPDEF([fp_func])dnl
1496 # Try to find a ghc-pkg matching the ghc mentioned in the environment variable
1497 # WithGhc. Sets the output variable GhcPkgCmd.
1498 AC_DEFUN([FP_PROG_GHC_PKG],
1499 [AC_CACHE_CHECK([for ghc-pkg matching $WithGhc], fp_cv_matching_ghc_pkg,
1501 # If we are told to use ghc-stage2, then we're using an in-tree
1502 # compiler. In this case, we just want ghc-pkg, not ghc-pkg-stage2,
1503 # so we sed off -stage[0-9]$. However, if we are told to use
1504 # ghc-6.12.1 then we want to use ghc-pkg-6.12.1, so we keep any
1506 fp_ghc_pkg_guess=`echo "$WithGhc" | sed -e 's/-stage@<:@0-9@:>@$//' -e 's,ghc\(@<:@^/\\@:>@*\)$,ghc-pkg\1,'`
1507 if "$fp_ghc_pkg_guess" list > /dev/null 2>&1; then
1508 fp_cv_matching_ghc_pkg=$fp_ghc_pkg_guess
1510 AC_MSG_ERROR([Cannot find matching ghc-pkg])
1512 GhcPkgCmd=$fp_cv_matching_ghc_pkg
1513 AC_SUBST([GhcPkgCmd])
1517 # FP_GCC_EXTRA_FLAGS
1518 # ------------------
1519 # Determine which extra flags we need to pass gcc when we invoke it
1520 # to compile .hc code.
1522 # -fwrapv is needed for gcc to emit well-behaved code in the presence of
1523 # integer wrap around. (Trac #952)
1525 AC_DEFUN([FP_GCC_EXTRA_FLAGS],
1526 [AC_REQUIRE([FP_GCC_VERSION])
1527 AC_CACHE_CHECK([for extra options to pass gcc when compiling via C], [fp_cv_gcc_extra_opts],
1528 [fp_cv_gcc_extra_opts=
1529 FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-ge], [3.4],
1530 [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fwrapv"],
1532 FP_COMPARE_VERSIONS([$fp_cv_gcc_version], [-ge], [4.0],
1533 [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fno-builtin"],
1536 AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts)
1540 # FP_SETUP_PROJECT_VERSION
1541 # ---------------------
1542 AC_DEFUN([FP_SETUP_PROJECT_VERSION],
1544 if test "$RELEASE" = "NO"; then
1545 AC_MSG_CHECKING([for GHC version date])
1546 if test -f VERSION_DATE; then
1547 PACKAGE_VERSION=${PACKAGE_VERSION}.`cat VERSION_DATE`
1548 AC_MSG_RESULT(given $PACKAGE_VERSION)
1549 elif test -d .git; then
1551 ver_posixtime=`git log -1 --pretty=format:%ct`
1552 ver_date=`perl -MPOSIX -e "print strftime('%Y%m%d', gmtime($ver_posixtime));"`
1553 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
1554 changequote([, ])dnl
1555 AC_MSG_ERROR([failed to detect version date: check that git and perl are in your path])
1557 PACKAGE_VERSION=${PACKAGE_VERSION}.$ver_date
1558 AC_MSG_RESULT(inferred $PACKAGE_VERSION)
1559 elif test -f VERSION; then
1560 PACKAGE_VERSION=`cat VERSION`
1561 AC_MSG_RESULT(given $PACKAGE_VERSION)
1563 AC_MSG_WARN([cannot determine snapshot version: no .git directory and no VERSION file])
1564 dnl We'd really rather this case didn't happen, but it might
1565 dnl do (in particular, people using lndir trees may find that
1566 dnl the build system can't find any other date). If it does
1567 dnl happen, then we use the current date.
1568 dnl This way we get some idea about how recent a build is.
1569 dnl It also means that packages built for 2 different builds
1570 dnl will probably use different version numbers, so things are
1571 dnl less likely to go wrong.
1572 PACKAGE_VERSION=${PACKAGE_VERSION}.`date +%Y%m%d`
1576 AC_MSG_CHECKING([for GHC Git commit id])
1577 if test -d .git; then
1578 git_commit_id=`git rev-parse HEAD`
1579 if test -n "$git_commit_id" 2>&1 >/dev/null; then true; else
1580 AC_MSG_ERROR([failed to detect revision: check that git is in your path])
1582 PACKAGE_GIT_COMMIT_ID=$git_commit_id
1583 AC_MSG_RESULT(inferred $PACKAGE_GIT_COMMIT_ID)
1584 elif test -f GIT_COMMIT_ID; then
1585 PACKAGE_GIT_COMMIT_ID=`cat GIT_COMMIT_ID`
1586 AC_MSG_RESULT(given $PACKAGE_GIT_COMMIT_ID)
1588 AC_MSG_WARN([cannot determine snapshot revision: no .git directory and no 'GIT_COMMIT_ID' file])
1589 PACKAGE_GIT_COMMIT_ID="0000000000000000000000000000000000000000"
1594 AC_SUBST([ProjectName], [$PACKAGE_NAME])
1595 AC_SUBST([ProjectVersion], [$PACKAGE_VERSION])
1596 AC_SUBST([ProjectGitCommitId], [$PACKAGE_GIT_COMMIT_ID])
1598 # Split PACKAGE_VERSION into (possibly empty) parts
1599 VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
1600 VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
1601 VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
1602 ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
1604 # Calculate project version as an integer, using 2 digits for minor version
1605 case $VERSION_MINOR in
1606 ?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;
1607 ??) ProjectVersionInt=${VERSION_MAJOR}${VERSION_MINOR} ;;
1608 *) AC_MSG_ERROR([bad minor version in $PACKAGE_VERSION]) ;;
1610 AC_SUBST([ProjectVersionInt])
1612 # The project patchlevel is zero unless stated otherwise
1613 test -z "$ProjectPatchLevel" && ProjectPatchLevel=0
1615 # Save split version of ProjectPatchLevel
1616 ProjectPatchLevel1=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1/'`
1617 ProjectPatchLevel2=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3/'`
1619 AC_SUBST([ProjectPatchLevel1])
1620 AC_SUBST([ProjectPatchLevel2])
1622 # Remove dots from the patch level; this allows us to have versions like 6.4.1.20050508
1623 ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'`
1625 AC_SUBST([ProjectPatchLevel])
1627 # The version of the GHC package changes every day, since the
1628 # patchlevel is the current date. We don't want to force
1629 # recompilation of the entire compiler when this happens, so for
1630 # GHC HEAD we omit the patchlevel from the package version number.
1632 # The ProjectPatchLevel1 > 20000000 iff GHC HEAD. If it's for a stable
1633 # release like 7.10.1 or for a release candidate such as 7.10.1.20141224
1634 # then we don't omit the patchlevel components.
1636 ProjectVersionMunged="$ProjectVersion"
1637 if test "$ProjectPatchLevel1" -gt 20000000; then
1638 ProjectVersionMunged="${VERSION_MAJOR}.${VERSION_MINOR}"
1640 AC_SUBST([ProjectVersionMunged])
1641 ])# FP_SETUP_PROJECT_VERSION
1643 # Check for a working timer_create(). We need a pretty detailed check
1644 # here, because there exist partially-working implementations of
1645 # timer_create() in certain versions of Linux (see bug #1933).
1647 AC_DEFUN([FP_CHECK_TIMER_CREATE],[
1648 AC_CHECK_FUNC([timer_create],[HAVE_timer_create=yes],[HAVE_timer_create=no])
1650 if test "$HAVE_timer_create" = "yes"
1652 if test "$cross_compiling" = "yes"
1654 # We can't test timer_create when we're cross-compiling, so we
1655 # optimistiaclly assume that it actually works properly.
1656 AC_DEFINE([USE_TIMER_CREATE], 1, [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)])
1658 AC_CACHE_CHECK([for a working timer_create(CLOCK_REALTIME)],
1659 [fptools_cv_timer_create_works],
1662 #ifdef HAVE_STDLIB_H
1668 #ifdef HAVE_SIGNAL_H
1671 #ifdef HAVE_UNISTD_H
1675 static volatile int tock = 0;
1676 static void handler(int i)
1681 static void timeout(int i)
1683 // timer_settime() has been known to hang, so just in case
1684 // we install a 1-second timeout (see #2257)
1688 int main(int argc, char *argv[])
1693 struct itimerspec it;
1694 struct sigaction action;
1697 ev.sigev_notify = SIGEV_SIGNAL;
1698 ev.sigev_signo = SIGVTALRM;
1700 action.sa_handler = handler;
1701 action.sa_flags = 0;
1702 sigemptyset(&action.sa_mask);
1703 if (sigaction(SIGVTALRM, &action, NULL) == -1) {
1704 fprintf(stderr,"SIGVTALRM problem\n");
1708 action.sa_handler = timeout;
1709 action.sa_flags = 0;
1710 sigemptyset(&action.sa_mask);
1711 if (sigaction(SIGALRM, &action, NULL) == -1) {
1712 fprintf(stderr,"SIGALRM problem\n");
1717 if (timer_create(CLOCK_REALTIME, &ev, &timer) != 0) {
1718 fprintf(stderr,"No CLOCK_REALTIME timer\n");
1724 it.it_value.tv_sec = 0;
1725 it.it_value.tv_nsec = 1000000; // 1ms
1726 it.it_interval = it.it_value;
1727 if (timer_settime(timer, 0, &it, NULL) != 0) {
1728 fprintf(stderr,"settime problem\n");
1732 // some environments have coarse scheduler/timer granularity of ~10ms and worse
1733 usleep(100000); // 100ms
1736 fprintf(stderr,"no CLOCK_REALTIME signal\n");
1740 timer_delete(timer);
1745 [fptools_cv_timer_create_works=yes],
1746 [fptools_cv_timer_create_works=no])
1748 case $fptools_cv_timer_create_works in
1749 yes) AC_DEFINE([USE_TIMER_CREATE], 1,
1750 [Define to 1 if we can use timer_create(CLOCK_REALTIME,...)]);;
1758 AC_DEFUN([FP_ICONV],
1760 dnl--------------------------------------------------------------------
1761 dnl * Deal with arguments telling us iconv is somewhere odd
1762 dnl--------------------------------------------------------------------
1764 dnl Note: ICONV_LIB_DIRS and ICONV_INCLUDE_DIRS are not predefined
1765 dnl to the empty string to allow them to be overridden from the
1768 AC_ARG_WITH([iconv-includes],
1769 [AC_HELP_STRING([--with-iconv-includes],
1770 [directory containing iconv.h])],
1771 [ICONV_INCLUDE_DIRS=$withval])
1773 AC_ARG_WITH([iconv-libraries],
1774 [AC_HELP_STRING([--with-iconv-libraries],
1775 [directory containing iconv library])],
1776 [ICONV_LIB_DIRS=$withval])
1778 AC_SUBST(ICONV_INCLUDE_DIRS)
1779 AC_SUBST(ICONV_LIB_DIRS)
1786 dnl--------------------------------------------------------------------
1787 dnl * Deal with arguments telling us gmp is somewhere odd
1788 dnl--------------------------------------------------------------------
1790 AC_ARG_WITH([gmp-includes],
1791 [AC_HELP_STRING([--with-gmp-includes],
1792 [directory containing gmp.h])],
1793 [GMP_INCLUDE_DIRS=$withval])
1795 AC_ARG_WITH([gmp-libraries],
1796 [AC_HELP_STRING([--with-gmp-libraries],
1797 [directory containing gmp library])],
1798 [GMP_LIB_DIRS=$withval])
1800 AC_SUBST(GMP_INCLUDE_DIRS)
1801 AC_SUBST(GMP_LIB_DIRS)
1806 AC_DEFUN([FP_CURSES],
1808 dnl--------------------------------------------------------------------
1809 dnl * Deal with arguments telling us curses is somewhere odd
1810 dnl--------------------------------------------------------------------
1812 AC_ARG_WITH([curses-includes],
1813 [AC_HELP_STRING([--with-curses-includes],
1814 [directory containing curses headers])],
1815 [CURSES_INCLUDE_DIRS=$withval])
1817 AC_ARG_WITH([curses-libraries],
1818 [AC_HELP_STRING([--with-curses-libraries],
1819 [directory containing curses libraries])],
1820 [CURSES_LIB_DIRS=$withval])
1822 AC_SUBST(CURSES_INCLUDE_DIRS)
1823 AC_SUBST(CURSES_LIB_DIRS)
1826 # --------------------------------------------------------------
1827 # Calculate absolute path to build tree
1828 # --------------------------------------------------------------
1830 AC_DEFUN([FP_FIND_ROOT],[
1831 AC_MSG_CHECKING(for path to top of build tree)
1832 if test "$windows" = YES
1834 dnl Make sure this is a c:/foo/bar (mixed) style path. Some parts of
1835 dnl the build system might depend on it (such as the sed expression
1836 dnl `"s|$(TOP)/||i"` in addCFileDeps in rules/build-dependencies.mk).
1837 hardtop=$(cygpath -m "$(pwd)")
1842 dnl Remove common automounter nonsense
1843 hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|'`
1845 if ! test -d "$hardtop"; then
1846 AC_MSG_ERROR([cannot determine current directory])
1849 dnl We don't support building in directories with spaces.
1853 The build system does not support building in a directory
1854 containing space characters.
1855 Suggestion: move the build tree somewhere else.])
1861 AC_MSG_RESULT($hardtop)
1864 # GHC_CONVERT_CPU(cpu, target_var)
1865 # --------------------------------
1866 # converts cpu from gnu to ghc naming, and assigns the result to $target_var
1867 AC_DEFUN([GHC_CONVERT_CPU],[
1884 i386|i486|i586|i686)
1936 echo "Unknown CPU $1"
1942 # GHC_CONVERT_VENDOR(vendor, target_var)
1943 # --------------------------------
1944 # converts vendor from gnu to ghc naming, and assigns the result to $target_var
1945 AC_DEFUN([GHC_CONVERT_VENDOR],[
1947 pc|gentoo|w64) # like i686-pc-linux-gnu, i686-gentoo-freebsd8, x86_64-w64-mingw32
1950 softfloat) # like armv5tel-softfloat-linux-gnueabi
1953 hardfloat) # like armv7a-hardfloat-linux-gnueabi
1957 #pass thru by default
1963 # GHC_CONVERT_OS(os, converted_cpu, target_var)
1964 # --------------------------------
1965 # converts os from gnu to ghc naming, and assigns the result to $target_var
1966 AC_DEFUN([GHC_CONVERT_OS],[
1968 darwin10-arm|darwin11-i386|darwin14-aarch64|darwin14-x86_64)
1979 # As far as I'm aware, none of these have relevant variants
1980 freebsd|netbsd|openbsd|dragonfly|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|haiku)
1983 aix*) # e.g. powerpc-ibm-aix7.1.3.0
1986 freebsd*) # like i686-gentoo-freebsd7
1987 # i686-gentoo-freebsd8
1988 # i686-gentoo-freebsd8.2
1995 echo "Unknown OS $1"
2003 # BOOTSTRAPPING_GHC_INFO_FIELD
2004 # --------------------------------
2005 # Set the variable $1 to the value of the ghc --info field $2.
2006 AC_DEFUN([BOOTSTRAPPING_GHC_INFO_FIELD],[
2007 $1=`"$WithGhc" --info | grep "^ ,(\"$2\"," | sed -e 's/.*","//' -e 's/")$//'`
2009 if test "${$1}" != "$tmp"
2011 topdir=`"$WithGhc" --print-libdir | sed 's#\\\\#/#g'`
2017 # LIBRARY_VERSION(lib, [dir])
2018 # --------------------------------
2019 # Gets the version number of a library.
2020 # If $1 is ghc-prim, then we define LIBRARY_ghc_prim_VERSION as 1.2.3
2021 # $2 points to the directory under libraries/
2022 AC_DEFUN([LIBRARY_VERSION],[
2023 dir=m4_default([$2],[$1])
2024 LIBRARY_[]translit([$1], [-], [_])[]_VERSION=`grep -i "^version:" libraries/${dir}/$1.cabal | sed "s/.* //"`
2025 AC_SUBST(LIBRARY_[]translit([$1], [-], [_])[]_VERSION)
2029 # --------------------------------
2030 # Gets the version number of XCode, if on a Mac
2031 AC_DEFUN([XCODE_VERSION],[
2032 if test "$TargetOS_CPP" = "darwin"
2034 AC_MSG_CHECKING(XCode version)
2035 XCodeVersion=`xcodebuild -version | grep Xcode | sed "s/Xcode //"`
2036 # Old XCode versions don't actually give the XCode version
2037 if test "$XCodeVersion" = ""
2039 AC_MSG_RESULT(not found (too old?))
2043 AC_MSG_RESULT($XCodeVersion)
2044 XCodeVersion1=`echo "$XCodeVersion" | sed 's/\..*//'`
2046 XCodeVersion2=`echo "$XCodeVersion" | sed 's/[^.]*\.\([^.]*\).*/\1/'`
2047 changequote([, ])dnl
2048 AC_MSG_NOTICE(XCode version component 1: $XCodeVersion1)
2049 AC_MSG_NOTICE(XCode version component 2: $XCodeVersion2)
2055 # --------------------------------
2056 # Find where the llvm tools are. We have a special function to handle when they
2057 # are installed with a version suffix (e.g., llc-3.1).
2059 # $1 = the variable to set
2060 # $2 = the with option name
2061 # $3 = the command to look for
2062 # $4 = the version of the command to look for
2064 AC_DEFUN([FIND_LLVM_PROG],[
2065 # Test for program with version name.
2066 FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3-$4])
2067 if test -z "$$1"; then
2068 # Test for program without version name.
2069 FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL_NOTARGET([$1], [$2], [$3])
2070 if test -n "$$1"; then
2071 AC_MSG_CHECKING([$$1 is version $4])
2072 if test `$$1 --version | grep -c "version $4"` -gt 0 ; then
2083 # Find the version of `ld` to use. This is used in both in the top level
2084 # configure.ac and in distrib/configure.ac.in.
2086 # $1 = the variable to set
2088 AC_DEFUN([FIND_LD],[
2089 FP_ARG_WITH_PATH_GNU_PROG([LD], [ld], [ld])
2093 # Arm and Aarch64 requires use of the binutils ld.gold linker.
2094 # This case should catch at least arm-unknown-linux-gnueabihf,
2095 # arm-linux-androideabi, arm64-unknown-linux and
2096 # aarch64-linux-android
2097 FP_ARG_WITH_PATH_GNU_PROG([LD_GOLD], [ld.gold], [ld.gold])
2106 # FIND_GHC_BOOTSTRAP_PROG()
2107 # --------------------------------
2108 # Parse the bootstrap GHC's compier settings file for the location of things
2109 # like the `llc` and `opt` commands.
2111 # $1 = the variable to set
2112 # $2 = The bootstrap compiler.
2113 # $3 = The string to grep for to find the correct line.
2115 AC_DEFUN([FIND_GHC_BOOTSTRAP_PROG],[
2116 BootstrapTmpCmd=`grep $3 $($2 --print-libdir)/settings 2>/dev/null | sed 's/.*", "//;s/".*//'`
2117 if test -n "$BootstrapTmpCmd" && test `basename $BootstrapTmpCmd` = $BootstrapTmpCmd ; then
2118 AC_PATH_PROG([$1], [$BootstrapTmpCmd], "")
2125 AC_DEFUN([MAYBE_OVERRIDE_STAGE0],[
2126 if test ! -z "$With_$1" -a "$CrossCompiling" != "YES"; then
2127 AC_MSG_NOTICE([Not cross-compiling, so --with-$1 also sets $2])
2133 # FP_CPP_CMD_WITH_ARGS()
2134 # ----------------------
2135 # sets CPP command and its arguments
2137 # $1 = the variable to set to CPP command
2138 # $2 = the varibale to set to CPP command arguments
2140 AC_DEFUN([FP_CPP_CMD_WITH_ARGS],[
2141 dnl ** what cpp to use?
2142 dnl --------------------------------------------------------------
2144 [AC_HELP_STRING([--with-hs-cpp=ARG],
2145 [Path to the (C) preprocessor for Haskell files [default=autodetect]])],
2147 if test "$HostOS" = "mingw32"
2149 AC_MSG_WARN([Request to use $withval will be ignored])
2156 # We can't use $CPP here, since HS_CPP_CMD is expected to be a single
2157 # command (no flags), and AC_PROG_CPP defines CPP as "/usr/bin/gcc -E".
2160 SOLARIS_GCC_CPP_BROKEN=NO
2161 SOLARIS_FOUND_GOOD_CPP=NO
2164 GCC_MAJOR_MINOR=`$CC --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
2165 if test "$GCC_MAJOR_MINOR" != "3.4"; then
2166 # this is not 3.4.x release so with broken CPP
2167 SOLARIS_GCC_CPP_BROKEN=YES
2172 if test "$SOLARIS_GCC_CPP_BROKEN" = "YES"; then
2173 # let's try to find if GNU C 3.4.x is installed
2174 if test -x /usr/sfw/bin/gcc; then
2175 # something executable is in expected path so let's
2176 # see if it's really GNU C
2177 NEW_GCC_MAJOR_MINOR=`/usr/sfw/bin/gcc --version|grep "gcc (GCC)"|cut -d ' ' -f 3-3|cut -d '.' -f 1-2`
2178 if test "$NEW_GCC_MAJOR_MINOR" = "3.4"; then
2179 # this is GNU C 3.4.x which provides non-broken CPP on Solaris
2180 # let's use it as CPP then.
2181 HS_CPP_CMD=/usr/sfw/bin/gcc
2182 SOLARIS_FOUND_GOOD_CPP=YES
2185 if test "$SOLARIS_FOUND_GOOD_CPP" = "NO"; then
2186 AC_MSG_WARN([Your GNU C provides broken CPP and you do not have GNU C 3.4.x installed.])
2187 AC_MSG_WARN([Please install GNU C 3.4.x to solve this issue. It will be used as CPP only.])
2195 dnl ** what cpp flags to use?
2196 dnl -----------------------------------------------------------
2197 AC_ARG_WITH(hs-cpp-flags,
2198 [AC_HELP_STRING([--with-hs-cpp-flags=ARG],
2199 [Flags to the (C) preprocessor for Haskell files [default=autodetect]])],
2201 if test "$HostOS" = "mingw32"
2203 AC_MSG_WARN([Request to use $withval will be ignored])
2205 HS_CPP_ARGS=$withval
2209 $HS_CPP_CMD -x c /dev/null -dM -E > conftest.txt 2>&1
2210 if grep "__clang__" conftest.txt >/dev/null 2>&1; then
2211 HS_CPP_ARGS="-E -undef -traditional -Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
2213 $HS_CPP_CMD -v > conftest.txt 2>&1
2214 if grep "gcc" conftest.txt >/dev/null 2>&1; then
2215 HS_CPP_ARGS="-E -undef -traditional"
2217 $HS_CPP_CMD --version > conftest.txt 2>&1
2218 if grep "cpphs" conftest.txt >/dev/null 2>&1; then
2219 HS_CPP_ARGS="--cpp -traditional"
2221 AC_MSG_WARN([configure can't recognize your CPP program, you may need to set --with-hs-cpp-flags=FLAGS explicitly])
2235 # ----------------------
2236 # whether to use libbfd for debugging RTS
2237 AC_DEFUN([FP_BFD_SUPPORT], [
2238 AC_ARG_ENABLE(bfd-debug,
2239 [AC_HELP_STRING([--enable-bfd-debug],
2240 [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
2242 # don't pollute general LIBS environment
2244 AC_CHECK_HEADERS([bfd.h])
2245 dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
2246 dnl the order of these tests matters: bfd needs libiberty
2247 AC_CHECK_LIB(iberty, xmalloc)
2248 dnl 'bfd_init' is a rare non-macro in libbfd
2249 AC_CHECK_LIB(bfd, bfd_init)
2251 AC_TRY_LINK([#include <bfd.h>],
2253 /* mimic our rts/Printer.c */
2258 name = "some.executable";
2260 abfd = bfd_openr(name, "default");
2261 bfd_check_format_matches (abfd, bfd_object, &matching);
2263 long storage_needed;
2264 storage_needed = bfd_get_symtab_upper_bound (abfd);
2267 asymbol **symbol_table;
2268 long number_of_symbols;
2271 number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
2272 bfd_get_symbol_info(abfd,symbol_table[0],&info);
2275 [],dnl bfd seems to work
2276 [AC_MSG_ERROR([can't use 'bfd' library])])