summaryrefslogtreecommitdiff
path: root/mk/curses.builtin.mk
blob: a3e18891e305c016a4d93a37025c1fe1bdb8df59 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# $NetBSD: curses.builtin.mk,v 1.20 2019/06/17 18:19:55 sjmulder Exp $

BUILTIN_PKG:=	curses

BUILTIN_FIND_LIBS:=				curses
BUILTIN_FIND_HEADERS_VAR:=			H_CURSES
BUILTIN_FIND_HEADERS.H_CURSES=			curses.h

# Functions and defines to search for.
# These are valid USE_CURSES options and will determine whether the
# package can use the builtin curses or not.
#
BUILTIN_TEST_CURSES_FUNCS=	chgat getsyx halfdelay putwin
BUILTIN_TEST_CURSES_FUNCS+=	resize_term resizeterm ripoffline set_escdelay syncok
BUILTIN_TEST_CURSES_FUNCS+=	wgetnstr wsyncup mvwchgat vw_printw
BUILTIN_TEST_CURSES_FUNCS+=	getmouse
BUILTIN_TEST_CURSES_DEFINES=	WA_NORMAL

.for func in ${BUILTIN_TEST_CURSES_FUNCS}
BUILTIN_FIND_FILES_VAR+=			H_CURSES_${func:tu}
BUILTIN_FIND_FILES.H_CURSES_${func:tu}=		${H_CURSES}
BUILTIN_FIND_GREP.H_CURSES_${func:tu}=		${func}
.endfor

.for defn in ${BUILTIN_TEST_CURSES_DEFINES}
BUILTIN_FIND_FILES_VAR+=			H_CURSES_${defn}
BUILTIN_FIND_FILES.H_CURSES_${defn}=		${H_CURSES}
BUILTIN_FIND_GREP.H_CURSES_${defn}=		${defn}
.endfor

.include "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.curses)
IS_BUILTIN.curses=	no
.  if empty(H_CURSES:M${LOCALBASE}/*) && exists(${H_CURSES})
IS_BUILTIN.curses=	yes
.  endif
.endif
MAKEVARS+=	IS_BUILTIN.curses

###
### 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.curses)
.  if ${PREFER.curses} == "pkgsrc"
USE_BUILTIN.curses=	no
.  else
USE_BUILTIN.curses=	${IS_BUILTIN.curses}
.    if defined(BUILTIN_PKG.curses) && !empty(IS_BUILTIN.curses:M[yY][eE][sS])
USE_BUILTIN.curses=	yes
.      for _dep_ in ${BUILDLINK_API_DEPENDS.curses}
.        if !empty(USE_BUILTIN.curses:M[yY][eE][sS])
USE_BUILTIN.curses!=							\
	if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.curses:Q}; then	\
		${ECHO} yes;						\
	else								\
		${ECHO} no;						\
	fi
.        endif
.      endfor
.    endif
.  endif  # PREFER.curses
.endif

# If it is set to chgat, a curses implementation with chgat(3) support
# is considered good enough.
.if defined(USE_CURSES) && empty(USE_CURSES:M[yY][eE][sS])
.  for func in ${BUILTIN_TEST_CURSES_FUNCS}
.    if !empty(USE_CURSES:M${func}) && \
	!empty(H_CURSES_${func:tu}:M__nonexistent__)
USE_BUILTIN.curses=	no
.    endif
.  endfor
.  for defn in ${BUILTIN_TEST_CURSES_DEFINES}
.    if !empty(USE_CURSES:M${defn}) && \
	!empty(H_CURSES_${defn}:M__nonexistent__)
USE_BUILTIN.curses=	no
.    endif
.  endfor
# AFAIK there is no way of working out if a system curses library has wide
# character support. So be safe and say no unless we know for sure.
.  if !empty(USE_CURSES:Mwide)
.    if ${OPSYS} == "NetBSD"
.      if !empty(MACHINE_PLATFORM:MNetBSD-[0-4].*-*)
USE_BUILTIN.curses=	no
.      endif
.    else
USE_BUILTIN.curses=	no
.    endif
.  endif
.endif

# Even if the package requested tests above pass,
# some system curses just are not good enough.
# If your system is one, add it here so a suitable
# curses from pkgsrc can be installed.
_INCOMPAT_CURSES?=
.for _pattern_ in ${_INCOMPAT_CURSES} ${INCOMPAT_CURSES}
.  if !empty(MACHINE_PLATFORM:M${_pattern_})
USE_BUILTIN.curses=	no
.  endif
.endfor

MAKEVARS+=	USE_BUILTIN.curses

# Define BUILTIN_LIBNAME.curses to be the base name of the built-in
# curses library.
#
.if !empty(BUILTIN_LIB_FOUND.curses:M[yY][eE][sS])
BUILTIN_LIBNAME.curses=		curses
.endif

BUILTIN_LIBNAME.curses=		curses

###
### The section below only applies if we are not including this file
### solely to determine whether a built-in implementation exists.
###
CHECK_BUILTIN.curses?=	no
.if !empty(CHECK_BUILTIN.curses:M[nN][oO])

.  if !empty(USE_BUILTIN.curses:M[yY][eE][sS])
.    if exists(${H_CURSES})
BUILDLINK_INCDIRS.curses?=	${H_CURSES:H}
.    endif
BUILDLINK_LIBNAME.curses=	${BUILTIN_LIBNAME.curses}
.  endif

.endif	# CHECK_BUILTIN.curses