xref: /freebsd/share/mk/bsd.files.mk (revision d9f0ce31900a48d1a2bfc1c8c86f79d1e831451a)
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}
33STAGE_SETS+=	${group}
34STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
35
36.if defined(NO_ROOT)
37.if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
38${group}TAGS+=		package=${${group}PACKAGE:Uruntime}
39.endif
40${group}TAG_ARGS=	-T ${${group}TAGS:[*]:S/ /,/g}
41.endif
42
43
44_${group}FILES=
45.for file in ${${group}}
46.if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
47    defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \
48    defined(${group}NAME_${file:T}) || defined(${group}NAME)
49${group}OWN_${file:T}?=	${${group}OWN}
50${group}GRP_${file:T}?=	${${group}GRP}
51${group}MODE_${file:T}?=	${${group}MODE}
52${group}DIR_${file:T}?=	${${group}DIR}
53.if defined(${group}NAME)
54${group}NAME_${file:T}?=	${${group}NAME}
55.else
56${group}NAME_${file:T}?=	${file:T}
57.endif
58STAGE_AS_SETS+=	${file:T}
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