Pullup ticket #2848 - requested by adrianp
[pkgsrc.git] / mk / termcap.builtin.mk
1 # $NetBSD: termcap.builtin.mk,v 1.5 2008/03/11 15:39:16 jlam Exp $
2
3 BUILTIN_PKG:=   termcap
4
5 BUILTIN_FIND_LIBS:=             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.curses:M[yY][eE][sS]) || \
23       !empty(BUILTIN_LIB_FOUND.termcap:M[yY][eE][sS]) || \
24       !empty(BUILTIN_LIB_FOUND.termlib:M[yY][eE][sS]) || \
25       !empty(BUILTIN_LIB_FOUND.tinfo:M[yY][eE][sS])
26 IS_BUILTIN.termcap=     yes
27 .  endif
28 .endif
29 MAKEVARS+=      IS_BUILTIN.termcap
30
31 ###
32 ### Determine whether we should use the built-in implementation if it
33 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
34 ###
35 .if !defined(USE_BUILTIN.termcap)
36 .  if ${PREFER.termcap} == "pkgsrc"
37 USE_BUILTIN.termcap=    no
38 .  else
39 USE_BUILTIN.termcap=    ${IS_BUILTIN.termcap}
40 .  endif  # PREFER.termcap
41 .endif
42 MAKEVARS+=      USE_BUILTIN.termcap
43
44 # Define BUILTIN_LIBNAME.termcap to be the base name of the built-in
45 # termcap library.
46 #
47 # The way this is determined is:
48 #
49 # (1) If <term.h> exists and libtinfo exists, then it's "tinfo".
50 # (2) If <term.h> exists and libcurses exists, then it's "curses".
51 # (3) If <term.h> exists and lib{curses,tinfo} don't, then it's "c".
52 # (4) If <termcap.h> exists and libtermcap exists, then it's "termcap".
53 # (5) If <termcap.h> exists and libtermcap doesn't, then it's "c".
54 # (6) If <termlib.h> exists and libtermlib exists, then it's "termlib".
55 # (7) If <termlib.h> exists and libtermlib doesn't, then it's "c".
56 # (8) If libtermlib exists by itself, then it's "termlib".
57 #
58 .if empty(H_TERM:M__nonexistent__) && empty(H_TERM:M${LOCALBASE}/*)
59 .  if !empty(BUILTIN_LIB_FOUND.tinfo:M[yY][eE][sS])
60 BUILTIN_LIBNAME.termcap=        tinfo
61 .  elif !empty(BUILTIN_LIB_FOUND.curses:M[yY][eE][sS])
62 BUILTIN_LIBNAME.termcap=        curses
63 .  else
64 BUILTIN_LIBNAME.termcap=        c
65 .  endif
66 .elif empty(H_TERMCAP:M__nonexistent__) && empty(H_TERMCAP:M${LOCALBASE}/*)
67 .  if !empty(BUILTIN_LIB_FOUND.termcap:M[yY][eE][sS])
68 BUILTIN_LIBNAME.termcap=        termcap
69 .  else
70 BUILTIN_LIBNAME.termcap=        c
71 .  endif
72 .elif empty(H_TERMLIB:M__nonexistent__) && empty(H_TERMLIB:M${LOCALBASE}/*)
73 .  if !empty(BUILTIN_LIB_FOUND.termlib:M[yY][eE][sS])
74 BUILTIN_LIBNAME.termcap=        termlib
75 .  else
76 BUILTIN_LIBNAME.termcap=        c
77 .  endif
78 .elif !empty(BUILTIN_LIB_FOUND.termlib:M[yY][eE][sS])
79 BUILTIN_LIBNAME.termcap=        termlib
80 .endif
81
82 ###
83 ### The section below only applies if we are not including this file
84 ### solely to determine whether a built-in implementation exists.
85 ###
86 CHECK_BUILTIN.termcap?= no
87 .if !empty(CHECK_BUILTIN.termcap:M[nN][oO])
88
89 .  if !empty(USE_BUILTIN.termcap:M[yY][eE][sS])
90 BUILDLINK_LIBNAME.termcap=      ${BUILTIN_LIBNAME.termcap}
91 .  endif
92
93 # If the package wants both "termcap" and "curses", then we must not
94 # remove the -l options for the curses libraries; otherwise, we should
95 # remove them as GNU configure scripts commonly check for one or both
96 # of those library options.
97 #
98 .  if empty(BUILDLINK_TREE:Mcurses) && empty(BUILDLINK_TREE:Mncurses)
99 BUILDLINK_TRANSFORM+=           rm:-lcurses
100 BUILDLINK_TRANSFORM+=           rm:-lncurses
101 .  endif
102
103 .endif  # CHECK_BUILTIN.termcap