xref: /dragonfly/contrib/bmake/mk/links.mk (revision cfd1aba3)
1# $Id: links.mk,v 1.5 2005/07/11 18:01:05 sjg Exp $
2#
3#	@(#) Copyright (c) 2005, Simon J. Gerraty
4#
5#	This file is provided in the hope that it will
6#	be of use.  There is absolutely NO WARRANTY.
7#	Permission to copy, redistribute or otherwise
8#	use this file is hereby granted provided that
9#	the above copyright notice and this notice are
10#	left intact.
11#
12#	Please send copies of changes and bug-fixes to:
13#	sjg@crufty.net
14#
15
16# some platforms need something special
17LN?= ln
18ECHO?= echo
19
20LINKS?=
21SYMLINKS?=
22
23__SYMLINK_SCRIPT= \
24		${ECHO} "$$t -> $$l"; \
25		mkdir -p `dirname $$t`; \
26		rm -f $$t; \
27		${LN} -s $$l $$t
28
29__LINK_SCRIPT= \
30		${ECHO} "$$t -> $$l"; \
31		mkdir -p `dirname $$t`; \
32		rm -f $$t; \
33		${LN} $$l $$t
34
35_SYMLINKS_SCRIPT= \
36	while test $$\# -ge 2; do \
37		l=$$1; shift; \
38		t=${DESTDIR}$$1; shift; \
39		${__SYMLINK_SCRIPT}; \
40	done; :;
41
42_LINKS_SCRIPT= \
43	while test $$\# -ge 2; do \
44		l=${DESTDIR}$$1; shift; \
45		t=${DESTDIR}$$1; shift; \
46		${__LINK_SCRIPT}; \
47	done; :;
48
49_SYMLINKS_USE:	.USE
50	@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_SYMLINKS_SCRIPT}
51
52_LINKS_USE:	.USE
53	@set ${$@_LINKS:U${LINKS}}; ${_LINKS_SCRIPT}
54
55
56# sometimes we want to ensure DESTDIR is ignored
57_BUILD_SYMLINKS_SCRIPT= \
58	while test $$\# -ge 2; do \
59		l=$$1; shift; \
60		t=$$1; shift; \
61		${__SYMLINK_SCRIPT}; \
62	done; :;
63
64_BUILD_LINKS_SCRIPT= \
65	while test $$\# -ge 2; do \
66		l=$$1; shift; \
67		t=$$1; shift; \
68		${__LINK_SCRIPT}; \
69	done; :;
70
71_BUILD_SYMLINKS_USE:	.USE
72	@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_BUILD_SYMLINKS_SCRIPT}
73
74_BUILD_LINKS_USE:	.USE
75	@set ${$@_LINKS:U${LINKS}}; ${_BUILD_LINKS_SCRIPT}
76