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