etc/protocols - sync with NetBSD-8
[minix.git] / share / mk / bsd.files.mk
blob4a1df65d5e4f6ba156150bf93d684bee78ca490e
1 # $NetBSD: bsd.files.mk,v 1.43 2013/04/06 15:39:19 uebayasi Exp $
3 .if !defined(_BSD_FILES_MK_)
4 _BSD_FILES_MK_=1
6 .include <bsd.init.mk>
8 .if !target(__fileinstall)
9 ##### Basic targets
10 realinstall: filesinstall
11 realall: filesbuild
13 ##### Default values
14 FILESDIR?= ${BINDIR}
15 FILESOWN?= ${BINOWN}
16 FILESGRP?= ${BINGRP}
17 FILESMODE?= ${NONBINMODE}
19 ##### Build rules
20 filesbuild:
21 .PHONY: filesbuild
23 ##### Install rules
24 filesinstall:: # ensure existence
25 .PHONY: filesinstall
27 configfilesinstall:: .PHONY
29 __fileinstall: .USE
30 ${_MKTARGET_INSTALL}
31 ${INSTALL_FILE} \
32 -o ${FILESOWN_${.ALLSRC:T}:U${FILESOWN}} \
33 -g ${FILESGRP_${.ALLSRC:T}:U${FILESGRP}} \
34 -m ${FILESMODE_${.ALLSRC:T}:U${FILESMODE}} \
35 ${SYSPKGTAG} ${.ALLSRC} ${.TARGET}
37 .endif # !target(__fileinstall)
40 .for F in ${FILES:O:u}
41 _FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override
42 _FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override
43 _F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path
44 _FDOBUILD:= ${FILESBUILD_${F}:U${FILESBUILD:Uno}}
46 .if ${MKUPDATE} == "no"
47 ${_F}! ${F} __fileinstall # install rule
48 .if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no")
49 ${_F}! .MADE # no build at install
50 .endif
51 .else
52 ${_F}: ${F} __fileinstall # install rule
53 .if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no")
54 ${_F}: .MADE # no build at install
55 .endif
56 .endif
58 .if ${_FDOBUILD} != "no"
59 filesbuild: ${F}
60 CLEANFILES+= ${F}
61 .endif
63 filesinstall:: ${_F}
64 .PRECIOUS: ${_F} # keep if install fails
65 .endfor
69 # CONFIGFILES
71 configinstall: configfilesinstall
73 .for F in ${CONFIGFILES:O:u}
74 _FDIR:= ${FILESDIR_${F}:U${FILESDIR}} # dir override
75 _FNAME:= ${FILESNAME_${F}:U${FILESNAME:U${F:T}}} # name override
76 _F:= ${DESTDIR}${_FDIR}/${_FNAME} # installed path
77 _FDOBUILD:= ${FILESBUILD_${F}:U${FILESBUILD:Uno}}
79 .if ${MKUPDATE} == "no"
80 ${_F}! ${F} __fileinstall # install rule
81 .if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no")
82 ${_F}! .MADE # no build at install
83 .endif
84 .else
85 ${_F}: ${F} __fileinstall # install rule
86 .if !defined(BUILD) && !make(all) && !make(${F}) && (${_FDOBUILD} == "no")
87 ${_F}: .MADE # no build at install
88 .endif
89 .endif
91 .if ${_FDOBUILD} != "no"
92 filesbuild: ${F}
93 CLEANFILES+= ${F}
94 .endif
96 configfilesinstall:: ${_F}
97 .PRECIOUS: ${_F} # keep if install fails
98 .endfor
100 .undef _FDIR
101 .undef _FNAME
102 .undef _F
106 # BUILDSYMLINKS
108 .if defined(BUILDSYMLINKS) # {
110 .for _SL _TL in ${BUILDSYMLINKS}
111 BUILDSYMLINKS.s+= ${_SL}
112 BUILDSYMLINKS.t+= ${_TL}
113 ${_TL}: ${_SL}
114 ${_MKMSG} "symlink " ${.CURDIR:T}/${.TARGET}
115 rm -f ${.TARGET}
116 ln -s ${.ALLSRC} ${.TARGET}
117 .endfor
119 realall: ${BUILDSYMLINKS.t}
121 CLEANDIRFILES+= ${BUILDSYMLINKS.t}
123 .endif # }
126 # .uue -> "" handling (i.e. decode a given binary/object)
128 # UUDECODE_FILES - List of files which are stored in the source tree
129 # as <file>.uue and should be uudecoded.
131 # UUDECODE_FILES_RENAME_fn - For this file, rename its output to the provided
132 # name (handled via -p and redirecting stdout)
134 .if defined(UUDECODE_FILES) # {
135 .SUFFIXES: .uue
137 .uue:
138 ${_MKTARGET_CREATE}
139 rm -f ${.TARGET}
140 ${TOOL_UUDECODE} -p ${.IMPSRC} > ${.TARGET}
142 .if defined(UUDECODE_FILES_RENAME_${UUDECODE_FILES})
143 ${UUDECODE_FILES_RENAME_${UUDECODE_FILES}}: ${UUDECODE_FILES}
144 cp ${.ALLSRC} ${.TARGET}
145 .endif
147 realall: ${UUDECODE_FILES}
149 CLEANUUDECODE_FILES=${UUDECODE_FILES}
150 .for i in ${UUDECODE_FILES}
151 CLEANUUDECODE_FILES+=${UUDECODE_FILES_RENAME_${i}}
152 .endfor
154 CLEANFILES+= ${CLEANUUDECODE_FILES}
155 .endif # }
157 ##### Pull in related .mk logic
158 .include <bsd.obj.mk>
159 .include <bsd.sys.mk>
160 .include <bsd.clean.mk>
162 .endif # !defined(_BSD_FILES_MK_)