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