-# FP_PATH_XTRA
-# ------------
-# Same as AC_PATH_XTRA, but works even for broken Cygwins which try to include
-# the non-existant <gl/mesa_wgl.h> header when -mno-cygwin is used.
-AC_DEFUN([FP_PATH_XTRA],
-[AC_REQUIRE([FP_CHECK_WIN32])
-if test x"$is_win32" = xyes; then
- no_x=yes
-else
- AC_PATH_XTRA
-fi
-])# FP_PATH_XTRA
-
-
-# FP_CHECK_GL_HELPER(LIBNAME, LIBS, INCLUDES, FUNCTION-BODY)
-# ----------------------------------------------------------
-# Try each library in LIBS to successfully link INCLUDES plus FUNCTION-BODY,
-# setting LIBNAME_CFLAGS and LIBNAME_LIBS to the corresponding values. Sets
-# no_LIBNAME to "yes" if no suitable library was found. (LIBNAME_CFLAGS0
-# contains the value of LIBNAME_CFLAGS without CPPFLAGS, and LIBNAME_LIBS0
-# contains the value of LIBNAME_LIBS without LDFLAGS, but these are only
-# used internally.)
-AC_DEFUN([FP_CHECK_GL_HELPER],
-[AC_CACHE_CHECK([for $1 library], [fp_cv_check_$1_lib],
- [fp_cv_check_$1_lib="no"
- fp_save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="$CPPFLAGS ${$1_CFLAGS}"
- fp_save_LIBS="$LIBS"
- for fp_try_lib in $2; do
- # transform "-lfoo" to "foo.lib" when using cl
- if test x"$CC" = xcl; then
- fp_try_lib=`echo $fp_try_lib | sed -e 's/^-l//' -e 's/$/.lib/'`
- fi
- LIBS="$fp_try_lib ${$1_LIBS} $fp_save_LIBS"
- AC_TRY_LINK([$3], [$4], [fp_cv_check_$1_lib="$fp_try_lib ${$1_LIBS}"; break])
- done
- LIBS="$fp_save_LIBS"
- CPPFLAGS="$fp_save_CPPFLAGS"])
-
- if test x"$fp_cv_check_$1_lib" = xno; then
- no_$1=yes
- $1_CFLAGS=
- $1_LIBS=
- else
- $1_CFLAGS0="${$1_CFLAGS}"
- $1_CFLAGS="$CPPFLAGS ${$1_CFLAGS0}"
- $1_LIBS0="$fp_cv_check_$1_lib"
- $1_LIBS="$LDFLAGS ${$1_LIBS0}"
- fi
-])# FP_CHECK_GL_HELPER
-
-
-# FP_CHECK_GL
-# -----------
-AC_DEFUN([FP_CHECK_GL],
-[AC_REQUIRE([FP_PATH_X])
-AC_REQUIRE([AC_CANONICAL_SYSTEM])
-
-AC_ARG_ENABLE([hopengl],
- [AC_HELP_STRING([--enable-hopengl],
- [build a Haskell binding for OpenGL (GL/GLU). On Mac OS X, use
- --enable-hopengl=x11 to use X11 instead of the "native" libraries.
- (default=no)])],
- [enable_opengl=$enableval], [enable_opengl=no])
-
-if test x"$enable_opengl" = xno; then
- no_GL=yes
-else
- use_quartz_opengl=no
- case $target_os in
- darwin*)
- if test x"$enable_opengl" != xx11; then
- AC_DEFINE([USE_QUARTZ_OPENGL], [1],
- [Define to 1 if native OpenGL should be used on Mac OS X])
- use_quartz_opengl=yes
- fi
- ;;
- esac
-
- if test x"$use_quartz_opengl" != xyes; then
- AC_CHECK_LIB([m], [atan], [GL_LIBS="-lm $GL_LIBS"])
+# FP_GCC_EXTRA_FLAGS
+# ------------------
+# Determine which extra flags we need to pass gcc when we invoke it
+# to compile .hc code.
+#
+# Some OSs (Mandrake Linux, in particular) configure GCC with
+# -momit-leaf-frame-pointer on by default. If this is the case, we
+# need to turn it off for mangling to work. The test is currently a
+# bit crude, using only the version number of gcc.
+#
+# -fwrapv is needed for gcc to emit well-behaved code in the presence of
+# integer wrap around. (Trac #952)
+#
+# -fno-unit-at-a-time or -fno-toplevel-reoder is necessary to avoid gcc
+# reordering things in the module and confusing the manger and/or splitter.
+# (eg. Trac #1427)
+#
+AC_DEFUN([FP_GCC_EXTRA_FLAGS],
+[AC_REQUIRE([FP_HAVE_GCC])
+AC_CACHE_CHECK([for extra options to pass gcc when compiling via C], [fp_cv_gcc_extra_opts],
+[fp_cv_gcc_extra_opts=
+ FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.4],
+ [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fwrapv"],
+ [])
+ case $TargetPlatform in
+ i386-*|x86_64-*)
+ FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.2],
+ [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -mno-omit-leaf-frame-pointer"],
+ [])
+ FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [3.4],
+ [FP_COMPARE_VERSIONS([$fp_gcc_version], [-ge], [4.2],
+ [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fno-toplevel-reorder"],
+ [fp_cv_gcc_extra_opts="$fp_cv_gcc_extra_opts -fno-unit-at-a-time"]
+ )],
+ [])
+ ;;
+ esac
+])
+AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts)
+])