1 # $NetBSD: builtin.mk,v 1.8 2009/01/18 06:56:34 dholland Exp $
5 # H_NB_CURSESW searches for NetBSD's <curses.h> that uses HAVE_WCHAR to
6 # build with wide curses support.
8 # XXX Need to deal with Solaris <curses.h>
10 BUILTIN_FIND_LIBS:= ncursesw curses
11 BUILTIN_FIND_FILES_VAR:= H_NB_CURSESW H_NCURSESW
12 BUILTIN_FIND_FILES.H_NB_CURSESW= /usr/include/curses.h
13 BUILTIN_FIND_GREP.H_NB_CURSESW= \#ifdef[ ]*HAVE_WCHAR
14 BUILTIN_FIND_FILES.H_NCURSESW= /usr/include/ncursesw/curses.h \
16 BUILTIN_FIND_GREP.H_NCURSESW= \Id: curses.wide,v
18 .include "../../mk/buildlink3/bsd.builtin.mk"
21 ### Determine if there is a built-in implementation of the package and
22 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
24 .if !defined(IS_BUILTIN.ncursesw)
25 IS_BUILTIN.ncursesw= no
26 . if empty(H_NCURSESW:M__nonexistent__) && \
27 empty(H_NCURSESW:M${LOCALBASE}/*) && \
28 !empty(BUILTIN_LIB_FOUND.ncursesw:M[yY][eE][sS])
29 IS_BUILTIN.ncursesw= yes
32 MAKEVARS+= IS_BUILTIN.ncursesw
35 ### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to
36 ### a package name to represent the built-in package.
38 .if !defined(BUILTIN_PKG.ncursesw) && \
39 !empty(IS_BUILTIN.ncursesw:M[yY][eE][sS]) && \
40 empty(H_NCURSESW:M__nonexistent__)
41 BUILTIN_VERSION.ncursesw!= \
42 ${AWK} '/\#define[ ]*NCURSES_VERSION[ ]/ { \
44 gsub("\"", "", vers); \
48 BUILTIN_PKG.ncursesw= ncursesw-${BUILTIN_VERSION.ncursesw}
50 MAKEVARS+= BUILTIN_PKG.ncursesw
53 ### Determine whether we should use the built-in implementation if it
54 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
56 .if !defined(USE_BUILTIN.ncursesw)
57 . if ${PREFER.ncursesw} == "pkgsrc"
58 USE_BUILTIN.ncursesw= no
60 USE_BUILTIN.ncursesw= ${IS_BUILTIN.ncursesw}
61 . if defined(BUILTIN_PKG.ncursesw) && \
62 !empty(IS_BUILTIN.ncursesw:M[yY][eE][sS])
63 USE_BUILTIN.ncursesw= yes
64 . for _dep_ in ${BUILDLINK_API_DEPENDS.ncursesw}
65 . if !empty(USE_BUILTIN.ncursesw:M[yY][eE][sS])
66 USE_BUILTIN.ncursesw!= \
67 if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.ncursesw:Q}; then \
76 # XXX By default, assume that the native curses on NetBSD systems is
77 # XXX good enough to replace ncursesw. In reality, no version of NetBSD
78 # XXX has a curses library that can completely replace ncursesw; however,
79 # XXX some versions implement enough of ncursesw that some packages are
82 . if empty(H_NB_CURSESW:M__nonexistent__) && \
83 empty(H_NB_CURSESW:M${LOCALBASE}/*)
84 USE_BUILTIN.ncursesw= yes
86 . endif # PREFER.ncursesw
88 MAKEVARS+= USE_BUILTIN.ncursesw
90 # If USE_NCURSES is defined, then only use the built-in "ncursesw"
91 # if it's *actually* ncursesw.
93 .if defined(USE_NCURSES) && !empty(IS_BUILTIN.ncursesw:M[nN][oO])
94 USE_BUILTIN.ncursesw= no
97 # Define BUILTIN_LIBNAME.ncursesw to be the base name of the built-in
100 .if !empty(BUILTIN_LIB_FOUND.ncursesw:M[yY][eE][sS])
101 BUILTIN_LIBNAME.ncursesw= ncursesw
102 .elif !empty(BUILTIN_LIB_FOUND.curses:M[yY][eE][sS])
103 BUILTIN_LIBNAME.ncursesw= curses
107 ### The section below only applies if we are not including this file
108 ### solely to determine whether a built-in implementation exists.
110 CHECK_BUILTIN.ncursesw?= no
111 .if !empty(CHECK_BUILTIN.ncursesw:M[nN][oO])
113 . if !empty(USE_BUILTIN.ncursesw:M[yY][eE][sS])
114 BUILDLINK_LIBNAME.ncursesw= ${BUILTIN_LIBNAME.ncursesw}
115 BUILDLINK_TRANSFORM+= l:ncursesw:${BUILTIN_LIBNAME.ncursesw}
116 . if empty(H_NB_CURSESW:M__nonexistent__) && \
117 empty(H_NB_CURSESW:M${LOCALBASE}/*)
118 BUILDLINK_CPPFLAGS.ncursesw+= -DHAVE_WCHAR=1
122 # According to the ncurses(3) manual page, applications that want to use
123 # the wide curses definitions need to define _XOPEN_SOURCE_EXTENDED.
125 . if !empty(USE_BUILTIN.ncursesw:M[nN][oO]) || \
126 (!empty(USE_BUILTIN.ncursesw:M[yY][eE][sS]) && \
127 !empty(IS_BUILTIN.ncursesw:M[yY][eE][sS]))
129 BUILDLINK_CPPFLAGS.ncursesw+= -D_XOPEN_SOURCE_EXTENDED=1
131 BUILDLINK_TARGETS+= buildlink-ncursesw-curses-h
133 # Packages will expect the following includes to provide declarations
134 # for ncursesw if wide curses are supported:
136 # <ncursesw/curses.h>
140 # We must explicitly force the symlinks to be created as we have to
141 # overwrite any that ncurses/buildlink3.mk might create ahead of us.
143 . if !target(buildlink-ncursesw-curses-h)
144 .PHONY: buildlink-ncursesw-curses-h
145 buildlink-ncursesw-curses-h:
147 curses_h="ncursesw/ncurses.h curses.h"; \
148 for f in $$curses_h; do \
149 src=${BUILDLINK_PREFIX.ncursesw:Q}"/include/$$f"; \
150 dests="ncursesw/curses.h ncurses.h curses.h"; \
151 for dest in $$dests; do \
152 dest=${BUILDLINK_DIR:Q}"/include/$$dest"; \
153 if ${TEST} -f "$$src"; then \
154 ${ECHO_BUILDLINK_MSG} "Linking $$dest -> $$f."; \
155 ${MKDIR} `${DIRNAME} "$$dest"`; \
156 ${LN} -fs "$$src" "$$dest"; \
162 .endif # CHECK_BUILTIN.ncursesw