summaryrefslogtreecommitdiff
path: root/sysutils/file/builtin.mk
diff options
context:
space:
mode:
Diffstat (limited to 'sysutils/file/builtin.mk')
-rw-r--r--sysutils/file/builtin.mk56
1 files changed, 41 insertions, 15 deletions
diff --git a/sysutils/file/builtin.mk b/sysutils/file/builtin.mk
index 174f1474989..c603a25faec 100644
--- a/sysutils/file/builtin.mk
+++ b/sysutils/file/builtin.mk
@@ -1,22 +1,48 @@
-# $NetBSD: builtin.mk,v 1.1 2004/07/31 22:13:38 salo Exp $
-#
+# $NetBSD: builtin.mk,v 1.2 2005/06/01 18:03:21 jlam Exp $
-_MAGIC_H= /usr/include/magic.h
+BUILTIN_PKG:= file
+BUILTIN_FIND_FILES_VAR:= H_FILE
+BUILTIN_FIND_FILES.H_FILE= /usr/include/magic.h
+BUILTIN_FIND_GREP.H_FILE= magic_file
+
+.include "../../mk/buildlink3/bsd.builtin.mk"
+
+###
+### Determine if there is a built-in implementation of the package and
+### set IS_BUILTIN.<pkg> appropriately ("yes" or "no").
+###
.if !defined(IS_BUILTIN.file)
IS_BUILTIN.file= no
-. if exists(${_MAGIC_H})
-IS_BUILTIN.file!= \
- if ${GREP} -q "magic_file" ${_MAGIC_H}; then \
- ${ECHO} "yes"; \
- else \
- ${ECHO} "no"; \
- fi
+. if empty(H_FILE:M${LOCALBASE}/*) && exists(${H_FILE})
+IS_BUILTIN.file= yes
. endif
-BUILDLINK_VARS+= IS_BUILTIN.file
-.endif # IS_BUILTIN.file
+.endif
+MAKEVARS+= IS_BUILTIN.file
+###
+### Determine whether we should use the built-in implementation if it
+### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no").
+###
.if !defined(USE_BUILTIN.file)
-USE_BUILTIN.file?= ${IS_BUILTIN.file}
-PREFER.file?= pkgsrc
-.endif # USE_BUILTIN.file
+. if ${PREFER.file} == "pkgsrc"
+USE_BUILTIN.file= no
+. else
+USE_BUILTIN.file= ${IS_BUILTIN.file}
+. if defined(BUILTIN_PKG.file) && \
+ !empty(IS_BUILTIN.file:M[yY][eE][sS])
+USE_BUILTIN.file= yes
+. for _dep_ in ${BUILDLINK_DEPENDS.file}
+. if !empty(USE_BUILTIN.file:M[yY][eE][sS])
+USE_BUILTIN.file!= \
+ if ${PKG_ADMIN} pmatch ${_dep_:Q} ${BUILTIN_PKG.file:Q}; then \
+ ${ECHO} yes; \
+ else \
+ ${ECHO} no; \
+ fi
+. endif
+. endfor
+. endif
+. endif # PREFER.file
+.endif
+MAKEVARS+= USE_BUILTIN.file