pullup 3232
[pkgsrcv2.git] / mk / termcap.builtin.mk
1 # $NetBSD: termcap.builtin.mk,v 1.6 2009/03/20 19:25:01 joerg Exp $
2
3 BUILTIN_PKG:=   termcap
4
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
13
14 .include "buildlink3/bsd.builtin.mk"
15
16 ###
17 ### Determine if there is a built-in implementation of the package and
18 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
19 ###
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
28 .  endif
29 .endif
30 MAKEVARS+=      IS_BUILTIN.termcap
31
32 ###
33 ### Determine whether we should use the built-in implementation if it
34 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
35 ###
36 .if !defined(USE_BUILTIN.termcap)
37 .  if ${PREFER.termcap} == "pkgsrc"
38 USE_BUILTIN.termcap=    no
39 .  else
40 USE_BUILTIN.termcap=    ${IS_BUILTIN.termcap}
41 .  endif  # PREFER.termcap
42 .endif
43 MAKEVARS+=      USE_BUILTIN.termcap
44
45 # Define BUILTIN_LIBNAME.termcap to be the base name of the built-in
46 # termcap library.
47 #
48 # The way this is determined is:
49 #
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".
58 #
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
66 .  else
67 BUILTIN_LIBNAME.termcap=        c
68 .  endif
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
72 .  else
73 BUILTIN_LIBNAME.termcap=        c
74 .  endif
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
78 .  else
79 BUILTIN_LIBNAME.termcap=        c
80 .  endif
81 .elif !empty(BUILTIN_LIB_FOUND.termlib:M[yY][eE][sS])
82 BUILTIN_LIBNAME.termcap=        termlib
83 .endif
84
85 ###
86 ### The section below only applies if we are not including this file
87 ### solely to determine whether a built-in implementation exists.
88 ###
89 CHECK_BUILTIN.termcap?= no
90 .if !empty(CHECK_BUILTIN.termcap:M[nN][oO])
91
92 .  if !empty(USE_BUILTIN.termcap:M[yY][eE][sS])
93 BUILDLINK_LIBNAME.termcap=      ${BUILTIN_LIBNAME.termcap}
94 .  endif
95
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.
100 #
101 .  if empty(BUILDLINK_TREE:Mcurses) && empty(BUILDLINK_TREE:Mncurses)
102 BUILDLINK_TRANSFORM+=           rm:-lcurses
103 BUILDLINK_TRANSFORM+=           rm:-lncurses
104 .  endif
105
106 .endif  # CHECK_BUILTIN.termcap