1#	@(#)Makefile	8.2 (Berkeley) 1/4/94
2# $FreeBSD$
3#
4# Doing a "make install" builds /usr/include.
5
6.include <bsd.own.mk>
7
8CLEANFILES= osreldate.h version vers.c
9SUBDIR= arpa protocols rpcsvc rpc xlocale
10INCS=	a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
11	db.h \
12	dirent.h dlfcn.h elf.h elf-hints.h err.h fmtmsg.h fnmatch.h fstab.h \
13	fts.h ftw.h getopt.h glob.h grp.h \
14	ieeefp.h ifaddrs.h \
15	inttypes.h iso646.h kenv.h langinfo.h libgen.h limits.h link.h \
16	locale.h malloc.h malloc_np.h memory.h monetary.h mpool.h mqueue.h \
17	ndbm.h netconfig.h \
18	netdb.h nl_types.h nlist.h nss.h nsswitch.h paths.h \
19	printf.h proc_service.h pthread.h \
20	pthread_np.h pwd.h ranlib.h readpassphrase.h regex.h \
21	res_update.h resolv.h runetype.h search.h semaphore.h setjmp.h \
22	signal.h spawn.h stab.h stdalign.h stdbool.h stddef.h \
23	stdnoreturn.h stdio.h stdlib.h string.h stringlist.h \
24	strings.h sysexits.h tar.h termios.h tgmath.h \
25	time.h timeconv.h timers.h ttyent.h \
26	uchar.h ulimit.h unistd.h utime.h utmpx.h uuid.h varargs.h \
27	wchar.h wctype.h wordexp.h xlocale.h
28
29.PATH: ${.CURDIR}/../contrib/libc-vis
30INCS+=	vis.h
31
32MHDRS=	float.h floatingpoint.h stdarg.h
33
34PHDRS=	sched.h _semaphore.h
35
36LHDRS=	aio.h errno.h fcntl.h linker_set.h poll.h stdatomic.h stdint.h \
37	syslog.h ucontext.h
38
39LDIRS=	bsm cam geom net net80211 netatalk netgraph netinet netinet6 \
40	netipsec ${_netipx} netnatm netsmb \
41	nfs nfsclient nfsserver \
42	sys vm
43
44LSUBDIRS=	cam/ata cam/scsi \
45	dev/acpica dev/agp dev/an dev/bktr dev/ciss dev/filemon dev/firewire \
46	dev/hwpmc \
47	dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/nvme \
48	dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/smbus \
49	dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \
50	fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
51	fs/procfs fs/smbfs fs/udf fs/unionfs \
52	geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
53	geom/mirror geom/mountver geom/multipath geom/nop \
54	geom/raid geom/raid3 geom/shsec geom/stripe geom/virstor \
55	netgraph/atm netgraph/netflow \
56	security/audit \
57	security/mac_biba security/mac_bsdextended security/mac_lomac \
58	security/mac_mls security/mac_partition \
59	ufs/ffs ufs/ufs
60
61LSUBSUBDIRS=	dev/mpt/mpilib
62
63.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64"
64_dev_powermac_nvram=	dev/powermac_nvram
65.endif
66
67.if ${MK_GPIB} != "no"
68_dev_ieee488=	dev/ieee488
69.endif
70
71.if ${MK_GSSAPI} != "no"
72SUBDIR+=	gssapi
73INCS+=		gssapi.h
74.endif
75
76.if ${MK_HESIOD} != "no"
77INCS+=	hesiod.h
78.endif
79
80.if ${MK_BLUETOOTH} != "no"
81LSUBSUBDIRS+=	netgraph/bluetooth/include
82.endif
83
84# XXX unconditionally needed by <netsmb/netbios.h>
85#.if ${MK_IPX} != "no"
86_netipx=	netipx
87#.endif
88
89# Handle the #define aliases for libiconv
90.if ${MK_ICONV} == "yes"
91INCS+=		iconv.h
92.endif
93	
94
95# Define SHARED to indicate whether you want symbolic links to the system
96# source (``symlinks''), or a separate copy (``copies'').  ``symlinks'' is
97# probably only useful for developers and should be avoided if you do not
98# wish to tie your /usr/include and /usr/src together.
99#SHARED=	symlinks
100SHARED?=	copies
101
102INCS+=	osreldate.h
103
104SYSDIR=			${.CURDIR}/../sys
105NEWVERS_SH=		${SYSDIR}/conf/newvers.sh
106PARAM_H=		${SYSDIR}/sys/param.h
107MK_OSRELDATE_SH=	${.CURDIR}/mk-osreldate.sh
108
109osreldate.h vers.c: ${NEWVERS_SH} ${PARAM_H} ${MK_OSRELDATE_SH}
110	env ECHO="${ECHO}" \
111	    MAKE="${MAKE}" \
112	    NEWVERS_SH=${NEWVERS_SH} \
113	    PARAM_H=${PARAM_H} \
114	    SYSDIR=${SYSDIR} \
115	    sh ${MK_OSRELDATE_SH}
116
117.for i in ${LHDRS}
118INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
119.endfor
120.for i in ${MHDRS}
121INCSLINKS+=	machine/$i ${INCLUDEDIR}/$i
122.endfor
123.for i in ${PHDRS}
124INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
125.endfor
126
127.if ${MACHINE} != ${MACHINE_CPUARCH}
128_MARCHS=	${MACHINE_CPUARCH}
129.endif
130.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
131_MARCHS+=	x86
132.endif
133
134.include <bsd.prog.mk>
135
136installincludes: ${SHARED}
137${SHARED}: compat
138
139# Take care of stale directory-level symlinks.
140compat:
141.for i in ${LDIRS} ${LSUBDIRS} machine ${_MARCHS} crypto
142	if [ -L ${DESTDIR}${INCLUDEDIR}/$i ]; then \
143		rm -f ${DESTDIR}${INCLUDEDIR}/$i; \
144	fi
145.endfor
146	mtree -deU ${MTREE_FOLLOWS_SYMLINKS} \
147	    -f ${.CURDIR}/../etc/mtree/BSD.include.dist \
148	    -p ${DESTDIR}${INCLUDEDIR}
149
150copies:
151.for i in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} altq crypto machine machine/pc \
152	${_MARCHS}
153.if exists(${DESTDIR}${INCLUDEDIR}/$i)
154	cd ${DESTDIR}${INCLUDEDIR}/$i; \
155	for h in *.h; do \
156		if [ -L $$h ]; then rm -f $$h; fi; \
157	done
158.endif
159.endfor
160.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS}
161	cd ${.CURDIR}/../sys; \
162	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
163	    ${DESTDIR}${INCLUDEDIR}/$i
164.endfor
165	cd ${.CURDIR}/../sys/dev/acpica; \
166	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \
167	    ${DESTDIR}${INCLUDEDIR}/dev/acpica
168	cd ${.CURDIR}/../sys/dev/agp; \
169	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 agpreg.h \
170	    ${DESTDIR}${INCLUDEDIR}/dev/agp
171	cd ${.CURDIR}/../sys/dev/bktr; \
172	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \
173	    ${DESTDIR}${INCLUDEDIR}/dev/bktr
174.if ${MK_NAND} != "no"
175	cd ${.CURDIR}/../sys/dev/nand; \
176	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nandsim.h \
177	    ${DESTDIR}${INCLUDEDIR}/dev/nand; \
178	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \
179	    ${DESTDIR}${INCLUDEDIR}/dev/nand
180.endif
181	cd ${.CURDIR}/../sys/dev/pci; \
182	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \
183	    ${DESTDIR}${INCLUDEDIR}/dev/pci
184	cd ${.CURDIR}/../sys/contrib/altq/altq; \
185	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
186	    ${DESTDIR}${INCLUDEDIR}/altq
187	cd ${.CURDIR}/../sys/fs/cd9660/; \
188	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
189	    ${DESTDIR}${INCLUDEDIR}/isofs/cd9660
190.if ${MK_IPFILTER} != "no"
191	cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
192	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
193	    ${DESTDIR}${INCLUDEDIR}/netinet
194.endif
195.if ${MK_PF} != "no"
196	cd ${.CURDIR}/../sys/netpfil/pf; \
197	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
198	    ${DESTDIR}${INCLUDEDIR}/netpfil/pf
199.endif
200	cd ${.CURDIR}/../sys/crypto; \
201	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 rijndael/rijndael.h \
202	    ${DESTDIR}${INCLUDEDIR}/crypto
203	cd ${.CURDIR}/../sys/opencrypto; \
204	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
205	    ${DESTDIR}${INCLUDEDIR}/crypto
206	cd ${.CURDIR}/../sys/${MACHINE}/include; \
207	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
208	    ${DESTDIR}${INCLUDEDIR}/machine
209.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
210	cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
211	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
212	    ${DESTDIR}${INCLUDEDIR}/machine/pc
213.endif
214.for _MARCH in ${_MARCHS}
215.if exists(${.CURDIR}/../sys/${_MARCH}/include)
216	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
217	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
218	cd ${.CURDIR}/../sys/${_MARCH}/include; \
219	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
220	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}
221.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
222	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
223	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
224	cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
225	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
226	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc
227.endif
228.endif
229.endfor
230	cd ${.CURDIR}/../sys/rpc; \
231	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 types.h \
232	    ${DESTDIR}${INCLUDEDIR}/rpc
233
234symlinks:
235	@${ECHO} "Setting up symlinks to kernel source tree..."
236.for i in ${LDIRS}
237	cd ${.CURDIR}/../sys/$i; \
238	for h in *.h; do \
239		ln -fs ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
240	done
241.endfor
242.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci}
243	cd ${.CURDIR}/../sys/$i; \
244	for h in *.h; do \
245		ln -fs ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
246	done
247.endfor
248	cd ${.CURDIR}/../sys/dev/acpica; \
249	for h in acpiio.h; do \
250		ln -fs ../../../../sys/dev/acpica/$$h \
251		    ${DESTDIR}${INCLUDEDIR}/dev/acpica; \
252	done
253	cd ${.CURDIR}/../sys/dev/agp; \
254	for h in agpreg.h; do \
255		ln -fs ../../../../sys/dev/agp/$$h \
256		    ${DESTDIR}${INCLUDEDIR}/dev/agp; \
257	done
258	cd ${.CURDIR}/../sys/dev/bktr; \
259	for h in ioctl_*.h; do \
260		ln -fs ../../../../sys/dev/bktr/$$h \
261		    ${DESTDIR}${INCLUDEDIR}/dev/bktr; \
262	done
263.if ${MK_NAND} != "no"
264	cd ${.CURDIR}/../sys/dev/nand; \
265	for h in nandsim.h nand_dev.h; do \
266		ln -fs ../../../../sys/dev/nand/$$h \
267		    ${DESTDIR}${INCLUDEDIR}/dev/nand; \
268	done
269.endif
270	cd ${.CURDIR}/../sys/dev/pci; \
271	for h in pcireg.h; do \
272		ln -fs ../../../../sys/dev/pci/$$h \
273		    ${DESTDIR}${INCLUDEDIR}/dev/pci; \
274	done
275.for i in ${LSUBSUBDIRS}
276	cd ${.CURDIR}/../sys/$i; \
277	for h in *.h; do \
278		ln -fs ../../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
279	done
280.endfor
281	cd ${.CURDIR}/../sys/contrib/altq/altq; \
282	for h in *.h; do \
283		ln -fs ../../../sys/contrib/altq/altq/$$h \
284		    ${DESTDIR}${INCLUDEDIR}/altq; \
285	done
286.if ${MK_IPFILTER} != "no"
287	cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
288	for h in *.h; do \
289		ln -fs ../../../sys/contrib/ipfilter/netinet/$$h \
290		    ${DESTDIR}${INCLUDEDIR}/netinet; \
291	done
292.endif
293.if ${MK_PF} != "no"
294	cd ${.CURDIR}/../sys/netpfil/pf; \
295	for h in *.h; do \
296		ln -fs ../../../../sys/netpfil/pf/$$h \
297		    ${DESTDIR}${INCLUDEDIR}/netpfil/pf; \
298	done
299.endif
300	cd ${.CURDIR}/../sys/crypto; \
301	for h in rijndael/rijndael.h; do \
302		ln -fs ../../../sys/crypto/$$h \
303		    ${DESTDIR}${INCLUDEDIR}/crypto; \
304	done
305	cd ${.CURDIR}/../sys/opencrypto; \
306	for h in *.h; do \
307		ln -fs ../../../sys/opencrypto/$$h \
308		    ${DESTDIR}${INCLUDEDIR}/crypto; \
309	done
310	cd ${.CURDIR}/../sys/${MACHINE}/include; \
311	for h in *.h; do \
312		ln -fs ../../../sys/${MACHINE}/include/$$h \
313		    ${DESTDIR}${INCLUDEDIR}/machine; \
314	done
315.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
316	cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
317	for h in *.h; do \
318		ln -fs ../../../../sys/${MACHINE}/include/pc/$$h \
319		    ${DESTDIR}${INCLUDEDIR}/machine/pc; \
320	done
321.endif
322.for _MARCH in ${_MARCHS}
323.if exists(${.CURDIR}/../sys/${_MARCH}/include)
324	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
325	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
326	cd ${.CURDIR}/../sys/${_MARCH}/include; \
327	for h in *.h; do \
328		ln -fs ../../../sys/${_MARCH}/include/$$h \
329		    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
330	done
331.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
332	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
333	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
334	cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
335	for h in *.h; do \
336		ln -fs ../../../../sys/${_MARCH}/include/pc/$$h \
337		    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
338	done
339.endif
340.endif
341.endfor
342	cd ${.CURDIR}/../sys/fs/cd9660; \
343	for h in *.h; do \
344		ln -fs ../../../../sys/fs/cd9660/$$h \
345		    ${DESTDIR}${INCLUDEDIR}/isofs/cd9660; \
346	done
347	cd ${.CURDIR}/../sys/rpc; \
348	for h in types.h; do \
349		ln -fs ../../../sys/rpc/$$h \
350		    ${DESTDIR}${INCLUDEDIR}/rpc; \
351	done
352