ticket #2718
[pkgsrc.git] / mk / curses.buildlink3.mk
1 # $NetBSD: curses.buildlink3.mk,v 1.12 2008/02/29 16:29:04 jlam 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
29 .include "bsd.fast.prefs.mk"
30
31 .if !empty(CURSES_BUILDLINK3_MK:M+)
32
33 # _CURSES_PKGS is an exhaustive list of all of the curses implementations
34 # that may be used with curses.buildlink3.mk.
35 #
36 _CURSES_PKGS?=          curses ncurses pdcurses
37
38 CHECK_BUILTIN.curses:=  yes
39 .  include "curses.builtin.mk"
40 CHECK_BUILTIN.curses:=  no
41
42 # Set the value of CURSES_DEFAULT depending on the platform and what's
43 # available in the base system.
44 #
45 .if defined(USE_BUILTIN.curses) && !empty(USE_BUILTIN.curses:M[yY][eE][sS])
46 CURSES_DEFAULT?=        curses
47 .else
48 CURSES_DEFAULT?=        ncurses
49 .endif
50
51 _CURSES_ACCEPTED=       # empty
52 .if defined(USE_BUILTIN.curses) && !empty(USE_BUILTIN.curses:M[yY][eE][sS])
53 _CURSES_ACCEPTED+=      curses          # system curses exists
54 .endif
55 _CURSES_ACCEPTED+=      ncurses         # pkgsrc ncurses
56 _CURSES_ACCEPTED+=      pdcurses        # pkgsrc pdcurses
57
58 _CURSES_TYPE=           ${CURSES_DEFAULT}
59 .  if !empty(_CURSES_ACCEPTED:M${_CURSES_TYPE})
60 CURSES_TYPE=            ${_CURSES_TYPE}
61 .  else
62 CURSES_TYPE=            none
63 .  endif
64
65 BUILD_DEFS+=            CURSES_DEFAULT
66 BUILD_DEFS_EFFECTS+=    CURSES_TYPE
67
68 # _PKG_USE_CURSES is a flag for use by the curses packages' buildlink3.mk
69 # files to indicate that the headers and libraries should be usable as
70 # <curses.h> and -lcurses.
71 #
72 _PKG_USE_CURSES=        yes
73
74 .endif  # CURSES_BUILDLINK3_MK
75
76 .if ${CURSES_TYPE} == "none"
77 PKG_FAIL_REASON=        \
78         "${_CURSES_TYPE} is not an acceptable curses type for ${PKGNAME}."
79 .elif ${CURSES_TYPE} == "curses"
80 BUILDLINK_PACKAGES:=            ${BUILDLINK_PACKAGES:Ncurses}
81 BUILDLINK_PACKAGES+=            curses
82 BUILDLINK_ORDER:=               ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}curses
83 BUILDLINK_LDADD.curses?=        ${BUILDLINK_LIBNAME.curses:S/^/-l/:S/^-l$//}
84 BUILDLINK_BUILTIN_MK.curses=    ../../mk/curses.builtin.mk
85 .elif ${CURSES_TYPE} == "ncurses"
86 USE_NCURSES=                    yes
87 .  include "../../devel/ncurses/buildlink3.mk"
88 BUILDLINK_PREFIX.curses?=       ${BUILDLINK_PREFIX.ncurses}
89 BUILDLINK_LIBNAME.curses?=      ${BUILDLINK_LIBNAME.ncurses}
90 BUILDLINK_LDADD.curses?=        ${BUILDLINK_LDADD.ncurses}
91 .elif ${CURSES_TYPE} == "pdcurses"
92 .  include "../../devel/pdcurses/buildlink3.mk"
93 BUILDLINK_PREFIX.curses?=       ${BUILDLINK_PREFIX.pdcurses}
94 BUILDLINK_LIBNAME.curses?=      ${BUILDLINK_LIBNAME.pdcurses}
95 BUILDLINK_LDADD.curses?=        ${BUILDLINK_LDADD.pdcurses}
96 .endif