xref: /freebsd/share/mk/bsd.files.mk (revision 1669d8afc64812c8d2d1d147ae1fd42ff441e1b1)
1# $FreeBSD$
2
3.if !target(__<bsd.init.mk>__)
4.error bsd.files.mk cannot be included directly.
5.endif
6
7FILESGROUPS?=	FILES
8
9.if !target(buildfiles)
10.for group in ${FILESGROUPS}
11buildfiles: ${${group}}
12.endfor
13.endif
14
15all: buildfiles
16
17.if !target(installfiles)
18.for group in ${FILESGROUPS}
19.if defined(${group}) && !empty(${group})
20
21${group}OWN?=	${SHAREOWN}
22${group}GRP?=	${SHAREGRP}
23${group}MODE?=	${SHAREMODE}
24${group}DIR?=	${BINDIR}
25
26_${group}FILES=
27.for file in ${${group}}
28.if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
29    defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \
30    defined(${group}NAME_${file:T})
31${group}OWN_${file:T}?=	${${group}OWN}
32${group}GRP_${file:T}?=	${${group}GRP}
33${group}MODE_${file:T}?=	${${group}MODE}
34${group}DIR_${file:T}?=	${${group}DIR}
35.if defined(${group}NAME)
36${group}NAME_${file:T}?=	${${group}NAME}
37.else
38${group}NAME_${file:T}?=	${file:T}
39.endif
40installfiles: _${group}INS_${file:T}
41_${group}INS_${file:T}: ${file}
42	${INSTALL} -o ${${group}OWN_${.ALLSRC:T}} \
43	    -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
44	    ${.ALLSRC} \
45	    ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
46.else
47_${group}FILES+= ${file}
48.endif
49.endfor
50.if !empty(_${group}FILES)
51installfiles: _${group}INS
52_${group}INS: ${_${group}FILES}
53.if defined(${group}NAME)
54	${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
55	    -m ${${group}MODE} ${.ALLSRC} \
56	    ${DESTDIR}${${group}DIR}/${${group}NAME}
57.else
58	${INSTALL} -o ${${group}OWN} -g ${${group}GRP} \
59	    -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}
60.endif
61.endif
62
63.endif # defined(${group}) && !empty(${group})
64.endfor
65
66.endif # !target(installfiles)
67
68realinstall: installfiles
69.ORDER: beforeinstall installfiles
70