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