Merge commit 'b31320a79e2054c6739b5229259dbf98f3afc547' into merges
[unleashed.git] / share / mk / scripts.mk
blob32ab8f826a47ba162de57cb3756ea41c41cb15c7
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
10 # left intact.
12 # Please send copies of changes and bug-fixes to:
13 # sjg@crufty.net
16 .include <init.mk>
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}
27 SCRIPTS_COPY ?= -C
29 # how we get script name from src
30 SCRIPTSNAME_MOD?=T:R
32 .if !target(buildfiles)
33 .for group in ${SCRIPTSGROUPS}
34 buildfiles: ${${group}}
35 .endfor
36 .endif
37 buildfiles:
38 realbuild: buildfiles
40 .for group in ${SCRIPTSGROUPS}
41 .if !empty(${group}) && defined(${group}DIR)
42 .if ${group} != "SCRIPTS"
43 ${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN}
44 .endif
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}}
64 .else
65 STAGE_SETS += ${group}
66 stage_files.${group}: ${script}
67 installscripts.${group}: ${script}
68 installscripts: installscripts.${group}
69 .endif
71 .endfor # script
73 installscripts.${group}: script_mkdirs
74 ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \
75 ${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR}
77 .endif # !empty
78 .endfor # group
80 script_mkdirs:
81 @for d in ${script_mkdir_list:O:u}; do \
82 test -d ${DESTDIR}$$d || \
83 ${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 755 ${DESTDIR}$$d; \
84 done
87 beforeinstall:
88 installscripts:
89 realinstall: installscripts
90 .ORDER: beforeinstall installscripts