]> CyberLeo.Net >> Repos - FreeBSD/releng/10.3.git/blob - contrib/bmake/mk/links.mk
- Copy stable/10@296371 to releng/10.3 in preparation for 10.3-RC1
[FreeBSD/releng/10.3.git] / contrib / bmake / mk / links.mk
1 # $Id: links.mk,v 1.6 2014/09/29 17:14:40 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
17 LN?= ln
18 ECHO?= echo
19
20 LINKS?=
21 SYMLINKS?=
22
23 __SYMLINK_SCRIPT= \
24                 ${ECHO} "$$t -> $$l"; \
25                 case `'ls' -l $$t 2> /dev/null` in \
26                 *"> $$l") ;; \
27                 *) \
28                         mkdir -p `dirname $$t`; \
29                         rm -f $$t; \
30                         ${LN} -s $$l $$t;; \
31                 esac
32
33
34 __LINK_SCRIPT= \
35                 ${ECHO} "$$t -> $$l"; \
36                 mkdir -p `dirname $$t`; \
37                 rm -f $$t; \
38                 ${LN} $$l $$t
39
40 _SYMLINKS_SCRIPT= \
41         while test $$\# -ge 2; do \
42                 l=$$1; shift; \
43                 t=${DESTDIR}$$1; shift; \
44                 ${__SYMLINK_SCRIPT}; \
45         done; :;
46
47 _LINKS_SCRIPT= \
48         while test $$\# -ge 2; do \
49                 l=${DESTDIR}$$1; shift; \
50                 t=${DESTDIR}$$1; shift; \
51                 ${__LINK_SCRIPT}; \
52         done; :;
53
54 _SYMLINKS_USE:  .USE
55         @set ${$@_SYMLINKS:U${SYMLINKS}}; ${_SYMLINKS_SCRIPT}
56
57 _LINKS_USE:     .USE
58         @set ${$@_LINKS:U${LINKS}}; ${_LINKS_SCRIPT}
59
60
61 # sometimes we want to ensure DESTDIR is ignored
62 _BUILD_SYMLINKS_SCRIPT= \
63         while test $$\# -ge 2; do \
64                 l=$$1; shift; \
65                 t=$$1; shift; \
66                 ${__SYMLINK_SCRIPT}; \
67         done; :;
68
69 _BUILD_LINKS_SCRIPT= \
70         while test $$\# -ge 2; do \
71                 l=$$1; shift; \
72                 t=$$1; shift; \
73                 ${__LINK_SCRIPT}; \
74         done; :;
75
76 _BUILD_SYMLINKS_USE:    .USE
77         @set ${$@_SYMLINKS:U${SYMLINKS}}; ${_BUILD_SYMLINKS_SCRIPT}
78
79 _BUILD_LINKS_USE:       .USE
80         @set ${$@_LINKS:U${LINKS}}; ${_BUILD_LINKS_SCRIPT}