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