xref: /freebsd/include/Makefile (revision f976241773df2260e6170317080761d1c5814fe5)
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/mfi dev/mmc dev/nvme \
49	dev/ofw dev/pbio dev/pci ${_dev_powermac_nvram} dev/ppbus dev/pwm \
50	dev/smbus dev/speaker dev/tcp_log dev/veriexec dev/vkbd dev/wi \
51	fs/devfs fs/fdescfs fs/msdosfs 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	netinet/netdump \
60	security/audit \
61	security/mac_biba security/mac_bsdextended security/mac_lomac \
62	security/mac_mls security/mac_partition \
63	security/mac_veriexec \
64	sys/disk \
65	ufs/ffs ufs/ufs
66
67LSUBSUBDIRS=	dev/mpt/mpilib
68
69.if ${MK_BLUETOOTH} != "no"
70LSUBSUBDIRS+=	netgraph/bluetooth/include
71.endif
72
73.if ${MK_CUSE} != "no"
74LSUBDIRS+=	fs/cuse
75.endif
76
77.if ${MK_GSSAPI} != "no"
78SUBDIR+=	gssapi
79INCS+=		gssapi.h
80.endif
81
82.if ${MK_HESIOD} != "no"
83INCS+=	hesiod.h
84.endif
85
86# Handle the #define aliases for libiconv
87.if ${MK_ICONV} == "yes"
88INCS+=		iconv.h
89.endif
90
91.if ${MK_USB} != "no"
92LSUBDIRS+=	dev/usb
93.endif
94
95.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64"
96_dev_powermac_nvram=	dev/powermac_nvram
97.endif
98
99# Define SHARED to indicate whether you want symbolic links to the system
100# source (``symlinks''), or a separate copy (``copies'').  ``symlinks'' is
101# probably only useful for developers and should be avoided if you do not
102# wish to tie your /usr/include and /usr/src together.
103#SHARED=	symlinks
104SHARED?=	copies
105
106INCS+=	osreldate.h
107
108SYSDIR=			${SRCTOP}/sys
109NEWVERS_SH=		${SYSDIR}/conf/newvers.sh
110PARAM_H=		${SYSDIR}/sys/param.h
111MK_OSRELDATE_SH=	${.CURDIR}/mk-osreldate.sh
112
113SYMLINKS+= ${LIBDIR:C,[^/]+,..,g:C,^/,,}${INCLUDEDIR} ${LIBDIR}/include
114
115osreldate.h: ${NEWVERS_SH} ${PARAM_H} ${MK_OSRELDATE_SH}
116	env NEWVERS_SH=${NEWVERS_SH} PARAMFILE=${PARAM_H} SYSDIR=${SYSDIR} \
117	    sh ${MK_OSRELDATE_SH}
118
119.for i in ${LHDRS}
120INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
121.endfor
122.for i in ${MHDRS}
123INCSLINKS+=	machine/$i ${INCLUDEDIR}/$i
124.endfor
125.for i in ${PHDRS}
126INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
127.endfor
128
129.if ${MACHINE} != ${MACHINE_CPUARCH}
130_MARCHS=	${MACHINE_CPUARCH}
131.endif
132.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
133_MARCHS+=	x86
134.endif
135
136META_TARGETS+=	compat
137stage_includes: ${SHARED}
138SDESTDIR=	${SYSROOT:U${DESTDIR}}
139
140# Take care of stale directory-level symlinks.
141compat:
142.for i in ${LDIRS} ${LSUBDIRS} machine ${_MARCHS} crypto
143	if [ -L ${SDESTDIR}${INCLUDEDIR}/$i ]; then \
144		rm -f ${SDESTDIR}${INCLUDEDIR}/$i; \
145	fi
146.endfor
147	mtree -deU ${NO_ROOT:D-W} ${MTREE_FOLLOWS_SYMLINKS} \
148	    -f ${SRCTOP}/etc/mtree/BSD.include.dist \
149	    -p ${SDESTDIR}${INCLUDEDIR} > /dev/null
150
151copies: .PHONY .META
152.for i in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} crypto machine machine/pc \
153	${_MARCHS}
154	if [ -d ${SDESTDIR}${INCLUDEDIR}/$i ]; then \
155		cd ${SDESTDIR}${INCLUDEDIR}/$i; \
156		for h in *.h; do \
157			if [ -L $$h ]; then rm -f $$h; fi; \
158		done; \
159	fi
160.endfor
161.for i in ${LDIRS} ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/evdev:Ndev/hyperv:Ndev/pci:Ndev/veriexec} ${LSUBSUBDIRS}
162	cd ${SRCTOP}/sys; \
163	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
164	    ${SDESTDIR}${INCLUDEDIR}/$i
165.endfor
166	cd ${SRCTOP}/sys/dev/acpica; \
167	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \
168	    ${SDESTDIR}${INCLUDEDIR}/dev/acpica; \
169	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 acpi_hpet.h \
170	    ${SDESTDIR}${INCLUDEDIR}/dev/acpica
171	cd ${SRCTOP}/sys/dev/agp; \
172	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 agpreg.h \
173	    ${SDESTDIR}${INCLUDEDIR}/dev/agp
174	cd ${SRCTOP}/sys/dev/bktr; \
175	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \
176	    ${SDESTDIR}${INCLUDEDIR}/dev/bktr
177	cd ${SRCTOP}/sys/dev/evdev; \
178	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 input.h \
179	    ${SDESTDIR}${INCLUDEDIR}/dev/evdev; \
180	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 input-event-codes.h \
181	    ${SDESTDIR}${INCLUDEDIR}/dev/evdev; \
182	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 uinput.h \
183	    ${SDESTDIR}${INCLUDEDIR}/dev/evdev
184	cd ${SRCTOP}/sys/dev/hyperv/include; \
185	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 hyperv.h \
186	    ${SDESTDIR}${INCLUDEDIR}/dev/hyperv
187	cd ${SRCTOP}/sys/dev/hyperv/utilities; \
188	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 hv_snapshot.h \
189	    ${SDESTDIR}${INCLUDEDIR}/dev/hyperv
190	cd ${SRCTOP}/sys/dev/pci; \
191	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 pcireg.h \
192	    ${SDESTDIR}${INCLUDEDIR}/dev/pci
193	cd ${SRCTOP}/sys/dev/veriexec; \
194	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 veriexec_ioctl.h \
195	    ${SDESTDIR}${INCLUDEDIR}/dev/veriexec
196	cd ${SRCTOP}/sys/fs/cd9660/; \
197	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
198	    ${SDESTDIR}${INCLUDEDIR}/isofs/cd9660
199.if ${MK_IPFILTER} != "no"
200	cd ${SRCTOP}/sys/contrib/ipfilter/netinet; \
201	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
202	    ${SDESTDIR}${INCLUDEDIR}/netinet
203.endif
204.if ${MK_PF} != "no"
205	cd ${SRCTOP}/sys/netpfil/pf; \
206	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
207	    ${SDESTDIR}${INCLUDEDIR}/netpfil/pf
208.endif
209	cd ${SRCTOP}/sys/crypto; \
210	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 rijndael/rijndael.h \
211	    ${SDESTDIR}${INCLUDEDIR}/crypto
212	cd ${SRCTOP}/sys/opencrypto; \
213	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
214	    ${SDESTDIR}${INCLUDEDIR}/crypto
215	cd ${SRCTOP}/sys/${MACHINE}/include; \
216	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
217	    ${SDESTDIR}${INCLUDEDIR}/machine
218.if exists(${SRCTOP}/sys/${MACHINE}/include/pc)
219	cd ${SRCTOP}/sys/${MACHINE}/include/pc; \
220	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
221	    ${SDESTDIR}${INCLUDEDIR}/machine/pc
222.endif
223.for _MARCH in ${_MARCHS}
224.if exists(${SRCTOP}/sys/${_MARCH}/include)
225	${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
226	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}; \
227	cd ${SRCTOP}/sys/${_MARCH}/include; \
228	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
229	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}
230.if exists(${SRCTOP}/sys/${_MARCH}/include/pc)
231	${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
232	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
233	cd ${SRCTOP}/sys/${_MARCH}/include/pc; \
234	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
235	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}/pc
236.endif
237.endif
238.endfor
239	cd ${SRCTOP}/sys/rpc; \
240	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 types.h \
241	    ${SDESTDIR}${INCLUDEDIR}/rpc
242	cd ${SRCTOP}/sys/teken; \
243	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 teken.h \
244	    ${SDESTDIR}${INCLUDEDIR}/teken
245.if ${MK_CDDL} != "no"
246	cd ${SRCTOP}/sys/cddl/contrib/opensolaris/uts/common/sys; \
247	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 nvpair.h \
248	    ${SDESTDIR}${INCLUDEDIR}/sys
249.endif
250.if ${MK_MLX5TOOL} != "no"
251	cd ${SRCTOP}/sys/dev/mlx5; \
252	${INSTALL} -C ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 444 mlx5io.h \
253	    ${SDESTDIR}${INCLUDEDIR}/dev/mlx5
254.endif
255
256symlinks: .PHONY .META
257	@${ECHO} "Setting up symlinks to kernel source tree..."
258.for i in ${LDIRS}
259	cd ${SRCTOP}/sys/$i; \
260	for h in *.h; do \
261		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/$i/$$h ${SDESTDIR}${INCLUDEDIR}/$i; \
262	done
263.endfor
264.for i in ${LSUBDIRS:Ndev/agp:Ndev/acpica:Ndev/bktr:Ndev/evdev:Ndev/hyperv:Ndev/pci:Ndev/veriexec}
265	cd ${SRCTOP}/sys/$i; \
266	for h in *.h; do \
267		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/$i/$$h ${SDESTDIR}${INCLUDEDIR}/$i; \
268	done
269.endfor
270	cd ${SRCTOP}/sys/dev/acpica; \
271	for h in acpiio.h acpi_hpet.h; do \
272		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/acpica/$$h \
273		    ${SDESTDIR}${INCLUDEDIR}/dev/acpica; \
274	done
275	cd ${SRCTOP}/sys/dev/agp; \
276	for h in agpreg.h; do \
277		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/agp/$$h \
278		    ${SDESTDIR}${INCLUDEDIR}/dev/agp; \
279	done
280	cd ${SRCTOP}/sys/dev/bktr; \
281	for h in ioctl_*.h; do \
282		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/bktr/$$h \
283		    ${SDESTDIR}${INCLUDEDIR}/dev/bktr; \
284	done
285	cd ${SRCTOP}/sys/dev/evdev; \
286	for h in input.h input-event-codes.h uinput.h; do \
287		ln -fs ../../../../sys/dev/evdev/$$h \
288		    ${SDESTDIR}${INCLUDEDIR}/dev/evdev; \
289	done
290	cd ${SRCTOP}/sys/dev/hyperv/include; \
291	for h in hyperv.h; do \
292		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/hyperv/include/$$h \
293		    ${SDESTDIR}${INCLUDEDIR}/dev/hyperv; \
294	done
295	cd ${SRCTOP}/sys/dev/hyperv/utilities; \
296	for h in hv_snapshot.h; do \
297		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/hyperv/utilities/$$h \
298		    ${SDESTDIR}${INCLUDEDIR}/dev/hyperv; \
299	done
300	cd ${SRCTOP}/sys/dev/pci; \
301	for h in pcireg.h; do \
302		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/pci/$$h \
303		    ${SDESTDIR}${INCLUDEDIR}/dev/pci; \
304	done
305	cd ${SRCTOP}/sys/dev/veriexec; \
306	for h in veriexec_ioctl.h; do \
307		ln -fs ../../../../sys/dev/veriexec/$$h \
308		    ${SDESTDIR}${INCLUDEDIR}/dev/veriexec; \
309	done
310.for i in ${LSUBSUBDIRS}
311	cd ${SRCTOP}/sys/$i; \
312	for h in *.h; do \
313		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../../sys/$i/$$h ${SDESTDIR}${INCLUDEDIR}/$i; \
314	done
315.endfor
316.if ${MK_IPFILTER} != "no"
317	cd ${SRCTOP}/sys/contrib/ipfilter/netinet; \
318	for h in *.h; do \
319		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/contrib/ipfilter/netinet/$$h \
320		    ${SDESTDIR}${INCLUDEDIR}/netinet; \
321	done
322.endif
323.if ${MK_PF} != "no"
324	cd ${SRCTOP}/sys/netpfil/pf; \
325	for h in *.h; do \
326		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/netpfil/pf/$$h \
327		    ${SDESTDIR}${INCLUDEDIR}/netpfil/pf; \
328	done
329.endif
330	cd ${SRCTOP}/sys/crypto; \
331	for h in rijndael/rijndael.h; do \
332		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/crypto/$$h \
333		    ${SDESTDIR}${INCLUDEDIR}/crypto; \
334	done
335	cd ${SRCTOP}/sys/opencrypto; \
336	for h in *.h; do \
337		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/opencrypto/$$h \
338		    ${SDESTDIR}${INCLUDEDIR}/crypto; \
339	done
340	cd ${SRCTOP}/sys/${MACHINE}/include; \
341	for h in *.h; do \
342		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/${MACHINE}/include/$$h \
343		    ${SDESTDIR}${INCLUDEDIR}/machine; \
344	done
345.if exists(${SRCTOP}/sys/${MACHINE}/include/pc)
346	cd ${SRCTOP}/sys/${MACHINE}/include/pc; \
347	for h in *.h; do \
348		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/${MACHINE}/include/pc/$$h \
349		    ${SDESTDIR}${INCLUDEDIR}/machine/pc; \
350	done
351.endif
352.for _MARCH in ${_MARCHS}
353.if exists(${SRCTOP}/sys/${_MARCH}/include)
354	${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
355	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}; \
356	cd ${SRCTOP}/sys/${_MARCH}/include; \
357	for h in *.h; do \
358		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/${_MARCH}/include/$$h \
359		    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}; \
360	done
361.if exists(${SRCTOP}/sys/${_MARCH}/include/pc)
362	${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
363	    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
364	cd ${SRCTOP}/sys/${_MARCH}/include/pc; \
365	for h in *.h; do \
366		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/${_MARCH}/include/pc/$$h \
367		    ${SDESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
368	done
369.endif
370.endif
371.endfor
372	cd ${SRCTOP}/sys/fs/cd9660; \
373	for h in *.h; do \
374		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/fs/cd9660/$$h \
375		    ${SDESTDIR}${INCLUDEDIR}/isofs/cd9660; \
376	done
377	cd ${SRCTOP}/sys/rpc; \
378	for h in types.h; do \
379		${INSTALL_SYMLINK} ${TAG_ARGS} ../../../sys/rpc/$$h \
380		    ${SDESTDIR}${INCLUDEDIR}/rpc; \
381	done
382.if ${MK_CDDL} != "no"
383	${INSTALL_SYMLINK} ${TAG_ARGS} \
384	    ../../../sys/cddl/contrib/opensolaris/uts/common/sys/nvpair.h \
385	    ${SDESTDIR}${INCLUDEDIR}/sys
386.endif
387.if ${MK_MLX5TOOL} != "no"
388	${INSTALL_SYMLINK} ${TAG_ARGS} ../../../../sys/dev/mlx5/mlx5io.h \
389	    ${SDESTDIR}${INCLUDEDIR}/dev/mlx5
390.endif
391
392.include <bsd.prog.mk>
393
394installincludes: ${SHARED}
395${SHARED}: compat
396
397.if ${MACHINE} == "host" && !defined(_SKIP_BUILD)
398# we're here because we are building a sysroot...
399# we need MACHINE et al set correctly
400HOST_MACHINE!= uname -m
401HOST_MACHINE_ARCH!= uname -p
402MACHINE:= ${HOST_MACHINE}
403MACHINE_ARCH:= ${HOST_MACHINE_ARCH}
404.endif
405