pullup 3232
[pkgsrcv2.git] / mk / curses.buildlink3.mk
1 # $NetBSD: curses.buildlink3.mk,v 1.16 2010/02/07 10:20:37 roy Exp $
2 #
3 # This Makefile fragment is meant to be included by packages that require
4 # any curses implementation instead of one particular one.  The available
5 # curses implementations are "curses" if built-in, "ncurses", and
6 # "pdcurses".
7 #
8 # If a package genuinely requires ncurses or pdcurses, then it should
9 # directly include the appropriate buildlink3.mk instead of this file in
10 # the package Makefile.
11 #
12 # === User-settable variables ===
13 #
14 # CURSES_DEFAULT
15 #       This value represents the type of curses we wish to use on the
16 #       system.  Setting this to "curses" means that the system curses
17 #       implementation is fine.
18 #
19 #       Possible: curses, ncurses, pdcurses
20 #       Default: (depends)
21 #
22 # === Variables set by this file ===
23 #
24 # CURSES_TYPE
25 #       The name of the selected curses implementation.
26
27 CURSES_BUILDLINK3_MK:=  ${CURSES_BUILDLINK3_MK}+
28 .include "bsd.fast.prefs.mk"
29
30 .if !empty(CURSES_BUILDLINK3_MK:M+)
31
32 # _CURSES_PKGS is an exhaustive list of all of the curses implementations
33 # that may be used with curses.buildlink3.mk.
34 #
35 _CURSES_PKGS?=          curses ncurses pdcurses
36
37 CHECK_BUILTIN.curses:=  yes
38 .  include "curses.builtin.mk"
39 CHECK_BUILTIN.curses:=  no
40
41 # Set the value of CURSES_DEFAULT depending on the platform and what's
42 # available in the base system.
43 #
44 .if defined(USE_BUILTIN.curses) && !empty(USE_BUILTIN.curses:M[yY][eE][sS])
45 CURSES_DEFAULT?=        curses
46 .else
47 CURSES_DEFAULT?=        ncurses
48 .endif
49
50 _CURSES_ACCEPTED=       # empty
51 .if defined(USE_BUILTIN.curses) && !empty(USE_BUILTIN.curses:M[yY][eE][sS])
52 _CURSES_ACCEPTED+=      curses          # system curses exists
53 .endif
54 _CURSES_ACCEPTED+=      ncurses         # pkgsrc ncurses
55 _CURSES_ACCEPTED+=      pdcurses        # pkgsrc pdcurses
56
57 _CURSES_TYPE=           ${CURSES_DEFAULT}
58 .  if !empty(_CURSES_ACCEPTED:M${_CURSES_TYPE})
59 CURSES_TYPE=            ${_CURSES_TYPE}
60 .  else
61 CURSES_TYPE=            none
62 .  endif
63
64 BUILD_DEFS+=            CURSES_DEFAULT
65 BUILD_DEFS_EFFECTS+=    CURSES_TYPE
66
67 # _PKG_USE_CURSES is a flag for use by the curses packages' buildlink3.mk
68 # files to indicate that the headers and libraries should be usable as
69 # <curses.h> and -lcurses.
70 #
71 _PKG_USE_CURSES=        yes
72
73 .endif  # CURSES_BUILDLINK3_MK
74
75 .if ${CURSES_TYPE} == "none"
76 PKG_FAIL_REASON=        \
77         "${_CURSES_TYPE} is not an acceptable curses type for ${PKGNAME}."
78 .elif ${CURSES_TYPE} == "curses"
79 BUILDLINK_TREE+=                curses -curses
80 BUILDLINK_LDADD.curses?=        ${BUILDLINK_LIBNAME.curses:S/^/-l/:S/^-l$//}
81 BUILDLINK_BUILTIN_MK.curses=    ../../mk/curses.builtin.mk
82 .elif ${CURSES_TYPE} == "ncurses"
83 USE_NCURSES=                    yes
84 .  include "../../devel/ncurses/buildlink3.mk"
85 BUILDLINK_PREFIX.curses?=       ${BUILDLINK_PREFIX.ncurses}
86 BUILDLINK_LIBNAME.curses?=      ${BUILDLINK_LIBNAME.ncurses}
87 BUILDLINK_LDADD.curses?=        ${BUILDLINK_LDADD.ncurses}
88 .elif ${CURSES_TYPE} == "pdcurses"
89 .  include "../../devel/pdcurses/buildlink3.mk"
90 BUILDLINK_PREFIX.curses?=       ${BUILDLINK_PREFIX.pdcurses}
91 BUILDLINK_LIBNAME.curses?=      ${BUILDLINK_LIBNAME.pdcurses}
92 BUILDLINK_LDADD.curses?=        ${BUILDLINK_LDADD.pdcurses}
93 .endif