bsd.kinc.mk revision 1.7 1 1.7 kleink # $NetBSD: bsd.kinc.mk,v 1.7 1999/08/22 14:02:34 kleink 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.1 cgd .if !target(__initialized__)
33 1.1 cgd __initialized__:
34 1.1 cgd .if exists(${.CURDIR}/../Makefile.inc)
35 1.1 cgd .include "${.CURDIR}/../Makefile.inc"
36 1.1 cgd .endif
37 1.1 cgd .include <bsd.own.mk>
38 1.1 cgd .MAIN: all
39 1.1 cgd .endif
40 1.1 cgd
41 1.1 cgd # Change SYS_INCLUDE in bsd.own.mk or /etc/mk.conf to "symlinks" if you
42 1.1 cgd # don't want copies
43 1.1 cgd SYS_INCLUDE?= copies
44 1.1 cgd
45 1.1 cgd # If DESTDIR is set, we're probably building a release, so force "copies".
46 1.1 cgd .if defined(DESTDIR) && (${DESTDIR} != "/" && !empty(DESTDIR))
47 1.1 cgd SYS_INCLUDE= copies
48 1.1 cgd .endif
49 1.1 cgd
50 1.1 cgd
51 1.1 cgd .PHONY: incinstall
52 1.1 cgd includes: ${INCS} incinstall
53 1.1 cgd
54 1.1 cgd
55 1.1 cgd .if ${SYS_INCLUDE} == "symlinks"
56 1.1 cgd
57 1.1 cgd # don't install includes, just make symlinks.
58 1.1 cgd
59 1.1 cgd .if defined(KDIR)
60 1.1 cgd SYMLINKS+= ${KDIR} ${INCSDIR}
61 1.1 cgd .endif
62 1.1 cgd
63 1.1 cgd .else # not symlinks
64 1.1 cgd
65 1.1 cgd # make sure the directory is OK, and install includes.
66 1.1 cgd
67 1.1 cgd .PRECIOUS: ${DESTDIR}${INCSDIR}
68 1.1 cgd .PHONY: ${DESTDIR}${INCSDIR}
69 1.1 cgd ${DESTDIR}${INCSDIR}:
70 1.7 kleink @if [ ! -d ${.TARGET} ] || [ -h ${.TARGET} ] ; then \
71 1.1 cgd echo creating ${.TARGET}; \
72 1.1 cgd /bin/rm -rf ${.TARGET}; \
73 1.6 simonb ${INSTALL} ${INSTPRIV} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
74 1.6 simonb ${.TARGET}; \
75 1.1 cgd fi
76 1.1 cgd
77 1.1 cgd incinstall:: ${DESTDIR}${INCSDIR}
78 1.1 cgd
79 1.1 cgd .if defined(INCS)
80 1.1 cgd .for I in ${INCS}
81 1.4 castor incinstall:: ${DESTDIR}${INCSDIR}/$I
82 1.4 castor
83 1.4 castor .PRECIOUS: ${DESTDIR}${INCSDIR}/$I
84 1.4 castor .if !defined(UPDATE)
85 1.4 castor .PHONY: ${DESTDIR}${INCSDIR}/$I
86 1.4 castor .endif
87 1.4 castor ${DESTDIR}${INCSDIR}/$I: ${DESTDIR}${INCSDIR} $I
88 1.4 castor @cmp -s ${.CURDIR}/$I ${.TARGET} > /dev/null 2>&1 || \
89 1.6 simonb (echo "${INSTALL} ${RENAME} ${PRESERVE} ${INSTPRIV} -c \
90 1.6 simonb -o ${BINOWN} -g ${BINGRP} -m ${NONBINMODE} ${.CURDIR}/$I \
91 1.6 simonb ${.TARGET}" && \
92 1.6 simonb ${INSTALL} ${RENAME} ${PRESERVE} ${INSTPRIV} -c -o ${BINOWN} \
93 1.6 simonb -g ${BINGRP} -m ${NONBINMODE} ${.CURDIR}/$I ${.TARGET})
94 1.4 castor .endfor
95 1.4 castor .endif
96 1.4 castor
97 1.4 castor .if defined(DEPINCS)
98 1.4 castor .for I in ${DEPINCS}
99 1.1 cgd incinstall:: ${DESTDIR}${INCSDIR}/$I
100 1.1 cgd
101 1.1 cgd .PRECIOUS: ${DESTDIR}${INCSDIR}/$I
102 1.1 cgd .if !defined(UPDATE)
103 1.1 cgd .PHONY: ${DESTDIR}${INCSDIR}/$I
104 1.1 cgd .endif
105 1.1 cgd ${DESTDIR}${INCSDIR}/$I: ${DESTDIR}${INCSDIR} $I
106 1.1 cgd @cmp -s $I ${.TARGET} > /dev/null 2>&1 || \
107 1.5 christos (echo "${INSTALL} ${RENAME} ${PRESERVE} -c -o ${BINOWN} \
108 1.5 christos -g ${BINGRP} -m ${NONBINMODE} $I ${.TARGET}" && \
109 1.5 christos ${INSTALL} ${RENAME} ${PRESERVE} -c -o ${BINOWN} -g ${BINGRP} \
110 1.2 christos -m ${NONBINMODE} $I ${.TARGET})
111 1.1 cgd .endfor
112 1.1 cgd .endif
113 1.1 cgd
114 1.1 cgd .endif # not symlinks
115 1.1 cgd
116 1.1 cgd .if defined(SYMLINKS) && !empty(SYMLINKS)
117 1.1 cgd incinstall::
118 1.1 cgd @set ${SYMLINKS}; \
119 1.1 cgd while test $$# -ge 2; do \
120 1.1 cgd l=$$1; \
121 1.1 cgd shift; \
122 1.1 cgd t=${DESTDIR}$$1; \
123 1.1 cgd shift; \
124 1.1 cgd echo ".include <bsd.own.mk>"; \
125 1.1 cgd echo "all:: $$t"; \
126 1.1 cgd echo ".PHONY: $$t"; \
127 1.1 cgd echo "$$t:"; \
128 1.1 cgd echo " @echo \"$$t -> $$l\""; \
129 1.1 cgd echo " @rm -rf $$t"; \
130 1.1 cgd echo " @ln -s $$l $$t"; \
131 1.3 castor done | ${MAKE} -f-
132 1.1 cgd .endif
133 1.1 cgd
134 1.1 cgd .if !target(incinstall)
135 1.1 cgd incinstall::
136 1.1 cgd .endif
137 1.1 cgd
138 1.1 cgd .include <bsd.subdir.mk>
139