1a34d5fb1SAntonio Huete Jimenez# $Id: files.mk,v 1.7 2020/08/19 17:51:53 sjg Exp $ 2ca58f742SDaniel Fojt# 3ca58f742SDaniel Fojt# @(#) Copyright (c) 2017, Simon J. Gerraty 4ca58f742SDaniel Fojt# 5ca58f742SDaniel Fojt# This file is provided in the hope that it will 6ca58f742SDaniel Fojt# be of use. There is absolutely NO WARRANTY. 7ca58f742SDaniel Fojt# Permission to copy, redistribute or otherwise 8ca58f742SDaniel Fojt# use this file is hereby granted provided that 9ca58f742SDaniel Fojt# the above copyright notice and this notice are 10ca58f742SDaniel Fojt# left intact. 11ca58f742SDaniel Fojt# 12ca58f742SDaniel Fojt# Please send copies of changes and bug-fixes to: 13ca58f742SDaniel Fojt# sjg@crufty.net 14ca58f742SDaniel Fojt# 15ca58f742SDaniel Fojt 16ca58f742SDaniel Fojt.include <init.mk> 17ca58f742SDaniel Fojt 18ca58f742SDaniel FojtFILES_INSTALL_OWN ?= -o ${SHAREOWN} -g ${SHAREGRP} 19ca58f742SDaniel FojtFILESMODE ?= ${SHAREMODE} 20ca58f742SDaniel FojtFILES_COPY ?= -C 21ca58f742SDaniel Fojt 22ca58f742SDaniel FojtFILESGROUPS ?= FILES 23ca58f742SDaniel FojtFILESGROUPS := ${FILESGROUPS:O:u} 24ca58f742SDaniel Fojt 25ca58f742SDaniel Fojt.if !target(buildfiles) 26ca58f742SDaniel Fojt.for group in ${FILESGROUPS} 27ca58f742SDaniel Fojtbuildfiles: ${${group}} 28ca58f742SDaniel Fojt.endfor 29ca58f742SDaniel Fojt.endif 30ca58f742SDaniel Fojtbuildfiles: 31ca58f742SDaniel Fojtrealbuild: buildfiles 32ca58f742SDaniel Fojt 33ca58f742SDaniel Fojt# there is no default FILESDIR so 34ca58f742SDaniel Fojt# ignore group if ${group}DIR is not defined 35ca58f742SDaniel Fojt.for group in ${FILESGROUPS} 36ca58f742SDaniel Fojt.if !empty(${group}) && defined(${group}DIR) 37ca58f742SDaniel Fojt.if ${group} != "FILES" 38ca58f742SDaniel Fojt${group}_INSTALL_OWN ?= ${FILES_INSTALL_OWN} 39ca58f742SDaniel Fojt.endif 40ca58f742SDaniel Fojt# incase we are staging 41ca58f742SDaniel FojtSTAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR} 42ca58f742SDaniel Fojt 43ca58f742SDaniel Fojt.for file in ${${group}:O:u} 44ca58f742SDaniel Fojt${group}_INSTALL_OWN.${file:T} ?= ${${group}_INSTALL_OWN} 45ca58f742SDaniel Fojt${group}DIR.${file:T} ?= ${${group}DIR} 46ca58f742SDaniel Fojtfile_mkdir_list += ${${group}DIR.${file:T}} 47ca58f742SDaniel Fojt 48ca58f742SDaniel Fojt.if defined(${group}NAME.${file:T}) 49ca58f742SDaniel FojtSTAGE_AS_SETS += ${group} 50ca58f742SDaniel FojtSTAGE_AS_${file} = ${${group}NAME.${file:T}} 51ca58f742SDaniel Fojtstage_as.${group}: ${file} 52ca58f742SDaniel Fojt 53ca58f742SDaniel Fojtinstallfiles: installfiles.${group}.${file:T} 54ca58f742SDaniel Fojtinstallfiles.${group}.${file:T}: ${file} file_mkdirs 55ca58f742SDaniel Fojt ${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN.${file:T}} \ 56ca58f742SDaniel Fojt -m ${FILESMODE} ${.ALLSRC:Nfile_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${file:T}} 57ca58f742SDaniel Fojt 58ca58f742SDaniel Fojt.else 59ca58f742SDaniel FojtSTAGE_SETS += ${group} 60ca58f742SDaniel Fojtstage_files.${group}: ${file} 61ca58f742SDaniel Fojtinstallfiles.${group}: ${file} 62ca58f742SDaniel Fojtinstallfiles: installfiles.${group} 63ca58f742SDaniel Fojt.endif 64ca58f742SDaniel Fojt 65ca58f742SDaniel Fojt.endfor # file 66ca58f742SDaniel Fojt 67ca58f742SDaniel Fojtinstallfiles.${group}: file_mkdirs 68ca58f742SDaniel Fojt ${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN} -m ${FILESMODE} \ 69ca58f742SDaniel Fojt ${.ALLSRC:Nfile_mkdirs:O:u} ${DESTDIR}${${group}DIR} 70ca58f742SDaniel Fojt 71ca58f742SDaniel Fojt.endif # !empty 72ca58f742SDaniel Fojt.endfor # group 73ca58f742SDaniel Fojt 74ca58f742SDaniel Fojtfile_mkdirs: 75ca58f742SDaniel Fojt @for d in ${file_mkdir_list:O:u}; do \ 76ca58f742SDaniel Fojt test -d ${DESTDIR}$$d || \ 77ca58f742SDaniel Fojt ${INSTALL} -d ${FILES_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \ 78ca58f742SDaniel Fojt done 79ca58f742SDaniel Fojt 80ca58f742SDaniel Fojtbeforeinstall: 81ca58f742SDaniel Fojtinstallfiles: 82ca58f742SDaniel Fojtrealinstall: installfiles 83ca58f742SDaniel Fojt.ORDER: beforeinstall installfiles 84