svn commit: r336744 - in head: sbin/pfctl/tests/files share/mk

Brad Davis brd at FreeBSD.org
Thu Jul 26 17:05:35 UTC 2018


Author: brd
Date: Thu Jul 26 17:05:33 2018
New Revision: 336744
URL: https://svnweb.freebsd.org/changeset/base/336744

Log:
  Convert bsd.files.mk to support DIRS and simplify by only having one install
  target.
  
  Also update the pfctl tests Makefile to work with this change.
  
  Approved by:	bapt (mentor)
  Differential Revision:	https://reviews.freebsd.org/D16430

Modified:
  head/sbin/pfctl/tests/files/Makefile
  head/share/mk/bsd.files.mk

Modified: head/sbin/pfctl/tests/files/Makefile
==============================================================================
--- head/sbin/pfctl/tests/files/Makefile	Thu Jul 26 16:51:23 2018	(r336743)
+++ head/sbin/pfctl/tests/files/Makefile	Thu Jul 26 17:05:33 2018	(r336744)
@@ -4,9 +4,7 @@ TESTSDIR=	${TESTSBASE}/sbin/pfctl/files
 BINDIR=		${TESTSDIR}
 
 # We use ${.CURDIR} as workaround so that the glob patterns work.
-FILES=		${.CURDIR}/pf????.in
-FILES+=		${.CURDIR}/pf????.include
-FILES+=		${.CURDIR}/pf????.ok
+FILES!=		echo ${.CURDIR}/pf????.in ${.CURDIR}/pf????.include ${.CURDIR}/pf????.ok
 FILES+=		${.CURDIR}/pfctl_test_descr.sh
 
 .include <bsd.progs.mk>

Modified: head/share/mk/bsd.files.mk
==============================================================================
--- head/share/mk/bsd.files.mk	Thu Jul 26 16:51:23 2018	(r336743)
+++ head/share/mk/bsd.files.mk	Thu Jul 26 17:05:33 2018	(r336744)
@@ -5,6 +5,10 @@
 .endif
 
 .if !target(__<bsd.files.mk>__)
+.if target(__<bsd.dirs.mk>__)
+.error bsd.dirs.mk must be included after bsd.files.mk.
+.endif
+
 __<bsd.files.mk>__:
 
 FILESGROUPS?=	FILES
@@ -31,7 +35,7 @@ ${group}OWN=	${SHAREOWN}
 ${group}GRP=	${SHAREGRP}
 .endif
 ${group}MODE?=	${SHAREMODE}
