xref: /freebsd/include/Makefile (revision eb69d1f144a6fcc765d1b9d44a5ae8082353e70b)
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/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
259symlinks: .PHONY .META
260	@${ECHO} "Setting up symlinks to kernel source tree..."
261.for i in ${LDIRS}
262	cd ${SRCTOP}/sys/$i; \
263	for h in *.h; do \
264		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/$i/$$h ${SDESTDIR}${INCLUDEDIR}/$i; \
265	done
266.endfor
267.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/evdev:Ndev/hyperv:Ndev/nand:Ndev/pci}
268	cd ${SRCTOP}/sys/$i; \
269	for h in *.h; do \
270		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/$i/$$h ${SDESTDIR}${INCLUDEDIR}/$i; \
271	done
272.endfor
273	cd ${SRCTOP}/sys/dev/acpica; \
274	for h in acpiio.h acpi_hpet.h; do \
275		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/acpica/$$h \
276		    ${SDESTDIR}${INCLUDEDIR}/dev/acpica; \
277	done
278	cd ${SRCTOP}/sys/dev/agp; \
279	for h in agpreg.h; do \
280		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/agp/$$h \
281		    ${SDESTDIR}${INCLUDEDIR}/dev/agp; \
282	done
283	cd ${SRCTOP}/sys/dev/bktr; \
284	for h in ioctl_*.h; do \
285		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/bktr/$$h \
286		    ${SDESTDIR}${INCLUDEDIR}/dev/bktr; \
287	done
288.if ${MK_NAND} != "no"
289	cd ${SRCTOP}/sys/dev/nand; \
290	for h in nandsim.h nand_dev.h; do \
291		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/nand/$$h \
292		    ${SDESTDIR}${INCLUDEDIR}/dev/nand; \
293	done
294.endif
295	cd ${SRCTOP}/sys/dev/evdev; \
296	for h in input.h input-event-codes.h uinput.h; do \
297		ln -fs ../../../../sys/dev/evdev/$$h \
298		    ${SDESTDIR}${INCLUDEDIR}/dev/evdev; \
299	done
300	cd ${SRCTOP}/sys/dev/hyperv/include; \
301	for h in hyperv.h; do \
302		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/hyperv/include/$$h \
303		    ${SDESTDIR}${INCLUDEDIR}/dev/hyperv; \
304	done
305	cd ${SRCTOP}/sys/dev/hyperv/utilities; \
306	for h in hv_snapshot.h; do \
307		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/hyperv/utilities/$$h \
308		    ${SDESTDIR}${INCLUDEDIR}/dev/hyperv; \
309	done
310	cd ${SRCTOP}/sys/dev/pci; \
311	for h in pcireg.h; do \
312		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/pci/$$h \
313		    ${SDESTDIR}${INCLUDEDIR}/dev/pci; \
314	done
315.for i in ${LSUBSUBDIRS}
316	cd ${SRCTOP}/sys/$i; \
317	for h in *.h; do \
318		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../../sys/$i/$$h ${SDESTDIR}${INCLUDEDIR}/$i; \
319	done
320.endfor
321.if ${MK_IPFILTER} != "no"
322	cd ${SRCTOP}/sys/contrib/ipfilter/netinet; \
323	for h in *.h; do \
324		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/contrib/ipfilter/netinet/$$h \
325		    ${SDESTDIR}${INCLUDEDIR}/netinet; \
326	done
327.endif
328.if ${MK_PF} != "no"
329	cd ${SRCTOP}/sys/netpfil/pf; \
330	for h in *.h; do \
331		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/netpfil/pf/$$h \
332		    ${SDESTDIR}${INCLUDEDIR}/netpfil/pf; \
333	done
334.endif
335	cd ${SRCTOP}/sys/crypto; \
336	for h in rijndael/rijndael.h; do \
337		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/crypto/$$h \
338		    ${SDESTDIR}${INCLUDEDIR}/crypto; \
339	done
340	cd ${SRCTOP}/sys/opencrypto; \
341	for h in *.h; do \
342		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/opencrypto/$$h \
343		    ${SDESTDIR}${INCLUDEDIR}/crypto; \
344	done
345	cd ${SRCTOP}/sys/${MACHINE}/include; \
346	for h in *.h; do \
347		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/${MACHINE}/include/$$h \
348		    ${SDESTDIR}${INCLUDEDIR}/machine; \
349	done
350.if exists(${SRCTOP}/sys/${MACHINE}/include/pc)
351	cd ${SRCTOP}/sys/${MACHINE}/include/pc; \
352	for h in *.h; do \
353		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/${MACHINE}/include/pc/$$h \
354		    ${SDESTDIR}${INCLUDEDIR}/machine/pc; \
355	done
356.endif
357.for _MARCH in ${_MARCHS}
358.if exists(${SRCTOP}/sys/${_MARCH}/include)
359	${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
360	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}; \
361	cd ${SRCTOP}/sys/${_MARCH}/include; \
362	for h in *.h; do \
363		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/${_MARCH}/include/$$h \
364		    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}; \
365	done
366.if exists(${SRCTOP}/sys/${_MARCH}/include/pc)
367	${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
368	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
369	cd ${SRCTOP}/sys/${_MARCH}/include/pc; \
370	for h in *.h; do \
371		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/${_MARCH}/include/pc/$$h \
372		    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
373	done
374.endif
375.endif
376.endfor
377	cd ${SRCTOP}/sys/fs/cd9660; \
378	for h in *.h; do \
379		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/fs/cd9660/$$h \
380		    ${SDESTDIR}${INCLUDEDIR}/isofs/cd9660; \
381	done
382	cd ${SRCTOP}/sys/rpc; \
383	for h in types.h; do \
384		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/rpc/$$h \
385		    ${SDESTDIR}${INCLUDEDIR}/rpc; \
386	done
387
388.include <bsd.prog.mk>
389
390installincludes: ${SHARED}
391${SHARED}: compat
392
393.if ${MACHINE} == "host" && !defined(_SKIP_BUILD)
394# we're here because we are building a sysroot...
395# we need MACHINE et al set correctly
396HOST_MACHINE!= uname -m
397HOST_MACHINE_ARCH!= uname -p
398MACHINE:= ${HOST_MACHINE}
399MACHINE_ARCH:= ${HOST_MACHINE_ARCH}
400.endif
401