]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.files.mk
nvmecontrol(8): Fix a few mandoc related issues and add a SEE ALSO section
[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 .if target(__<bsd.dirs.mk>__)
9 .error bsd.dirs.mk must be included after bsd.files.mk.
10 .endif
11
12 __<bsd.files.mk>__:
13
14 FILESGROUPS?=   FILES
15
16 .for group in ${FILESGROUPS}
17 # Add in foo.yes and remove duplicates from all the groups
18 ${${group}}:= ${${group}} ${${group}.yes}
19 ${${group}}:= ${${group}:O:u}
20 buildfiles: ${${group}}
21 .endfor
22
23 .if !defined(_SKIP_BUILD)
24 all: buildfiles
25 .endif
26
27 .for group in ${FILESGROUPS}
28 .if defined(${group}) && !empty(${group})
29 installfiles: installfiles-${group}
30
31 ${group}OWN?=   ${SHAREOWN}
32 ${group}GRP?=   ${SHAREGRP}
33 .if ${MK_INSTALL_AS_USER} == "yes"
34 ${group}OWN=    ${SHAREOWN}
35 ${group}GRP=    ${SHAREGRP}
36 .endif
37 ${group}MODE?=  ${SHAREMODE}
38 ${group}DIR?=   BINDIR
39 STAGE_SETS+=    ${group:C,[/*],_,g}
40
41 .if ${group} == "FILES"
42 FILESPACKAGE=   ${PACKAGE:Uutilities}
43 .endif
44
45 .if defined(NO_ROOT)
46 .if !defined(${group}TAGS) || ! ${${group}TAGS:Mpackage=*}
47 ${group}TAGS+=          package=${${group}PACKAGE:Uutilities}
48 .endif
49 ${group}TAG_ARGS=       -T ${${group}TAGS:[*]:S/ /,/g}
50 .endif
51
52
53 .if ${${group}DIR:S/^\///} == ${${group}DIR}
54 # ${group}DIR specifies a variable that specifies a path
55 DIRS+=  ${${group}DIR}
56 _${group}DIR=   ${${group}DIR}
57 .else
58 # ${group}DIR specifies a path
59 DIRS+=  ${group}DIR
60 _${group}DIR=   ${group}DIR
61 .endif
62
63 STAGE_DIR.${group:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR}}
64
65 .for file in ${${group}}
66 ${group}OWN_${file}?=   ${${group}OWN}
67 ${group}GRP_${file}?=   ${${group}GRP}
68 .if ${MK_INSTALL_AS_USER} == "yes"
69 ${group}OWN_${file}=    ${SHAREOWN}
70 ${group}GRP_${file}=    ${SHAREGRP}
71 .endif # ${MK_INSTALL_AS_USER} == "yes"
72 ${group}MODE_${file}?=  ${${group}MODE}
73
74 # Determine the directory for the current file.  Default to the parent group
75 # DIR, then check to see how to pass that variable on below.
76 ${group}DIR_${file}?=   ${${group}DIR}
77 .if ${${group}DIR_${file}:S/^\///} == ${${group}DIR_${file}}
78 # DIR specifies a variable that specifies a path
79 _${group}DIR_${file}=   ${${group}DIR_${file}}
80 .else
81 # DIR directly specifies a path
82 _${group}DIR_${file}=   ${group}DIR_${file}
83 .endif
84 ${group}PREFIX_${file}= ${DESTDIR}${${_${group}DIR_${file}}}
85
86 # Append DIR to DIRS if not already in place -- DIRS is already filtered, so
87 # this is primarily to ease inspection.
88 .for d in ${DIRS}
89 _DIRS+= ${${d}}
90 .endfor
91 .if ${DIRS:M${_${group}DIR_${file}}} == ""
92 .if ${_DIRS:M${${_${group}DIR_${file}}}} == ""
93 DIRS+=  ${_${group}DIR_${file}}
94 .else
95 _${group}DIR_${file}=   ${group}DIR
96 .endif
97 .endif
98
99 .if defined(${group}NAME)
100 ${group}NAME_${file}?=  ${${group}NAME}
101 .else
102 ${group}NAME_${file}?=  ${file:T}
103 .endif # defined(${group}NAME)
104 STAGE_AS_${file}= ${${group}NAME_${file}}
105 # we cannot use file safely as a set name
106 # since we cannot? apply :T
107 # but we can use the ${group}DIR_${file}
108 # as a set - meta.stage.mk will :O:u for us
109 # we need to expand ${group}DIR_${file} and replace
110 # all '/' and '*' with '_' to make a safe target name.
111 STAGE_AS_SETS+= ${${_${group}DIR_${file}}:C,[/*],_,g}
112 STAGE_DIR.${${_${group}DIR_${file}}:C,[/*],_,g}= ${STAGE_OBJTOP}${${_${group}DIR_${file}}}
113 stage_as.${${_${group}DIR_${file}}:C,[/*],_,g}: ${file}
114
115 installfiles-${group}: _${group}INS_${file}
116 _${group}INS_${file}: ${file} installdirs-${_${group}DIR_${file}}
117         ${INSTALL} ${${group}TAG_ARGS} -o ${${group}OWN_${file}} \
118             -g ${${group}GRP_${file}} -m ${${group}MODE_${file}} \
119             ${.ALLSRC:Ninstalldirs-*} ${${group}PREFIX_${file}}/${${group}NAME_${file}}
120 .endfor # file in ${${group}}
121
122 .endif # defined(${group}) && !empty(${group})
123 .endfor # .for group in ${FILESGROUPS}
124
125 realinstall: installfiles
126 .ORDER: beforeinstall installfiles
127
128 .if ${MK_STAGING} != "no"
129 .if ${FILESGROUPS:@g@${$g}@} != ""
130 .if !empty(STAGE_SETS)
131 buildfiles: stage_files
132 STAGE_TARGETS+= stage_files
133 stage_files:
134 .if !empty(STAGE_AS_SETS)
135 buildfiles: stage_as
136 STAGE_TARGETS+= stage_as
137 stage_as:
138 .endif
139 .endif
140 .endif
141 .endif
142
143 .include <bsd.dirs.mk>
144
145 .endif # !target(__<bsd.files.mk>__)