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