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