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