File: ac_check_mpfi.m4

package info (click to toggle)
gap-float 1.0.7%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 640 kB
  • sloc: ansic: 2,154; cpp: 2,018; xml: 194; makefile: 112; sh: 1
file content (89 lines) | stat: -rw-r--r-- 2,248 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# check for mpfi library
# sets MPFI_CPPFLAGS, MPFI_LDFLAGS and MPFI_LIBS,
# and MPFI=yes/no

AC_DEFUN([AC_CHECK_MPFI],[
temp_LIBS="$LIBS"
temp_CPPFLAGS="$CPPFLAGS"
temp_LDFLAGS="$LDFLAGS"
MPFI=unknown

AC_ARG_WITH([mpfi],
 [AS_HELP_STRING([--with-mpfi=<location>],
   [Location at which the MPFI library was installed.
    If the argument is omitted, the library is assumed to be reachable
    under the standard search path (/usr, /usr/local,...).  Otherwise
    you must give the <path> to the directory which contains the
    library..])],
 [if test "$withval" = no; then
    MPFI=no
  elif test "$withval" = yes; then
    MPFI=yes
  else
    MPFI=yes
    MPFI_CPPFLAGS="-I$withval/include"
    MPFI_LDFLAGS="-L$withval/lib"
  fi],
  [AS_IF([command -v brew --prefix mpfi >/dev/null 2>&1],[
    AC_MSG_NOTICE([BREW mpfi detected])
    withval=$(brew --prefix)
    MPFI=yes
    MPFI_CPPFLAGS="-I$withval/include"
    MPFI_LDFLAGS="-L$withval/lib"
  ])]
)

AC_ARG_WITH([mpfi-include],
 [AS_HELP_STRING([--with-mpfi-include=<location>],
   [Location at which the mpfi include files were installed.])],
 [MPFI=yes
  MPFI_CPPFLAGS="-I$withval"]
)

AC_ARG_WITH([mpfi-lib],
 [AS_HELP_STRING([--with-mpfi-lib=<location>],
   [Location at which the mpfi library files were installed.])],
 [MPFI=yes
  MPFI_LDFLAGS="-L$withval"]
)

if test "$MPFI" != no; then

if test "$MPFR" = no; then
    AC_MSG_ERROR([Cannot have MPFI without having MPFR too.])
fi

MPFI_LIBS="-lmpfi"

AC_LANG_PUSH([C])
temp_status=true
CPPFLAGS="$CPPFLAGS $MPFI_CPPFLAGS $MPFR_CPPFLAGS"
AC_CHECK_HEADER(mpfi.h,,[temp_status=false],[#include <mpfr.h>])
LDFLAGS="$LDFLAGS $MPFI_LDFLAGS $MPFR_LDFLAGS"
AC_CHECK_LIB(mpfi,mpfi_sqrt,,[temp_status=false])
AC_LANG_POP([C])

if test "$temp_status" = false; then
    if test "$MPFI" = yes; then
        AC_MSG_ERROR([library mpfi not found. Using --with-mpfi, specify its location, or "no" to disable it.])
    else
        MPFI=no
    fi
else
    MPFI=yes
fi

fi

CPPFLAGS="$temp_CPPFLAGS"
LDFLAGS="$temp_LDFLAGS"
LIBS="$temp_LIBS"

if test "$MPFI" != no; then
    AC_DEFINE([USE_MPFI],1,[use MPFI library])
fi
AC_SUBST(MPFI_CPPFLAGS)
AC_SUBST(MPFI_LDFLAGS)
AC_SUBST(MPFI_LIBS)
AM_CONDITIONAL([WITH_MPFI_IS_YES],[test x"$MPFI" != xno])
])