-${group}DIR?=	${BINDIR}
+${group}DIR?=	BINDIR
 STAGE_SETS+=	${group:C,[/*],_,g}
 STAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${group}DIR}
 
@@ -43,71 +47,72 @@ ${group}TAG_ARGS=	-T ${${group}TAGS:[*]:S/ /,/g}
 .endif
 
 
-_${group}FILES=
-.for file in ${${group}}
-.if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
-    defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \
-    defined(${group}NAME_${file:T}) || defined(${group}NAME)
-${group}OWN_${file:T}?=	${${group}OWN}
-${group}GRP_${file:T}?=	${${group}GRP}
-.if ${MK_INSTALL_AS_USER} == "yes"
-${group}OWN_${file:T}=	${SHAREOWN}
-${group}GRP_${file:T}=	${SHAREGRP}
-.endif
-${group}MODE_${file:T}?=	${${group}MODE}
-${group}DIR_${file:T}?=	${${group}DIR}
-.if defined(${group}NAME)
-${group}NAME_${file:T}?=	${${group}NAME}
+.if ${${group}DIR:S/^\///} == ${${group}DIR}
+# ${group}DIR specifies a variable that specifies a path
+DIRS+=	${${group}DIR}
+_${group}DIR=	${${group}DIR}
 .else
-${group}NAME_${file:T}?=	${file:T}
+# ${group}DIR specifies a path
+DIRS+=	${group}DIR
+_${group}DIR=	${group}DIR
 .endif
-STAGE_AS_SETS+=	${file:T}
-STAGE_AS_${file:T}= ${${group}NAME_${file:T}}
-# XXX {group}OWN,GRP,MODE
-STAGE_DIR.${file:T}= ${STAGE_OBJTOP}${${group}DIR_${file:T}}
-stage_as.${file:T}: ${file}
 
-installfiles-${group}: installdirs-${group} _${group}INS_${file:T}
-_${group}INS_${file:T}: ${file}
-	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${.ALLSRC:T}} \
-	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
-	    ${.ALLSRC} \
-	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
-.else
-_${group}FILES+= ${file}
-.endif
-.endfor
 
+.for file in ${${group}}
+${group}OWN_${file}?=	${${group}OWN}
+${group}GRP_${file}?=	${${group}GRP}
+.if ${MK_INSTALL_AS_USER} == "yes"
+${group}OWN_${file}=	${SHAREOWN}
+${group}GRP_${file}=	${SHAREGRP}
+.endif # ${MK_INSTALL_AS_USER} == "yes"
+${group}MODE_${file}?=	${${group}MODE}
 
-installdirs-${group}:
-	@${ECHO} installing dirs ${group}DIR ${${group}DIR}
-.for dir in ${${group}DIR}
-.if defined(NO_ROOT)
-	${INSTALL} ${${group}TAG_ARGS} -d ${DESTDIR}${dir}
+# Determine the directory for the current file.  Default to the parent group
+# DIR, then check to see how to pass that variable on below.
+${group}DIR_${file}?=	${${group}DIR}
+.if ${${group}DIR_${file}:S/^\///} == ${${group}DIR_${file}}
+# DIR specifies a variable that specifies a path
+_${group}DIR_${file}=	${${group}DIR_${file}}
 .else
-	${INSTALL} ${${group}TAG_ARGS} -d -o ${DIROWN} -g ${DIRGRP} \
-		-m ${DIRMODE} ${DESTDIR}${dir}
+# DIR directly specifies a path
+_${group}DIR_${file}=	${group}DIR_${file}
 .endif
-.endfor
+${group}PREFIX_${file}=	${DESTDIR}${${_${group}DIR_${file}}}
 
-
-.if !empty(_${group}FILES)
-stage_files.${group}: ${_${group}FILES}
-
-installfiles-${group}: installdirs-${group} _${group}INS
-_${group}INS: ${_${group}FILES}
-.if defined(${group}NAME)
-	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
-	    -m ${${group}MODE} ${.ALLSRC} \
-	    ${DESTDIR}${${group}DIR}/${${group}NAME}
+# Append DIR to DIRS if not already in place -- DIRS is already filtered, so
+# this is primarily to ease inspection.
+.for d in ${DIRS}
+_DIRS+=	${${d}}
+.endfor
+.if ${DIRS:M${_${group}DIR_${file}}} == ""
+.if ${_DIRS:M${${_${group}DIR_${file}}}} == ""
+DIRS+=	${_${group}DIR_${file}}
 .else
-	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
-	    -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}/
+_${group}DIR_${file}=	${group}DIR
 .endif
 .endif
 
+.if defined(${group}NAME)
+${group}NAME_${file}?=	${${group}NAME}
+.else
+${group}NAME_${file}?=	${file:T}
+.endif # defined(${group}NAME)
+STAGE_AS_SETS+=	${file}
+STAGE_AS_${file}= ${${group}NAME_${file}}
+# XXX {group}OWN,GRP,MODE
+STAGE_DIR.${file}= ${STAGE_OBJTOP}${${group}DIR_${file}}
+stage_as.${file}: ${file}
+
+installfiles-${group}: _${group}INS1_${file}
+_${group}INS1_${file}: installdirs-${_${group}DIR_${file}} _${group}INS_${file}
+_${group}INS_${file}: ${file}
+	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${file}} \
+	    -g ${${group}GRP_${file}} -m ${${group}MODE_${file}} \
+	    ${.ALLSRC} ${${group}PREFIX_${file}}/${${group}NAME_${file}}
+.endfor # file in ${${group}}
+
 .endif # defined(${group}) && !empty(${group})
-.endfor
+.endfor # .for group in ${FILESGROUPS}
 
 realinstall: installfiles
 .ORDER: beforeinstall installfiles


More information about the svn-src-head mailing list