summaryrefslogtreecommitdiff
path: root/mk/termcap.buildlink3.mk
blob: 1f16224303aafc9d26f0032e949c4de54c012e02 (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
# $NetBSD: termcap.buildlink3.mk,v 1.13 2019/09/02 02:23:02 rillig Exp $
#
# This Makefile fragment is meant to be included by packages that require
# a termcap implementation that supports the basic termcap functions:
#
#	tgetent, tgetstr, tgetflag, tgetnum, tgoto, tputs
#
# System-defined variables:
#
# TERMCAP_TYPE
#	The name of the selected termcap implementation.

TERMCAP_BUILDLINK3_MK:=	${TERMCAP_BUILDLINK3_MK}+

.include "bsd.fast.prefs.mk"

.if !empty(TERMCAP_BUILDLINK3_MK:M+)

# _TERMCAP_TYPES is an exhaustive list of all of the termcap
#	implementations that may be found.
#
_TERMCAP_TYPES?=	terminfo curses termcap termlib tinfo

CHECK_BUILTIN.termcap:=	yes
.  include "termcap.builtin.mk"
CHECK_BUILTIN.termcap:=	no

.if !empty(USE_BUILTIN.termcap:M[yY][eE][sS])
.  if defined(BUILTIN_LIBNAME.termcap)
TERMCAP_TYPE=	${BUILTIN_LIBNAME.termcap}
.  else
TERMCAP_TYPE=	none
.  endif
.else
TERMCAP_TYPE=	curses		# pkgsrc termcap is curses
.endif
BUILD_DEFS_EFFECTS+=	TERMCAP_TYPE

# Most GNU configure scripts will try finding every termcap implementation,
# so prevent them from finding any except for the one we decide upon.
#
# There is special handling for packages that can be provided by pkgsrc,
# e.g. curses -- see termcap.builtin.mk for details.
#
.  for _tcap_ in ${_TERMCAP_TYPES:Ntermcap:Ncurses}
.    if empty(TERMCAP_TYPE:M${_tcap_}) \
	&& (!defined(TERMINFO_TYPE) || empty(TERMINFO_TYPE:M${_tcap_})) \
	&& (!defined(CURSES_TYPE) || empty(CURSES_TYPE:M${_tcap_}))
BUILDLINK_TRANSFORM+=		rm:-l${_tcap_}
.    endif
.  endfor
BUILDLINK_TRANSFORM+=		l:termcap:${BUILDLINK_LIBNAME.termcap}

.endif	# TERMCAP_BUILDLINK3_MK

.if ${TERMCAP_TYPE} == "none"
PKG_FAIL_REASON+=	"No usable termcap library found on the system."
.elif (${TERMCAP_TYPE} == "terminfo") || \
      (${TERMCAP_TYPE} == "termlib") || \
      (${TERMCAP_TYPE} == "termcap") || \
      (${TERMCAP_TYPE} == "tinfo")
BUILDLINK_TREE+=		termcap -termcap
BUILDLINK_LIBNAME.termcap?=	${BUILTIN_LIBNAME.termcap}
BUILDLINK_LDADD.termcap?=	${BUILDLINK_LIBNAME.termcap:S/^/-l/:S/^-l$//}
BUILDLINK_BUILTIN_MK.termcap=	../../mk/termcap.builtin.mk
.elif ${TERMCAP_TYPE} == "curses"
.  include "../../mk/curses.buildlink3.mk"
BUILDLINK_PREFIX.termcap?=	${BUILDLINK_PREFIX.curses}
BUILDLINK_LIBNAME.termcap?=	${BUILDLINK_LIBNAME.curses}
BUILDLINK_LDADD.termcap?=	${BUILDLINK_LDADD.curses}
.endif

_VARGROUPS+=		termcap
_DEF_VARS.termcap=	_TERMCAP_TYPES BUILD_DEFS_EFFECTS BUILDLINK_TRANSFORM
_SYS_VARS.termcap=	CHECK_BUILTIN.termcap BUILTIN_LIBNAME.termcap \
			TERMCAP_TYPE \
			BUILDLINK_PREFIX.termcap BUILDLINK_LIBNAME.termcap \
			BUILDLINK_LDADD.termcap \
			BUILDLINK_PREFIX.curses BUILDLINK_LIBNAME.curses \
			BUILDLINK_LDADD.curses
_USER_VARS.termcap=	USE_BUILTIN.termcap
_USE_VARS.termcap=	CURSES_TYPE