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