xref: /freebsd/share/mk/bsd.files.mk (revision b0b1dbdd)
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}
31STAGE_SETS+=	${group:C,[/*],_,g}
32STAGE_DIR.${group:C,[/*],_,g}= ${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
56STAGE_AS_SETS+=	${file:T}
57STAGE_AS_${file:T}= ${${group}NAME_${file:T}}
58# XXX {group}OWN,GRP,MODE
59STAGE_DIR.${file:T}= ${STAGE_OBJTOP}${${group}DIR_${file:T}}
60stage_as.${file:T}: ${file}
61
62installfiles-${group}: _${group}INS_${file:T}
63_${group}INS_${file:T}: ${file}
64	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${.ALLSRC:T}} \
65	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
66	    ${.ALLSRC} \
67	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
68.else
69_${group}FILES+= ${file}
70.endif
71.endfor
72.if !empty(_${group}FILES)
73stage_files.${group}: ${_${group}FILES}
74
75installfiles-${group}: _${group}INS
76_${group}INS: ${_${group}FILES}
77.if defined(${group}NAME)
78	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
79	    -m ${${group}MODE} ${.ALLSRC} \
80	    ${DESTDIR}${${group}DIR}/${${group}NAME}
81.else
82	${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
83	    -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}/
84.endif
85.endif
86
87.endif # defined(${group}) && !empty(${group})
88.endfor
89
90realinstall: installfiles
91.ORDER: beforeinstall installfiles
92
93.if ${MK_STAGING} != "no"
94.if !empty(STAGE_SETS)
95buildfiles: stage_files
96.if !empty(STAGE_AS_SETS)
97buildfiles: stage_as
98.endif
99.endif
100.endif
101
102.endif # !target(__<bsd.files.mk>__)
103