1*a34d5fb1SAntonio Huete Jimenez# $Id: scripts.mk,v 1.4 2020/08/19 17:51:53 sjg Exp $ 2ca58f742SDaniel Fojt# 3ca58f742SDaniel Fojt# @(#) Copyright (c) 2006, 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# 155f1e34d9SAlexandre Perrin 165f1e34d9SAlexandre Perrin.include <init.mk> 175f1e34d9SAlexandre Perrin 18ca58f742SDaniel FojtSCRIPTSGROUPS ?= SCRIPTS 19ca58f742SDaniel FojtSCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u} 205f1e34d9SAlexandre Perrin 215f1e34d9SAlexandre PerrinSCRIPTSDIR?= ${BINDIR} 225f1e34d9SAlexandre PerrinSCRIPTSOWN?= ${BINOWN} 235f1e34d9SAlexandre PerrinSCRIPTSGRP?= ${BINGRP} 245f1e34d9SAlexandre PerrinSCRIPTSMODE?= ${BINMODE} 255f1e34d9SAlexandre Perrin 26ca58f742SDaniel FojtSCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP} 27ca58f742SDaniel FojtSCRIPTS_COPY ?= -C 28ca58f742SDaniel Fojt 295f1e34d9SAlexandre Perrin# how we get script name from src 305f1e34d9SAlexandre PerrinSCRIPTSNAME_MOD?=T:R 315f1e34d9SAlexandre Perrin 32ca58f742SDaniel Fojt.if !target(buildfiles) 33ca58f742SDaniel Fojt.for group in ${SCRIPTSGROUPS} 34ca58f742SDaniel Fojtbuildfiles: ${${group}} 355f1e34d9SAlexandre Perrin.endfor 365f1e34d9SAlexandre Perrin.endif 37ca58f742SDaniel Fojtbuildfiles: 38ca58f742SDaniel Fojtrealbuild: buildfiles 395f1e34d9SAlexandre Perrin 40ca58f742SDaniel Fojt.for group in ${SCRIPTSGROUPS} 41ca58f742SDaniel Fojt.if !empty(${group}) && defined(${group}DIR) 42ca58f742SDaniel Fojt.if ${group} != "SCRIPTS" 43ca58f742SDaniel Fojt${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN} 44ca58f742SDaniel Fojt.endif 45ca58f742SDaniel Fojt# incase we are staging 46ca58f742SDaniel FojtSTAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR} 47ca58f742SDaniel Fojt 48ca58f742SDaniel Fojt.for script in ${${group}:O:u} 49ca58f742SDaniel Fojt${group}_INSTALL_OWN.${script:T} ?= ${${group}_INSTALL_OWN} 50ca58f742SDaniel Fojt${group}DIR.${script:T} ?= ${${group}DIR_${script:T}:U${${group}DIR}} 51ca58f742SDaniel Fojtscript_mkdir_list += ${${group}DIR.${script:T}} 52ca58f742SDaniel Fojt 53ca58f742SDaniel Fojt${group}NAME.${script} ?= ${${group}NAME_${script:T}:U${script:${SCRIPTSNAME_MOD}}} 54ca58f742SDaniel Fojt.if ${${group}NAME.${script}:T} != ${script:T} 55ca58f742SDaniel FojtSTAGE_AS_SETS += ${group} 56ca58f742SDaniel FojtSTAGE_AS_${script} = ${${group}NAME.${script:T}} 57ca58f742SDaniel Fojtstage_as.${group}: ${script} 58ca58f742SDaniel Fojt 59ca58f742SDaniel Fojtinstallscripts: installscripts.${group}.${script:T} 60ca58f742SDaniel Fojtinstallscripts.${group}.${script:T}: ${script} script_mkdirs 61ca58f742SDaniel Fojt ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN.${script:T}} \ 62ca58f742SDaniel Fojt -m ${SCRIPTSMODE} ${.ALLSRC:Nscript_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${script:T}} 63ca58f742SDaniel Fojt 64ca58f742SDaniel Fojt.else 65ca58f742SDaniel FojtSTAGE_SETS += ${group} 66ca58f742SDaniel Fojtstage_files.${group}: ${script} 67ca58f742SDaniel Fojtinstallscripts.${group}: ${script} 68ca58f742SDaniel Fojtinstallscripts: installscripts.${group} 695f1e34d9SAlexandre Perrin.endif 705f1e34d9SAlexandre Perrin 71ca58f742SDaniel Fojt.endfor # script 72ca58f742SDaniel Fojt 73ca58f742SDaniel Fojtinstallscripts.${group}: script_mkdirs 74ca58f742SDaniel Fojt ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \ 75ca58f742SDaniel Fojt ${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR} 76ca58f742SDaniel Fojt 77ca58f742SDaniel Fojt.endif # !empty 78ca58f742SDaniel Fojt.endfor # group 79ca58f742SDaniel Fojt 80ca58f742SDaniel Fojtscript_mkdirs: 81ca58f742SDaniel Fojt @for d in ${script_mkdir_list:O:u}; do \ 82ca58f742SDaniel Fojt test -d ${DESTDIR}$$d || \ 83ca58f742SDaniel Fojt ${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \ 84ca58f742SDaniel Fojt done 85ca58f742SDaniel Fojt 86ca58f742SDaniel Fojt 87ca58f742SDaniel Fojtbeforeinstall: 88ca58f742SDaniel Fojtinstallscripts: 89ca58f742SDaniel Fojtrealinstall: installscripts 90ca58f742SDaniel Fojt.ORDER: beforeinstall installscripts 915f1e34d9SAlexandre Perrin 92