]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.files.mk
Add a 'make print-dir' that simply traverses all directories and prints them.
[FreeBSD/FreeBSD.git] / share / mk / bsd.files.mk
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
10 FILESGROUPS?=   FILES
11
12 _FILESGROUPS=   ${FILESGROUPS:C,[/*],_,g:u}
13
14 .for group in ${_FILESGROUPS}
15 # Add in foo.yes and remove duplicates from all the groups
16 ${${group}}:= ${${group}} ${${group}.yes}
17 ${${group}}:= ${${group}:O:u}
18 buildfiles: ${${group}}
19 .endfor
20
21 .if !defined(_SKIP_BUILD)
22 all: buildfiles
23 .endif
24
25 .for group in ${_FILESGROUPS}
26 .if defined(${group}) && !empty(${group})
27 installfiles: installfiles-${group}
28
29 ${group}OWN?=   ${SHAREOWN}
30 ${group}GRP?=   ${SHAREGRP}
31 ${group}MODE?=  ${SHAREMODE}
32 ${group}DIR?=   ${BINDIR}
33 STAGE_SETS+=    ${group}
34 STAGE_DIR.${group}= ${STAGE_OBJTOP}${${group}DIR}
35
36 .if defined(NO_ROOT)
37 .if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
38 ${group}TAGS+=          package=${${group}PACKAGE:Uruntime}
39 .endif
40 ${group}TAG_ARGS=       -T ${${group}TAGS:[*]:S/ /,/g}
41 .endif
42
43
44 _${group}FILES=
45 .for file in ${${group}}
46 .if defined(${group}OWN_${file:T}) || defined(${group}GRP_${file:T}) || \
47     defined(${group}MODE_${file:T}) || defined(${group}DIR_${file:T}) || \
48     defined(${group}NAME_${file:T}) || defined(${group}NAME)
49 ${group}OWN_${file:T}?= ${${group}OWN}
50 ${group}GRP_${file:T}?= ${${group}GRP}
51 ${group}MODE_${file:T}?=        ${${group}MODE}
52 ${group}DIR_${file:T}?= ${${group}DIR}
53 .if defined(${group}NAME)
54 ${group}NAME_${file:T}?=        ${${group}NAME}
55 .else
56 ${group}NAME_${file:T}?=        ${file:T}
57 .endif
58 STAGE_AS_SETS+= ${file:T}
59 STAGE_AS_${file:T}= ${${group}NAME_${file:T}}
60 # XXX {group}OWN,GRP,MODE
61 STAGE_DIR.${file:T}= ${STAGE_OBJTOP}${${group}DIR_${file:T}}
62 stage_as.${file:T}: ${file}
63
64 installfiles-${group}: _${group}INS_${file:T}
65 _${group}INS_${file:T}: ${file}
66         ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${.ALLSRC:T}} \
67             -g ${${group}GRP_${.ALLSRC:T}} -m ${${group}MODE_${.ALLSRC:T}} \
68             ${.ALLSRC} \
69             ${DESTDIR}${${group}DIR_${.ALLSRC:T}}/${${group}NAME_${.ALLSRC:T}}
70 .else
71 _${group}FILES+= ${file}
72 .endif
73 .endfor
74 .if !empty(_${group}FILES)
75 stage_files.${group}: ${_${group}FILES}
76
77 installfiles-${group}: _${group}INS
78 _${group}INS: ${_${group}FILES}
79 .if defined(${group}NAME)
80         ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
81             -m ${${group}MODE} ${.ALLSRC} \
82             ${DESTDIR}${${group}DIR}/${${group}NAME}
83 .else
84         ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN} -g ${${group}GRP} \
85             -m ${${group}MODE} ${.ALLSRC} ${DESTDIR}${${group}DIR}/
86 .endif
87 .endif
88
89 .endif # defined(${group}) && !empty(${group})
90 .endfor
91
92 realinstall: installfiles
93 .ORDER: beforeinstall installfiles
94
95 .if ${MK_STAGING} != "no"
96 .if !empty(STAGE_SETS)
97 buildfiles: stage_files
98 .if !empty(STAGE_AS_SETS)
99 buildfiles: stage_as
100 .endif
101 .endif
102 .endif
103
104 .endif # !target(__<bsd.files.mk>__)