bsd.kinc.mk revision 1.14 1 # $NetBSD: bsd.kinc.mk,v 1.14 2000/06/06 05:40:47 mycroft Exp $
2
3 # System configuration variables:
4 #
5 # SYS_INCLUDE "symlinks": symlinks to include directories are created.
6 # This may not work 100% properly for all headers.
7 #
8 # "copies": directories are made, if necessary, and headers
9 # are installed into them.
10 #
11 # Variables:
12 #
13 # INCSDIR Directory to install includes into (and/or make, and/or
14 # symlink, depending on what's going on).
15 #
16 # KDIR Kernel directory to symlink to, if SYS_INCLUDE is symlinks.
17 # If unspecified, no action will be taken when making include
18 # for the directory if SYS_INCLUDE is symlinks.
19 #
20 # INCS Headers to install, if SYS_INCLUDE is copies.
21 #
22 # DEPINCS Headers to install which are built dynamically.
23 #
24 # SUBDIR Subdirectories to enter
25 #
26 # SYMLINKS Symlinks to make (unconditionally), a la bsd.links.mk.
27 # Note that the original bits will be 'rm -rf'd rather than
28 # just 'rm -f'd, to make the right thing happen with include
29 # directories.
30 #
31
32 .if !target(__initialized__)
33 __initialized__:
34 .if exists(${.CURDIR}/../Makefile.inc)
35 .include "${.CURDIR}/../Makefile.inc"
36 .endif
37 .include <bsd.own.mk>
38 .MAIN: all
39 .endif
40
41 # Change SYS_INCLUDE in bsd.own.mk or /etc/mk.conf to "symlinks" if you
42 # don't want copies
43 SYS_INCLUDE?= copies
44
45 # If DESTDIR is set, we're probably building a release, so force "copies".
46 .if defined(DESTDIR) && (${DESTDIR} != "/" && !empty(DESTDIR))
47 SYS_INCLUDE= copies
48 .endif
49
50
51 .PHONY: incinstall
52 includes: ${INCS} incinstall
53
54
55 .if ${SYS_INCLUDE} == "symlinks"
56
57 # don't install includes, just make symlinks.
58
59 .if defined(KDIR)
60 SYMLINKS+= ${KDIR} ${INCSDIR}
61 .endif
62
63 .else # not symlinks
64
65 # make sure the directory is OK, and install includes.
66
67 .PRECIOUS: ${DESTDIR}${INCSDIR}
68 .PHONY: ${DESTDIR}${INCSDIR}
69 ${DESTDIR}${INCSDIR}:
70 @if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \
71 echo creating ${.TARGET}; \
72 /bin/rm -rf ${.TARGET}; \
73 ${INSTALL} ${INSTPRIV} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
74 ${.TARGET}; \
75 fi
76
77 incinstall:: ${DESTDIR}${INCSDIR}
78
79 .if defined(INCS)
80 incinstall:: ${INCS:@I@${DESTDIR}${INCSDIR}/$I@}
81 .if !defined(UPDATE)
82 .PHONY: ${INCS:@I@${DESTDIR}${INCSDIR}/$I@}
83 .endif
84 .PRECIOUS: ${INCS:@I@${DESTDIR}${INCSDIR}/$I@}
85
86 .for I in ${INCS}
87 ${DESTDIR}${INCSDIR}/$I: ${DESTDIR}${INCSDIR} $I
88 @cmp -s ${.CURDIR}/$I ${.TARGET} > /dev/null 2>&1 || \
89 (echo "${INSTALL} ${RENAME} ${PRESERVE} ${INSTPRIV} -c \
90 -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} ${.CURDIR}/$I \
91 ${.TARGET}" && \
92 ${INSTALL} ${RENAME} ${PRESERVE} ${INSTPRIV} -c -o ${BINOWN} \
93 -g ${BINGRP} -m ${NONBINMODE} ${.CURDIR}/$I ${.TARGET})
94 .endfor
95 .endif
96
97 .if defined(DEPINCS)
98 incinstall:: ${DEPINCS:@I@${DESTDIR}${INCSDIR}/$I@}
99 .if !defined(UPDATE)
100 .PHONY: ${DEPINCS:@I@${DESTDIR}${INCSDIR}/$I@}
101 .endif
102 .PRECIOUS: ${DEPINCS:@I@${DESTDIR}${INCSDIR}/$I@}
103
104 .for I in ${DEPINCS}
105 ${DESTDIR}${INCSDIR}/$I: ${DESTDIR}${INCSDIR} $I
106 @cmp -s $I ${.TARGET} > /dev/null 2>&1 || \
107 (echo "${INSTALL} ${RENAME} ${PRESERVE} -c -o ${BINOWN} \
108 -g ${BINGRP} -m ${NONBINMODE} $I ${.TARGET}" && \
109 ${INSTALL} ${RENAME} ${PRESERVE} -c -o ${BINOWN} -g ${BINGRP} \
110 -m ${NONBINMODE} $I ${.TARGET})
111 .endfor
112 .endif
113
114 .endif # not symlinks
115
116 .if defined(SYMLINKS) && !empty(SYMLINKS)
117 incinstall::
118 @(set ${SYMLINKS}; \
119 while test $$# -ge 2; do \
120 l=$$1; \
121 shift; \
122 t=${DESTDIR}$$1; \
123 shift; \
124 if [ -L $$t ]; then \
125 cur=`ls -ld $$t | awk '{print $$NF}'` ; \
126 if [ "$$cur" = "$$l" ]; then \
127 continue ; \
128 fi; \
129 fi; \
130 echo "$$t -> $$l"; \
131 rm -rf $$t; ln -s $$l $$t; \
132 done; )
133 .endif
134
135 .if !target(incinstall)
136 incinstall::
137 .endif
138
139 .include <bsd.subdir.mk>
140