1 # $Id: scripts.mk,v 1.3 2017/05/06 17:29:45 sjg Exp $
3 # @(#) Copyright (c) 2006, Simon J. Gerraty
5 # This file is provided in the hope that it will
6 # be of use. There is absolutely NO WARRANTY.
7 # Permission to copy, redistribute or otherwise
8 # use this file is hereby granted provided that
9 # the above copyright notice and this notice are
12 # Please send copies of changes and bug-fixes to:
18 SCRIPTSGROUPS ?= SCRIPTS
19 SCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u}
21 SCRIPTSDIR?= ${BINDIR}
22 SCRIPTSOWN?= ${BINOWN}
23 SCRIPTSGRP?= ${BINGRP}
24 SCRIPTSMODE?= ${BINMODE}
26 SCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP}
29 # how we get script name from src
32 .if !target(buildfiles)
33 .for group in ${SCRIPTSGROUPS}
34 buildfiles: ${${group}}
40 .for group in ${SCRIPTSGROUPS}
41 .if !empty(${group}) && defined(${group}DIR)
42 .if ${group} != "SCRIPTS"
43 ${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN}
45 # incase we are staging
46 STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR}
48 .for script in ${${group}:O:u}
49 ${group}_INSTALL_OWN.${script:T} ?= ${${group}_INSTALL_OWN}
50 ${group}DIR.${script:T} ?= ${${group}DIR_${script:T}:U${${group}DIR}}
51 script_mkdir_list += ${${group}DIR.${script:T}}
53 ${group}NAME.${script} ?= ${${group}NAME_${script:T}:U${script:${SCRIPTSNAME_MOD}}}
54 .if ${${group}NAME.${script}:T} != ${script:T}
55 STAGE_AS_SETS += ${group}
56 STAGE_AS_${script} = ${${group}NAME.${script:T}}
57 stage_as.${group}: ${script}
59 installscripts: installscripts.${group}.${script:T}
60 installscripts.${group}.${script:T}: ${script} script_mkdirs
61 ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN.${script:T}} \
62 -m ${SCRIPTSMODE} ${.ALLSRC:Nscript_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${script:T}}
65 STAGE_SETS += ${group}
66 stage_files.${group}: ${script}
67 installscripts.${group}: ${script}
68 installscripts: installscripts.${group}
73 installscripts.${group}: script_mkdirs
74 ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \
75 ${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR}
81 @for d in ${script_mkdir_list:O:u}; do \
82 test -d ${DESTDIR}$$d || \
83 ${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \
89 realinstall: installscripts
90 .ORDER: beforeinstall installscripts