]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.files.mk
Merge from head
[FreeBSD/FreeBSD.git] / share / mk / bsd.files.mk
1 # $FreeBSD$
2
3 .if !target(__<bsd.init.mk>__)
4 .error bsd.files.mk cannot be included directly.
5 .endif
6
7 .if !target(__<bsd.files.mk>__)
8 __<bsd.files.mk>__:
9
10 FILESGROUPS?=   FILES
11
12 .for group in ${FILESGROUPS}
13 # Add in foo.yes and remove duplicates from all the groups
14 ${${group}}:= ${${group}} ${${group}.yes}
15 ${${group}}:= ${${group}:O:u}
16 buildfiles: ${${group}}
17 .endfor
18
19 all: buildfiles
20
21 .for group in ${FILESGROUPS}
22 .if defined(${group}) && !empty(${group})
23 installfiles: installfiles-${group}
24
25 ${group}OWN?=   ${SHAREOWN}
26 ${group}GRP?=   ${SHAREGRP}
27 ${group}MODE?=  ${SHAREMODE}
28 ${group}DIR?=   ${BINDIR}
29 .if !make(buildincludes)
30 STAGE_SETS+=    ${group}
31 .endif
32 STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
33 STAGE_SYMLINKS_DIR.${group}= ${STAGE_OBJTOP}
34
35 .if defined(NO_ROOT)
36 .if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
37 ${group}TAGS+=          package=${${group}PACKAGE:Uruntime}
38 .endif
39 ${group}TAG_ARGS=       -T ${${group}TAGS:[*]:S/ /,/g}
40 .endif
41
42
43 _${group}FILES=
44 .for file in ${${group}}
45 .if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
46     defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \
47     defined(${group}NAME_${file:T})
48 ${group}OWN_${file:T}?= ${${group}OWN}
49 ${group}GRP_${file:T}?= ${${group}GRP}
50 ${group}MODE_${file:T}?=        ${${group}MODE}
51 ${group}DIR_${file:T}?= ${${group}DIR}
52 .if defined(${group}NAME)
53 ${group}NAME_${file:T}?=        ${${group}NAME}
54 .else
55 ${group}NAME_${file:T}?=        ${file:T}
56 .endif
57 .if !make(buildincludes)
58 STAGE_AS_SETS+= ${group}
59 .endif
60 STAGE_AS_${file:T}= ${${group}NAME_${file:T}}
61 stage_as.${group}: ${file}
62
63 installfiles-${group}: _${group}INS_${file:T}
64 _${group}INS_${file:T}: ${file}
65         ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${.ALLSRC:T}} \
66             -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
67             ${.ALLSRC} \
68             ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
69 .else
70 _${group}FILES+= ${file}
71 .endif
72 .endfor
73 .if !empty(_${group}FILES)
74 stage_files.${group}: ${_${group}FILES}
75
76 installfiles-${group}: _${group}INS
77 _${group}INS: ${_${group}FILES}
78 .if defined(${group}NAME)
79         ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
80             -m ${${group}MODE} ${.ALLSRC} \
81             ${DESTDIR}${${group}DIR}/${${group}NAME}
82 .else
83         ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
84             -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
85 .endif
86 .endif
87
88 .endif # defined(${group}) && !empty(${group})
89 .endfor
90
91 realinstall: installfiles
92 .ORDER: beforeinstall installfiles
93
94 .if ${MK_STAGING} != "no"
95 .if !empty(STAGE_SETS)
96 buildfiles: stage_files
97 .if !empty(STAGE_AS_SETS)
98 buildfiles: stage_as
99 .endif
100 .endif
101 .endif
102
103 .endif # !target(__<bsd.files.mk>__)