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