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 gssapi 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 gssapi.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_HESIOD} != "no"
72INCS+=	hesiod.h
73.endif
74
75.if ${MK_BLUETOOTH} != "no"
76LSUBSUBDIRS+=	netgraph/bluetooth/include
77.endif
78
79# XXX unconditionally needed by <netsmb/netbios.h>
80#.if ${MK_IPX} != "no"
81_netipx=	netipx
82#.endif
83
84# Handle the #define aliases for libiconv
85.if ${MK_ICONV} == "yes"
86INCS+=		iconv.h
87.endif
88	
89
90# Define SHARED to indicate whether you want symbolic links to the system
91# source (``symlinks''), or a separate copy (``copies'').  ``symlinks'' is
92# probably only useful for developers and should be avoided if you do not
93# wish to tie your /usr/include and /usr/src together.
94#SHARED=	symlinks
95SHARED?=	copies
96
97INCS+=	osreldate.h
98
99SYSDIR=			${.CURDIR}/../sys
100NEWVERS_SH=		${SYSDIR}/conf/newvers.sh
101PARAM_H=		${SYSDIR}/sys/param.h
102MK_OSRELDATE_SH=	${.CURDIR}/mk-osreldate.sh
103
104osreldate.h vers.c: ${NEWVERS_SH} ${PARAM_H} ${MK_OSRELDATE_SH}
105	env ECHO="${ECHO}" \
106	    MAKE="${MAKE}" \
107	    NEWVERS_SH=${NEWVERS_SH} \
108	    PARAM_H=${PARAM_H} \
109	    SYSDIR=${SYSDIR} \
110	    sh ${MK_OSRELDATE_SH}
111
112.for i in ${LHDRS}
113INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
114.endfor
115.for i in ${MHDRS}
116INCSLINKS+=	machine/$i ${INCLUDEDIR}/$i
117.endfor
118.for i in ${PHDRS}
119INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
120.endfor
121
122.if ${MACHINE} != ${MACHINE_CPUARCH}
123_MARCHS=	${MACHINE_CPUARCH}
124.endif
125.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
126_MARCHS+=	x86
127.endif
128
129.include <bsd.prog.mk>
130
131installincludes: ${SHARED}
132${SHARED}: compat
133
134# Take care of stale directory-level symlinks.
135compat:
136.for i in ${LDIRS} ${LSUBDIRS} machine ${_MARCHS} crypto
137	if [ -L ${DESTDIR}${INCLUDEDIR}/$i ]; then \
138		rm -f ${DESTDIR}${INCLUDEDIR}/$i; \
139	fi
140.endfor
141	mtree -deU ${MTREE_FOLLOWS_SYMLINKS} \
142	    -f ${.CURDIR}/../etc/mtree/BSD.include.dist \
143	    -p ${DESTDIR}${INCLUDEDIR}
144
145copies:
146.for i in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} altq crypto machine machine/pc \
147	${_MARCHS}
148.if exists(${DESTDIR}${INCLUDEDIR}/$i)
149	cd ${DESTDIR}${INCLUDEDIR}/$i; \
150	for h in *.h; do \
151		if [ -L $$h ]; then rm -f $$h; fi; \
152	done
153.endif
154.endfor
155.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci} ${LSUBSUBDIRS}
156	cd ${.CURDIR}/../sys; \
157	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
158	    ${DESTDIR}${INCLUDEDIR}/$i
159.endfor
160	cd ${.CURDIR}/../sys/dev/acpica; \
161	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \
162	    ${DESTDIR}${INCLUDEDIR}/dev/acpica
163	cd ${.CURDIR}/../sys/dev/agp; \
164	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 agpreg.h \
165	    ${DESTDIR}${INCLUDEDIR}/dev/agp
166	cd ${.CURDIR}/../sys/dev/bktr; \
167	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \
168	    ${DESTDIR}${INCLUDEDIR}/dev/bktr
169.if ${MK_NAND} != "no"
170	cd ${.CURDIR}/../sys/dev/nand; \
171	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nandsim.h \
172	    ${DESTDIR}${INCLUDEDIR}/dev/nand; \
173	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \
174	    ${DESTDIR}${INCLUDEDIR}/dev/nand
175.endif
176	cd ${.CURDIR}/../sys/dev/pci; \
177	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \
178	    ${DESTDIR}${INCLUDEDIR}/dev/pci
179	cd ${.CURDIR}/../sys/contrib/altq/altq; \
180	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
181	    ${DESTDIR}${INCLUDEDIR}/altq
182	cd ${.CURDIR}/../sys/fs/cd9660/; \
183	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
184	    ${DESTDIR}${INCLUDEDIR}/isofs/cd9660
185.if ${MK_IPFILTER} != "no"
186	cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
187	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
188	    ${DESTDIR}${INCLUDEDIR}/netinet
189.endif
190	cd ${.CURDIR}/../sys/crypto; \
191	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 rijndael/rijndael.h \
192	    ${DESTDIR}${INCLUDEDIR}/crypto
193	cd ${.CURDIR}/../sys/opencrypto; \
194	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
195	    ${DESTDIR}${INCLUDEDIR}/crypto
196	cd ${.CURDIR}/../sys/${MACHINE}/include; \
197	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
198	    ${DESTDIR}${INCLUDEDIR}/machine
199.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
200	cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
201	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
202	    ${DESTDIR}${INCLUDEDIR}/machine/pc
203.endif
204.for _MARCH in ${_MARCHS}
205.if exists(${.CURDIR}/../sys/${_MARCH}/include)
206	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
207	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
208	cd ${.CURDIR}/../sys/${_MARCH}/include; \
209	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
210	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}
211.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
212	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
213	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
214	cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
215	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
216	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc
217.endif
218.endif
219.endfor
220	cd ${.CURDIR}/../sys/rpc; \
221	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 types.h \
222	    ${DESTDIR}${INCLUDEDIR}/rpc
223
224symlinks:
225	@${ECHO} "Setting up symlinks to kernel source tree..."
226.for i in ${LDIRS}
227	cd ${.CURDIR}/../sys/$i; \
228	for h in *.h; do \
229		ln -fs ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
230	done
231.endfor
232.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/nand:Ndev/pci}
233	cd ${.CURDIR}/../sys/$i; \
234	for h in *.h; do \
235		ln -fs ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
236	done
237.endfor
238	cd ${.CURDIR}/../sys/dev/acpica; \
239	for h in acpiio.h; do \
240		ln -fs ../../../../sys/dev/acpica/$$h \
241		    ${DESTDIR}${INCLUDEDIR}/dev/acpica; \
242	done
243	cd ${.CURDIR}/../sys/dev/agp; \
244	for h in agpreg.h; do \
245		ln -fs ../../../../sys/dev/agp/$$h \
246		    ${DESTDIR}${INCLUDEDIR}/dev/agp; \
247	done
248	cd ${.CURDIR}/../sys/dev/bktr; \
249	for h in ioctl_*.h; do \
250		ln -fs ../../../../sys/dev/bktr/$$h \
251		    ${DESTDIR}${INCLUDEDIR}/dev/bktr; \
252	done
253.if ${MK_NAND} != "no"
254	cd ${.CURDIR}/../sys/dev/nand; \
255	for h in nandsim.h nand_dev.h; do \
256		ln -fs ../../../../sys/dev/nand/$$h \
257		    ${DESTDIR}${INCLUDEDIR}/dev/nand; \
258	done
259.endif
260	cd ${.CURDIR}/../sys/dev/pci; \
261	for h in pcireg.h; do \
262		ln -fs ../../../../sys/dev/pci/$$h \
263		    ${DESTDIR}${INCLUDEDIR}/dev/pci; \
264	done
265.for i in ${LSUBSUBDIRS}
266	cd ${.CURDIR}/../sys/$i; \
267	for h in *.h; do \
268		ln -fs ../../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
269	done
270.endfor
271	cd ${.CURDIR}/../sys/contrib/altq/altq; \
272	for h in *.h; do \
273		ln -fs ../../../sys/contrib/altq/altq/$$h \
274		    ${DESTDIR}${INCLUDEDIR}/altq; \
275	done
276.if ${MK_IPFILTER} != "no"
277	cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
278	for h in *.h; do \
279		ln -fs ../../../sys/contrib/ipfilter/netinet/$$h \
280		    ${DESTDIR}${INCLUDEDIR}/netinet; \
281	done
282.endif
283	cd ${.CURDIR}/../sys/crypto; \
284	for h in rijndael/rijndael.h; do \
285		ln -fs ../../../sys/crypto/$$h \
286		    ${DESTDIR}${INCLUDEDIR}/crypto; \
287	done
288	cd ${.CURDIR}/../sys/opencrypto; \
289	for h in *.h; do \
290		ln -fs ../../../sys/opencrypto/$$h \
291		    ${DESTDIR}${INCLUDEDIR}/crypto; \
292	done
293	cd ${.CURDIR}/../sys/${MACHINE}/include; \
294	for h in *.h; do \
295		ln -fs ../../../sys/${MACHINE}/include/$$h \
296		    ${DESTDIR}${INCLUDEDIR}/machine; \
297	done
298.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
299	cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
300	for h in *.h; do \
301		ln -fs ../../../../sys/${MACHINE}/include/pc/$$h \
302		    ${DESTDIR}${INCLUDEDIR}/machine/pc; \
303	done
304.endif
305.for _MARCH in ${_MARCHS}
306.if exists(${.CURDIR}/../sys/${_MARCH}/include)
307	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
308	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
309	cd ${.CURDIR}/../sys/${_MARCH}/include; \
310	for h in *.h; do \
311		ln -fs ../../../sys/${_MARCH}/include/$$h \
312		    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
313	done
314.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
315	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
316	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
317	cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
318	for h in *.h; do \
319		ln -fs ../../../../sys/${_MARCH}/include/pc/$$h \
320		    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
321	done
322.endif
323.endif
324.endfor
325	cd ${.CURDIR}/../sys/fs/cd9660; \
326	for h in *.h; do \
327		ln -fs ../../../../sys/fs/cd9660/$$h \
328		    ${DESTDIR}${INCLUDEDIR}/isofs/cd9660; \
329	done
330	cd ${.CURDIR}/../sys/rpc; \
331	for h in types.h; do \
332		ln -fs ../../../sys/rpc/$$h \
333		    ${DESTDIR}${INCLUDEDIR}/rpc; \
334	done
335