summaryrefslogtreecommitdiff
path: root/math/mpfr/builtin.mk
blob: 5ce5343e17e3178f4df7200fc37d37561633ed70 (plain)
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
# $NetBSD: builtin.mk,v 1.7 2020/09/03 08:58:42 prlw1 Exp $

BUILTIN_PKG:=	mpfr

BUILTIN_FIND_HEADERS_VAR:=	H_MPFR
BUILTIN_FIND_HEADERS.H_MPFR=	mpfr.h mpfr/mpfr.h

BUILTIN_VERSION_SCRIPT.mpfr=	${AWK} \
				'/\#define[ \t]*MPFR_VERSION_STRING[ \t]/ { \
				v = substr($$3, 2, length($$3)-2) } \
				END { gsub("-p",".",v); print v }'

.include "../../mk/buildlink3/bsd.builtin.mk"

###
### Determine if there is a built-in implementation of the package and
### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
###
.if !defined(IS_BUILTIN.mpfr)
IS_BUILTIN.mpfr=	no
.  if empty(H_MPFR:M__nonexistent__) && empty(H_MPFR:M${LOCALBASE}/*)
IS_BUILTIN.mpfr=	yes
.  endif
.endif
MAKEVARS+=		IS_BUILTIN.mpfr

###
### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
### a package name to represent the built-in package.
###
.if !defined(BUILTIN_PKG.mpfr) && \
    !empty(IS_BUILTIN.mpfr:M[yY][eE][sS]) && \
    empty(H_MPFR:M__nonexistent__)
BUILTIN_VERSION.mpfr!=	${BUILTIN_VERSION_SCRIPT.mpfr} ${H_MPFR}
BUILTIN_PKG.mpfr=	mpfr-${BUILTIN_VERSION.mpfr}
.endif
MAKEVARS+=		BUILTIN_PKG.mpfr

###
### Determine whether we should use the built-in implementation if it
### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
###
.if !defined(USE_BUILTIN.mpfr)
.  if ${PREFER.mpfr} == "pkgsrc"
USE_BUILTIN.mpfr=	no
.  else
USE_BUILTIN.mpfr=	${IS_BUILTIN.mpfr}
.    if defined(BUILTIN_PKG.mpfr) && !empty(IS_BUILTIN.mpfr:M[yY][eE][sS])
USE_BUILTIN.mpfr=	yes
.      for _dep_ in ${BUILDLINK_API_DEPENDS.mpfr}
.        if !empty(USE_BUILTIN.mpfr:M[yY][eE][sS])
USE_BUILTIN.mpfr!=	\
	if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.mpfr:Q}; then	\
		${ECHO} yes;						\
	else								\
		${ECHO} no;						\
	fi
.        endif
.      endfor
.    endif
.  endif  # PREFER.mpfr
.endif
MAKEVARS+=		USE_BUILTIN.mpfr

CHECK_BUILTIN.mpfr?=	no
.if !empty(CHECK_BUILTIN.mpfr:M[Nn][Oo])
.  if !empty(USE_BUILTIN.mpfr:M[Yy][Ee][Ss])
MPFR_INCLUDE=		${H_MPFR:H}
BUILDLINK_INCDIRS.mpfr=	${MPFR_INCLUDE}
BUILDLINK_LIBDIRS.mpfr=	lib${LIBABISUFFIX}
CPPFLAGS+=		-I${MPFR_INCLUDE}
CFLAGS+=		-I${MPFR_INCLUDE}
.  endif
.endif # CHECK_BUILTIN.mpfr