bsd.links.mk revision 1.32 1 # $NetBSD: bsd.links.mk,v 1.32 2006/09/11 22:24:09 dbj Exp $
2
3 .include <bsd.init.mk>
4
5 ##### Basic targets
6 install: linksinstall
7
8 ##### Default values
9 LINKS?=
10 SYMLINKS?=
11
12 __linkinstall: .USE
13 ${_MKSHMSG_INSTALL} ${.TARGET}; \
14 ${_MKSHECHO} "${INSTALL_LINK} ${.ALLSRC} ${.TARGET}" && \
15 ${INSTALL_LINK} ${.ALLSRC} ${.TARGET}
16
17 ##### Install rules
18 .PHONY: linksinstall
19 linksinstall:: realinstall
20 .if !empty(SYMLINKS)
21 @(set ${SYMLINKS}; \
22 while test $$# -ge 2; do \
23 l=$$1; shift; \
24 t=${DESTDIR}$$1; shift; \
25 if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \
26 [ "$$l" = "$$ttarg" ]; then \
27 continue ; \
28 fi ; \
29 ${_MKSHMSG_INSTALL} $$t; \
30 ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \
31 ${INSTALL_SYMLINK} $$l $$t; \
32 done; )
33 .endif
34
35 .for _src _dst in ${LINKS}
36 _l:=${DESTDIR}${_src}
37 _t:=${DESTDIR}${_dst}
38
39 # Handle case conflicts carefully, when _dst occurs
40 # more than once after case flattening
41 .if ${MKUPDATE} == "no" || ${LINKS:tl:M${_dst:tl:Q}:[\#]} > 1
42 ${_t}! ${_l} __linkinstall
43 .else
44 ${_t}: ${_l} __linkinstall
45 .endif
46
47 linksinstall:: ${_t}
48 .PRECIOUS: ${_t}
49 .endfor
50
51 configinstall: configlinksinstall
52 .PHONY: configlinksinstall
53 configlinksinstall:: configfilesinstall
54 .if defined(CONFIGSYMLINKS)
55 @(set ${CONFIGSYMLINKS}; \
56 while test $$# -ge 2; do \
57 l=$$1; shift; \
58 t=${DESTDIR}$$1; shift; \
59 if ttarg=`${TOOL_STAT} -qf '%Y' $$t` && \
60 [ "$$l" = "$$ttarg" ]; then \
61 continue ; \
62 fi ; \
63 ${_MKSHMSG_INSTALL} $$t; \
64 ${_MKSHECHO} ${INSTALL_SYMLINK} $$l $$t; \
65 ${INSTALL_SYMLINK} $$l $$t; \
66 done; )
67 .endif
68
69 .for _src _dst in ${CONFIGLINKS}
70 _l:=${DESTDIR}${_src}
71 _t:=${DESTDIR}${_dst}
72
73 # Handle case conflicts carefully, when _dst occurs
74 # more than once after case flattening
75 .if ${MKUPDATE} == "no" || ${CONFIGLINKS:tl:M${_dst:tl:Q}:[\#]} > 1
76 ${_t}! ${_l} __linkinstall
77 .else
78 ${_t}: ${_l} __linkinstall
79 .endif
80
81 configlinksinstall:: ${_t}
82 .PRECIOUS: ${_t}
83 .endfor
84
85 .include <bsd.sys.mk>
86