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