summaryrefslogtreecommitdiff
path: root/devel/bmake/files/mk/links.mk
blob: c776295ce7a789d18c2dcc22f7edd8c2256a12ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# $Id: links.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $
#
#	@(#) Copyright (c) 2005, Simon J. Gerraty
#
#	This file is provided in the hope that it will
#	be of use.  There is absolutely NO WARRANTY.
#	Permission to copy, redistribute or otherwise
#	use this file is hereby granted provided that 
#	the above copyright notice and this notice are
#	left intact. 
#      
#	Please send copies of changes and bug-fixes to:
#	sjg@crufty.net
#

# some platforms need something special
LN?= ln
ECHO?= echo

LINKS?=
SYMLINKS?=

__SYMLINK_SCRIPT= \
		${ECHO} "$$t -> $$l"; \
		case `'ls' -l $$t 2> /dev/null` in \
		*"> $$l") ;; \
		*) \
			mkdir -p `dirname $$t`; \
			rm -f $$t; \
			${LN} -s $$l $$t;; \
		esac


__LINK_SCRIPT= \
		${ECHO} "$$t -> $$l"; \
		mkdir -p `dirname $$t`; \
		rm -f $$t; \
		${LN} $$l $$t

_SYMLINKS_SCRIPT= \
	while test $$\# -ge 2; do \
		l=$$1; shift; \
		t=${DESTDIR}$$1; shift; \
		${__SYMLINK_SCRIPT}; \
	done; :;

_LINKS_SCRIPT= \
	while test $$\# -ge 2; do \
		l=${DESTDIR}$$1; shift; \
		t=${DESTDIR}$$1; shift; \
		${__LINK_SCRIPT}; \
	done; :;

_SYMLINKS_USE:	.USE
	@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_SYMLINKS_SCRIPT}

_LINKS_USE:	.USE
	@set ${$@_LINKS:U${LINKS}}; ${_LINKS_SCRIPT}


# sometimes we want to ensure DESTDIR is ignored
_BUILD_SYMLINKS_SCRIPT= \
	while test $$\# -ge 2; do \
		l=$$1; shift; \
		t=$$1; shift; \
		${__SYMLINK_SCRIPT}; \
	done; :;

_BUILD_LINKS_SCRIPT= \
	while test $$\# -ge 2; do \
		l=$$1; shift; \
		t=$$1; shift; \
		${__LINK_SCRIPT}; \
	done; :;

_BUILD_SYMLINKS_USE:	.USE
	@set ${$@_SYMLINKS:U${SYMLINKS}}; ${_BUILD_SYMLINKS_SCRIPT}

_BUILD_LINKS_USE:	.USE
	@set ${$@_LINKS:U${LINKS}}; ${_BUILD_LINKS_SCRIPT}