Fixup fromcvs/togit conversion
[pkgsrcv2.git] / sysutils / file / builtin.mk
1 # $NetBSD: builtin.mk,v 1.5 2008/10/29 20:50:16 christos Exp $
2
3 BUILTIN_PKG:=   file
4
5 BUILTIN_FIND_FILES_VAR:=        H_FILE BIN_FILE
6 BUILTIN_FIND_FILES.H_FILE=      /usr/include/magic.h
7 BUILTIN_FIND_GREP.H_FILE=       magic_file
8 BUILTIN_FIND_FILES.BIN_FILE=    /bin/file /usr/bin/file
9
10 .include "../../mk/buildlink3/bsd.builtin.mk"
11
12 ###
13 ### Determine if there is a built-in implementation of the package and
14 ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
15 ###
16 .if !defined(IS_BUILTIN.file)
17 IS_BUILTIN.file=        no
18 .  if empty(H_FILE:M__nonexistent__) && empty(H_FILE:M${LOCALBASE}/*)
19 IS_BUILTIN.file=        yes
20 .  endif
21 .  if empty(BIN_FILE:M__nonexistent__) && empty(BIN_FILE:M{LOCALBASE}/*)
22 BUILTIN_CMD.file=       ${BIN_FILE}
23 .  else
24 BUILTIN_CMD.file=       file
25 .  endif
26 .endif
27 MAKEVARS+=      IS_BUILTIN.file
28
29 .if !defined(BUILTIN_PKG.file) && !empty(IS_BUILTIN.file:M[yY][eE][sS])
30 BUILTIN_VERSION.file!=  ${BUILTIN_CMD.file} --version 2>&1 | ${GREP} 'file-' | ${SED} 's/file-//'
31 BUILTIN_PKG.file=       file-${BUILTIN_VERSION.file}
32 .endif
33 MAKEVARS+=      BUILTIN_PKG.file
34
35 ###
36 ### Determine whether we should use the built-in implementation if it
37 ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
38 ###
39 .if !defined(USE_BUILTIN.file)
40 .  if ${PREFER.file} == "pkgsrc"
41 USE_BUILTIN.file=       no
42 .  else
43 USE_BUILTIN.file=       ${IS_BUILTIN.file}
44 .    if defined(BUILTIN_PKG.file) && \
45         !empty(IS_BUILTIN.file:M[yY][eE][sS])
46 USE_BUILTIN.file=       yes
47 .      for _dep_ in ${BUILDLINK_API_DEPENDS.file}
48 .        if !empty(USE_BUILTIN.file:M[yY][eE][sS])
49 USE_BUILTIN.file!=                                                      \
50         if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.file:Q}; then   \
51                 ${ECHO} yes;                                            \
52         else                                                            \
53                 ${ECHO} no;                                             \
54         fi
55 .        endif
56 .      endfor
57 .    endif
58 .  endif  # PREFER.file
59 .endif
60 MAKEVARS+=      USE_BUILTIN.file