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