Merge from vendor branch TNF:
[pkgsrcv2.git] / x11 / xextproto / builtin.mk
1 # $NetBSD: builtin.mk,v 1.6 2008/10/05 21:36:34 cube Exp $
2
3 BUILTIN_PKG:=   xextproto
4
5 BUILTIN_FIND_FILES_VAR:=                H_XEXTPROTO
6 BUILTIN_FIND_FILES.H_XEXTPROTO= \
7         ${X11BASE}/include/X11/extensions/extutil.h
8
9 .include "../../mk/buildlink3/bsd.builtin.mk"
10
11 ###
12 ### Determine if there is a built-in implementation of the package and
13 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
14 ###
15 .if ${X11BASE} == ${LOCALBASE}
16 IS_BUILTIN.xextproto=   no
17 .elif !defined(IS_BUILTIN.xextproto)
18 IS_BUILTIN.xextproto=   no
19 #
20 # Here, we skip checking whether the files are under ${LOCALBASE} since
21 # we'll consider this X11 package to be built-in even if it's a part
22 # of one of the pkgsrc-installed X11 distributions.
23 #
24 .  if empty(H_XEXTPROTO:M__nonexistent__)
25 IS_BUILTIN.xextproto=   yes
26 .  endif
27 .endif
28 MAKEVARS+=      IS_BUILTIN.xextproto
29
30 ###
31 ### Determine whether we should use the built-in implementation if it
32 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
33 ###
34 .if !defined(USE_BUILTIN.xextproto)
35 .  if ${PREFER.xextproto} == "pkgsrc"
36 USE_BUILTIN.xextproto=  no
37 .  else
38 USE_BUILTIN.xextproto=  ${IS_BUILTIN.xextproto}
39 .    if defined(BUILTIN_PKG.xextproto) && \
40         !empty(IS_BUILTIN.xextproto:M[yY][eE][sS])
41 USE_BUILTIN.xextproto=  yes
42 .      for _dep_ in ${BUILDLINK_API_DEPENDS.xextproto}
43 .        if !empty(USE_BUILTIN.xextproto:M[yY][eE][sS])
44 USE_BUILTIN.xextproto!=                                         \
45         if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.xextproto:Q}; then \
46                 ${ECHO} yes;                                            \
47         else                                                            \
48                 ${ECHO} no;                                             \
49         fi
50 .        endif
51 .      endfor
52 .    endif
53 .  endif  # PREFER.xextproto
54 .endif
55 MAKEVARS+=      USE_BUILTIN.xextproto
56
57 ###
58 ### The section below only applies if we are not including this file
59 ### solely to determine whether a built-in implementation exists.
60 ###
61
62 .include "../../mk/x11.builtin.mk"
63
64 CHECK_BUILTIN.xextproto?=       no
65 .if !empty(CHECK_BUILTIN.xextproto:M[nN][oO])
66
67 # If we are using the builtin version, check whether it has a xextproto.pc
68 # file or not.  If the latter, generate a fake one.
69 .  if !empty(USE_BUILTIN.xextproto:M[Yy][Ee][Ss])
70 BUILDLINK_TARGETS+=     xextproto-fake-pc
71
72 xextproto-fake-pc:
73         ${RUN} \
74         src=${BUILDLINK_PREFIX.xextproto}/lib/pkgconfig/xextproto.pc; \
75         dst=${BUILDLINK_DIR}/lib/pkgconfig/xextproto.pc; \
76         ${MKDIR} ${BUILDLINK_DIR}/lib/pkgconfig; \
77         if ${TEST} -f $${src}; then \
78                 ${LN} -sf $${src} $${dst}; \
79         else \
80                 { ${ECHO} "Name: XExtensions"; \
81                 ${ECHO} "Description: Sundry X extension headers"; \
82                 ${ECHO} "Version: 1.0.1"; \
83                 ${ECHO} "Cflags: -I${BUILDLINK_PREFIX.xextproto}/include"; \
84                 } >$${dst}; \
85         fi
86 .  endif
87
88 .endif  # CHECK_BUILTIN.xextproto