1# $Id: scripts.mk,v 1.6 2025/08/09 22:42:24 sjg Exp $ 2# 3# @(#) Copyright (c) 2006, Simon J. Gerraty 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# Please send copies of changes and bug-fixes to: 8# sjg@crufty.net 9# 10 11.include <init.mk> 12 13SCRIPTSGROUPS ?= SCRIPTS 14SCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u} 15 16SCRIPTSDIR?= ${BINDIR} 17SCRIPTSOWN?= ${BINOWN} 18SCRIPTSGRP?= ${BINGRP} 19SCRIPTSMODE?= ${BINMODE} 20 21SCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP} 22SCRIPTS_COPY ?= -C 23 24# how we get script name from src 25SCRIPTSNAME_MOD?=T:R 26 27.if !target(buildfiles) 28.for group in ${SCRIPTSGROUPS} 29buildfiles: ${${group}} 30.endfor 31.endif 32buildfiles: 33realbuild: buildfiles 34 35.for group in ${SCRIPTSGROUPS} 36.if !empty(${group}) && defined(${group}DIR) 37.if ${group} != "SCRIPTS" 38${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN} 39.endif 40# incase we are staging 41STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR} 42 43.for script in ${${group}:O:u} 44${group}_INSTALL_OWN.${script:T} ?= ${${group}_INSTALL_OWN} 45${group}DIR.${script:T} ?= ${${group}DIR_${script:T}:U${${group}DIR}} 46script_mkdir_list += ${${group}DIR.${script:T}} 47 48${group}NAME.${script} ?= ${${group}NAME_${script:T}:U${script:${SCRIPTSNAME_MOD}}} 49.if ${${group}NAME.${script}:T} != ${script:T} 50STAGE_AS_SETS += ${group} 51STAGE_AS_${script} = ${${group}NAME.${script:T}} 52stage_as.${group}: ${script} 53 54installscripts: installscripts.${group}.${script:T} 55installscripts.${group}.${script:T}: ${script} script_mkdirs 56 ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN.${script:T}} \ 57 -m ${SCRIPTSMODE} ${.ALLSRC:Nscript_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${script:T}} 58 59.else 60STAGE_SETS += ${group} 61stage_files.${group}: ${script} 62installscripts.${group}: ${script} 63installscripts: installscripts.${group} 64.endif 65 66.endfor # script 67 68installscripts.${group}: script_mkdirs 69 ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \ 70 ${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR} 71 72.endif # !empty 73.endfor # group 74 75script_mkdirs: 76 @for d in ${script_mkdir_list:O:u}; do \ 77 test -d ${DESTDIR}$$d || \ 78 ${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \ 79 done 80 81 82beforeinstall: 83installscripts: 84realinstall: installscripts 85.ORDER: beforeinstall installscripts 86 87