]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/bmake/mk/scripts.mk
MFC bmake-20170720
[FreeBSD/stable/10.git] / contrib / bmake / mk / scripts.mk
1 # $Id: scripts.mk,v 1.3 2017/05/06 17:29:45 sjg Exp $
2 #
3 #       @(#) Copyright (c) 2006, Simon J. Gerraty
4 #
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. 
11 #      
12 #       Please send copies of changes and bug-fixes to:
13 #       sjg@crufty.net
14 #
15
16 .include <init.mk>
17
18 SCRIPTSGROUPS ?= SCRIPTS
19 SCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u}
20
21 SCRIPTSDIR?=    ${BINDIR}
22 SCRIPTSOWN?=    ${BINOWN}
23 SCRIPTSGRP?=    ${BINGRP}
24 SCRIPTSMODE?=   ${BINMODE}
25
26 SCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP}
27 SCRIPTS_COPY ?= -C
28
29 # how we get script name from src
30 SCRIPTSNAME_MOD?=T:R
31
32 .if !target(buildfiles)
33 .for group in ${SCRIPTSGROUPS}
34 buildfiles: ${${group}}
35 .endfor
36 .endif
37 buildfiles:
38 realbuild: buildfiles
39
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}
47
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}}
52
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}
58
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}}
63
64 .else
65 STAGE_SETS += ${group}
66 stage_files.${group}: ${script}
67 installscripts.${group}: ${script}
68 installscripts: installscripts.${group}
69 .endif
70
71 .endfor                         # script
72
73 installscripts.${group}: script_mkdirs
74         ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \
75         ${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR}
76
77 .endif                          # !empty
78 .endfor                         # group
79
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 775 ${DESTDIR}$$d; \
84         done
85
86
87 beforeinstall:
88 installscripts:
89 realinstall:    installscripts
90 .ORDER: beforeinstall installscripts
91