No empty .Rs/.Re
[netbsd-mini2440.git] / share / mk / bsd.links.mk
blob73c03b724bd209ee35595fb03f252ed4dd18fbbf
1 # $NetBSD: bsd.links.mk,v 1.33 2009/03/01 09:42:41 isaki Exp $
3 .include <bsd.init.mk>
5 ##### Basic targets
6 install: linksinstall
8 ##### Default values
9 LINKS?=
10 SYMLINKS?=
11 LINKSOWN?= ${BINOWN}
12 LINKSGRP?= ${BINGRP}
13 LINKSMODE?= ${NONBINMODE}
15 __linkinstall: .USE
16 ${_MKSHMSG_INSTALL} ${.TARGET}; \
17 ${_MKSHECHO} "${INSTALL_LINK} \
18 -o ${LINKSOWN_${.ALLSRC:T}:U${LINKSOWN}} \
19 -g ${LINKSGRP_${.ALLSRC:T}:U${LINKSGRP}} \
20 -m ${LINKSMODE_${.ALLSRC:T}:U${LINKSMODE}} \
21 ${.ALLSRC} ${.TARGET}" && \
22 ${INSTALL_LINK} \
23 -o ${LINKSOWN_${.ALLSRC:T}:U${LINKSOWN}} \
24 -g ${LINKSGRP_${.ALLSRC:T}:U${LINKSGRP}} \
25 -m ${LINKSMODE_${.ALLSRC:T}:U${LINKSMODE}} \
26 ${.ALLSRC} ${.TARGET}
28 ##### Install rules
29 .PHONY: linksinstall
30 linksinstall:: realinstall
31 .if !empty(SYMLINKS)
32 @(set ${SYMLINKS}; \
33 while test $$# -ge 2; do \
34 l=$$1; shift; \
35 t=${DESTDIR}$$1; shift; \
36 if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \
37 [ "$$l" = "$$ttarg" ]; then \
38 continue ; \
39 fi ; \
40 ${_MKSHMSG_INSTALL} $$t; \
41 ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \
42 ${INSTALL_SYMLINK} $$l $$t; \
43 done; )
44 .endif
46 .for _src _dst in ${LINKS}
47 _l:=${DESTDIR}${_src}
48 _t:=${DESTDIR}${_dst}
50 # Handle case conflicts carefully, when _dst occurs
51 # more than once after case flattening
52 .if ${MKUPDATE} == "no" || ${LINKS:tl:M${_dst:tl:Q}:[\#]} > 1
53 ${_t}! ${_l} __linkinstall
54 .else
55 ${_t}: ${_l} __linkinstall
56 .endif
58 linksinstall:: ${_t}
59 .PRECIOUS: ${_t}
60 .endfor
62 configinstall: configlinksinstall
63 .PHONY: configlinksinstall
64 configlinksinstall:: configfilesinstall
65 .if !empty(CONFIGSYMLINKS)
66 @(set ${CONFIGSYMLINKS}; \
67 while test $$# -ge 2; do \
68 l=$$1; shift; \
69 t=${DESTDIR}$$1; shift; \
70 if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \
71 [ "$$l" = "$$ttarg" ]; then \
72 continue ; \
73 fi ; \
74 ${_MKSHMSG_INSTALL} $$t; \
75 ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \
76 ${INSTALL_SYMLINK} $$l $$t; \
77 done; )
78 .endif
80 .for _src _dst in ${CONFIGLINKS}
81 _l:=${DESTDIR}${_src}
82 _t:=${DESTDIR}${_dst}
84 # Handle case conflicts carefully, when _dst occurs
85 # more than once after case flattening
86 .if ${MKUPDATE} == "no" || ${CONFIGLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
87 ${_t}! ${_l} __linkinstall
88 .else
89 ${_t}: ${_l} __linkinstall
90 .endif
92 configlinksinstall:: ${_t}
93 .PRECIOUS: ${_t}
94 .endfor
96 .include <bsd.sys.mk>