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