From 4e657f5af09d311b5422b06df7103cd6106d2f0c Mon Sep 17 00:00:00 2001 From: brd Date: Thu, 26 Jul 2018 17:05:33 +0000 Subject: [PATCH] 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 --- sbin/pfctl/tests/files/Makefile | 4 +- share/mk/bsd.files.mk | 121 +++++++++++++++++--------------- 2 files changed, 64 insertions(+), 61 deletions(-) diff --git a/sbin/pfctl/tests/files/Makefile b/sbin/pfctl/tests/files/Makefile index 433106089b2a..818e4cd21f77 100644 --- a/sbin/pfctl/tests/files/Makefile +++ b/sbin/pfctl/tests/files/Makefile @@ -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 diff --git a/share/mk/bsd.files.mk b/share/mk/bsd.files.mk index 0330386ad0b1..7905dab6c65d 100644 --- a/share/mk/bsd.files.mk +++ b/share/mk/bsd.files.mk @@ -5,6 +5,10 @@ .endif .if !target(____) +.if target(____) +.error bsd.dirs.mk must be included after bsd.files.mk. +.endif + ____: 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= +.if ${${group}DIR:S/^\///} == ${${group}DIR} +# ${group}DIR specifies a variable that specifies a path +DIRS+= ${${group}DIR} +_${group}DIR= ${${group}DIR} +.else +# ${group}DIR specifies a path +DIRS+= ${group}DIR +_${group}DIR= ${group}DIR +.endif + + .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} +${group}OWN_${file}?= ${${group}OWN} +${group}GRP_${file}?= ${${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} +${group}OWN_${file}= ${SHAREOWN} +${group}GRP_${file}= ${SHAREGRP} +.endif # ${MK_INSTALL_AS_USER} == "yes" +${group}MODE_${file}?= ${${group}MODE} + +# 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 -${group}NAME_${file:T}?= ${file:T} +# DIR directly specifies a path +_${group}DIR_${file}= ${group}DIR_${file} .endif -STAGE_AS_SETS+= ${file:T} -STAGE_AS_${file:T}= ${${group}NAME_${file:T}} +${group}PREFIX_${file}= ${DESTDIR}${${_${group}DIR_${file}}} + +# 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 +_${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:T}= ${STAGE_OBJTOP}${${group}DIR_${file:T}} -stage_as.${file:T}: ${file} +STAGE_DIR.${file}= ${STAGE_OBJTOP}${${group}DIR_${file}} +stage_as.${file}: ${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 - - -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} -.else - ${INSTALL} ${${group}TAG_ARGS} -d -o ${DIROWN} -g ${DIRGRP} \ - -m ${DIRMODE} ${DESTDIR}${dir} -.endif -.endfor - - -.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} -.else - ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \ - -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}/ -.endif -.endif +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