1 # $NetBSD: termcap.builtin.mk,v 1.6 2009/03/20 19:25:01 joerg Exp $
5 BUILTIN_FIND_LIBS:= terminfo curses termcap termlib tinfo
6 BUILTIN_FIND_FILES_VAR:= H_TERM H_TERMCAP H_TERMLIB
7 BUILTIN_FIND_FILES.H_TERM:= /usr/include/term.h
8 BUILTIN_FIND_GREP.H_TERM:= tgetent
9 BUILTIN_FIND_FILES.H_TERMCAP:= /usr/include/termcap.h
10 BUILTIN_FIND_GREP.H_TERMCAP:= tgetent
11 BUILTIN_FIND_FILES.H_TERMLIB:= /usr/include/termlib.h
12 BUILTIN_FIND_GREP.H_TERMLIB:= tgetent
14 .include "buildlink3/bsd.builtin.mk"
17 ### Determine if there is a built-in implementation of the package and
18 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
20 .if !defined(IS_BUILTIN.termcap)
21 IS_BUILTIN.termcap= no
22 . if !empty(BUILTIN_LIB_FOUND.terminfo:M[yY[eE][sS]) || \
23 !empty(BUILTIN_LIB_FOUND.curses:M[yY][eE][sS]) || \
24 !empty(BUILTIN_LIB_FOUND.termcap:M[yY][eE][sS]) || \
25 !empty(BUILTIN_LIB_FOUND.termlib:M[yY][eE][sS]) || \
26 !empty(BUILTIN_LIB_FOUND.tinfo:M[yY][eE][sS])
27 IS_BUILTIN.termcap= yes
30 MAKEVARS+= IS_BUILTIN.termcap
33 ### Determine whether we should use the built-in implementation if it
34 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
36 .if !defined(USE_BUILTIN.termcap)
37 . if ${PREFER.termcap} == "pkgsrc"
38 USE_BUILTIN.termcap= no
40 USE_BUILTIN.termcap= ${IS_BUILTIN.termcap}
41 . endif # PREFER.termcap
43 MAKEVARS+= USE_BUILTIN.termcap
45 # Define BUILTIN_LIBNAME.termcap to be the base name of the built-in
48 # The way this is determined is:
50 # (1) If <term.h> exists and libtinfo exists, then it's "tinfo".
51 # (2) If <term.h> exists and libcurses exists, then it's "curses".
52 # (3) If <term.h> exists and lib{curses,tinfo} don't, then it's "c".
53 # (4) If <termcap.h> exists and libtermcap exists, then it's "termcap".
54 # (5) If <termcap.h> exists and libtermcap doesn't, then it's "c".
55 # (6) If <termlib.h> exists and libtermlib exists, then it's "termlib".
56 # (7) If <termlib.h> exists and libtermlib doesn't, then it's "c".
57 # (8) If libtermlib exists by itself, then it's "termlib".
59 .if empty(H_TERM:M__nonexistent__) && empty(H_TERM:M${LOCALBASE}/*)
60 . if !empty(BUILTIN_LIB_FOUND.terminfo:M[yY][eE][sS])
61 BUILTIN_LIBNAME.termcap= terminfo
62 . elif !empty(BUILTIN_LIB_FOUND.tinfo:M[yY][eE][sS])
63 BUILTIN_LIBNAME.termcap= tinfo
64 . elif !empty(BUILTIN_LIB_FOUND.curses:M[yY][eE][sS])
65 BUILTIN_LIBNAME.termcap= curses
67 BUILTIN_LIBNAME.termcap= c
69 .elif empty(H_TERMCAP:M__nonexistent__) && empty(H_TERMCAP:M${LOCALBASE}/*)
70 . if !empty(BUILTIN_LIB_FOUND.termcap:M[yY][eE][sS])
71 BUILTIN_LIBNAME.termcap= termcap
73 BUILTIN_LIBNAME.termcap= c
75 .elif empty(H_TERMLIB:M__nonexistent__) && empty(H_TERMLIB:M${LOCALBASE}/*)
76 . if !empty(BUILTIN_LIB_FOUND.termlib:M[yY][eE][sS])
77 BUILTIN_LIBNAME.termcap= termlib
79 BUILTIN_LIBNAME.termcap= c
81 .elif !empty(BUILTIN_LIB_FOUND.termlib:M[yY][eE][sS])
82 BUILTIN_LIBNAME.termcap= termlib
86 ### The section below only applies if we are not including this file
87 ### solely to determine whether a built-in implementation exists.
89 CHECK_BUILTIN.termcap?= no
90 .if !empty(CHECK_BUILTIN.termcap:M[nN][oO])
92 . if !empty(USE_BUILTIN.termcap:M[yY][eE][sS])
93 BUILDLINK_LIBNAME.termcap= ${BUILTIN_LIBNAME.termcap}
96 # If the package wants both "termcap" and "curses", then we must not
97 # remove the -l options for the curses libraries; otherwise, we should
98 # remove them as GNU configure scripts commonly check for one or both
99 # of those library options.
101 . if empty(BUILDLINK_TREE:Mcurses) && empty(BUILDLINK_TREE:Mncurses)
102 BUILDLINK_TRANSFORM+= rm:-lcurses
103 BUILDLINK_TRANSFORM+= rm:-lncurses
106 .endif # CHECK_BUILTIN.termcap