bsd.kinc.mk revision 1.19 1 1.19 tv # $NetBSD: bsd.kinc.mk,v 1.19 2001/11/02 05:21:50 tv Exp $
2 1.1 cgd
3 1.1 cgd # System configuration variables:
4 1.1 cgd #
5 1.1 cgd # SYS_INCLUDE "symlinks": symlinks to include directories are created.
6 1.1 cgd # This may not work 100% properly for all headers.
7 1.1 cgd #
8 1.1 cgd # "copies": directories are made, if necessary, and headers
9 1.1 cgd # are installed into them.
10 1.1 cgd #
11 1.1 cgd # Variables:
12 1.1 cgd #
13 1.1 cgd # INCSDIR Directory to install includes into (and/or make, and/or
14 1.1 cgd # symlink, depending on what's going on).
15 1.1 cgd #
16 1.1 cgd # KDIR Kernel directory to symlink to, if SYS_INCLUDE is symlinks.
17 1.1 cgd # If unspecified, no action will be taken when making include
18 1.1 cgd # for the directory if SYS_INCLUDE is symlinks.
19 1.1 cgd #
20 1.1 cgd # INCS Headers to install, if SYS_INCLUDE is copies.
21 1.1 cgd #
22 1.4 castor # DEPINCS Headers to install which are built dynamically.
23 1.4 castor #
24 1.1 cgd # SUBDIR Subdirectories to enter
25 1.1 cgd #
26 1.1 cgd # SYMLINKS Symlinks to make (unconditionally), a la bsd.links.mk.
27 1.1 cgd # Note that the original bits will be 'rm -rf'd rather than
28 1.1 cgd # just 'rm -f'd, to make the right thing happen with include
29 1.1 cgd # directories.
30 1.1 cgd #
31 1.1 cgd
32 1.19 tv .include <bsd.init.mk>
33 1.19 tv
34 1.19 tv ##### Basic targets
35 1.19 tv .PHONY: incinstall
36 1.19 tv includes: ${INCS} incinstall
37 1.1 cgd
38 1.19 tv ##### Default values
39 1.1 cgd # Change SYS_INCLUDE in bsd.own.mk or /etc/mk.conf to "symlinks" if you
40 1.1 cgd # don't want copies
41 1.13 simonb SYS_INCLUDE?= copies
42 1.1 cgd
43 1.1 cgd # If DESTDIR is set, we're probably building a release, so force "copies".
44 1.1 cgd .if defined(DESTDIR) && (${DESTDIR} != "/" && !empty(DESTDIR))
45 1.13 simonb SYS_INCLUDE= copies
46 1.1 cgd .endif
47 1.1 cgd
48 1.19 tv ##### Install rules
49 1.19 tv incinstall:: # ensure existence
50 1.1 cgd
51 1.1 cgd .if ${SYS_INCLUDE} == "symlinks"
52 1.1 cgd
53 1.1 cgd # don't install includes, just make symlinks.
54 1.1 cgd .if defined(KDIR)
55 1.1 cgd SYMLINKS+= ${KDIR} ${INCSDIR}
56 1.1 cgd .endif
57 1.1 cgd
58 1.19 tv .else # ${SYS_INCLUDE} != "symlinks"
59 1.1 cgd
60 1.1 cgd # make sure the directory is OK, and install includes.
61 1.19 tv incinstall:: ${DESTDIR}${INCSDIR}
62 1.19 tv .PRECIOUS: ${DESTDIR}${INCSDIR}
63 1.19 tv .PHONY: ${DESTDIR}${INCSDIR}
64 1.15 mycroft
65 1.1 cgd ${DESTDIR}${INCSDIR}:
66 1.7 kleink @if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \
67 1.1 cgd echo creating ${.TARGET}; \
68 1.1 cgd /bin/rm -rf ${.TARGET}; \
69 1.19 tv ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 ${.TARGET}; \
70 1.1 cgd fi
71 1.1 cgd
72 1.19 tv # -c is forced on here, in order to preserve modtimes for "make depend"
73 1.16 mycroft __incinstall: .USE
74 1.16 mycroft @cmp -s ${.ALLSRC} ${.TARGET} > /dev/null 2>&1 || \
75 1.19 tv (echo "${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \
76 1.19 tv -m ${NONBINMODE} ${.ALLSRC} ${.TARGET}" && \
77 1.19 tv ${INSTALL_FILE:N-c} -c -o ${BINOWN} -g ${BINGRP} \
78 1.19 tv -m ${NONBINMODE} ${.ALLSRC} ${.TARGET})
79 1.19 tv
80 1.19 tv .for F in ${INCS:O:u} ${DEPINCS:O:u}
81 1.19 tv _F:= ${DESTDIR}${INCSDIR}/${F} # installed path
82 1.16 mycroft
83 1.19 tv ${_F}: ${F} __incinstall # install rule
84 1.19 tv incinstall:: ${_F}
85 1.19 tv .PRECIOUS: ${_F} # keep if install fails
86 1.19 tv .PHONY: ${UPDATE:U${_F}} # clobber unless UPDATE
87 1.4 castor .endfor
88 1.4 castor
89 1.19 tv .undef _F
90 1.14 mycroft
91 1.19 tv .endif # ${SYS_INCLUDE} ?= "symlinks"
92 1.1 cgd
93 1.1 cgd .if defined(SYMLINKS) && !empty(SYMLINKS)
94 1.1 cgd incinstall::
95 1.10 drochner @(set ${SYMLINKS}; \
96 1.1 cgd while test $$# -ge 2; do \
97 1.19 tv l=$$1; shift; \
98 1.19 tv t=${DESTDIR}$$1; shift; \
99 1.17 cgd if [ -h $$t ]; then \
100 1.12 simonb cur=`ls -ld $$t | awk '{print $$NF}'` ; \
101 1.12 simonb if [ "$$cur" = "$$l" ]; then \
102 1.12 simonb continue ; \
103 1.12 simonb fi; \
104 1.12 simonb fi; \
105 1.12 simonb echo "$$t -> $$l"; \
106 1.12 simonb rm -rf $$t; ln -s $$l $$t; \
107 1.12 simonb done; )
108 1.1 cgd .endif
109 1.1 cgd
110 1.19 tv ##### Pull in related .mk logic
111 1.1 cgd .include <bsd.subdir.mk>
112