bsd.kinc.mk revision 1.19 1 # $NetBSD: bsd.kinc.mk,v 1.19 2001/11/02 05:21:50 tv 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 .include <bsd.init.mk>
33
34 ##### Basic targets
35 .PHONY: incinstall
36 includes: ${INCS} incinstall
37
38 ##### Default values
39 # Change SYS_INCLUDE in bsd.own.mk or /etc/mk.conf to "symlinks" if you
40 # don't want copies
41 SYS_INCLUDE?= copies
42
43 # If DESTDIR is set, we're probably building a release, so force "copies".
44 .if defined(DESTDIR) && (${DESTDIR} != "/" && !empty(DESTDIR))
45 SYS_INCLUDE= copies
46 .endif
47
48 ##### Install rules
49 incinstall:: # ensure existence
50
51 .if ${SYS_INCLUDE} == "symlinks"
52
53 # don't install includes, just make symlinks.
54 .if defined(KDIR)
55 SYMLINKS+= ${KDIR} ${INCSDIR}
56 .endif
57
58 .else # ${SYS_INCLUDE} != "symlinks"
59
60 # make sure the directory is OK, and install includes.
61 incinstall:: ${DESTDIR}${INCSDIR}
62 .PRECIOUS: ${DESTDIR}${INCSDIR}
63 .PHONY: ${DESTDIR}${INCSDIR}
64
65 ${DESTDIR}${INCSDIR}:
66 @if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \
67 echo creating ${.TARGET}; \
68 /bin/rm -rf ${.TARGET}; \
69 ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 ${.TARGET}; \
70 fi
71
72 # -c is forced on here, in order to preserve modtimes for "make depend"
73 __incinstall: .USE
74 @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
75 (echo "${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \
76 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}" && \
77 ${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \
78 -m ${NONBINMODE} ${.ALLSRC} ${.TARGET})
79
80 .for F in ${INCS:O:u} ${DEPINCS:O:u}
81 _F:= ${DESTDIR}${INCSDIR}/${F} # installed path
82
83 ${_F}: ${F} __incinstall # install rule
84 incinstall:: ${_F}
85 .PRECIOUS: ${_F} # keep if install fails
86 .PHONY: ${UPDATE:U${_F}} # clobber unless UPDATE
87 .endfor
88
89 .undef _F
90
91 .endif # ${SYS_INCLUDE} ?= "symlinks"
92
93 .if defined(SYMLINKS) && !empty(SYMLINKS)
94 incinstall::
95 @(set ${SYMLINKS}; \
96 while test $$# -ge 2; do \
97 l=$$1; shift; \
98 t=${DESTDIR}$$1; shift; \
99 if [ -h $$t ]; then \
100 cur=`ls -ld $$t | awk '{print $$NF}'` ; \
101 if [ "$$cur" = "$$l" ]; then \
102 continue ; \
103 fi; \
104 fi; \
105 echo "$$t -> $$l"; \
106 rm -rf $$t; ln -s $$l $$t; \
107 done; )
108 .endif
109
110 ##### Pull in related .mk logic
111 .include <bsd.subdir.mk>
112