xref: /freebsd/include/Makefile (revision 7cd2dcf07629713e5a3d60472cfe4701b705a167)
1#	@(#)Makefile	8.2 (Berkeley) 1/4/94
2# $FreeBSD$
3#
4# Doing a "make install" builds /usr/include.
5
6.include <bsd.own.mk>
7
8CLEANFILES= osreldate.h version vers.c
9SUBDIR= arpa gssapi 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 gssapi.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 stdatomic.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	ulimit.h unistd.h utime.h utmpx.h uuid.h varargs.h vis.h \
27	wchar.h wctype.h wordexp.h xlocale.h
28
29MHDRS=	float.h floatingpoint.h stdarg.h
30
31PHDRS=	sched.h _semaphore.h
32
33LHDRS=	aio.h errno.h fcntl.h linker_set.h poll.h stdint.h syslog.h \
34	ucontext.h
35
36LDIRS=	bsm cam geom net net80211 netatalk netgraph netinet netinet6 \
37	netipsec ${_netipx} netnatm \
38	nfs nfsclient nfsserver \
39	sys vm
40
41LSUBDIRS=	cam/ata cam/scsi \
42	dev/acpica dev/an dev/bktr dev/ciss dev/filemon dev/firewire dev/hwpmc \
43	dev/ic dev/iicbus ${_dev_ieee488} dev/io dev/lmc dev/mfi dev/nvme \
44	dev/ofw dev/pbio ${_dev_powermac_nvram} dev/ppbus dev/smbus \
45	dev/speaker dev/usb dev/utopia dev/vkbd dev/wi \
46	fs/devfs fs/fdescfs fs/msdosfs fs/nandfs fs/nfs fs/nullfs \
47	fs/procfs fs/udf fs/unionfs \
48	geom/cache geom/concat geom/eli geom/gate geom/journal geom/label \
49	geom/mirror geom/mountver geom/multipath geom/nop \
50	geom/raid geom/raid3 geom/shsec geom/stripe geom/virstor \
51	netgraph/atm netgraph/netflow \
52	security/audit \
53	security/mac_biba security/mac_bsdextended security/mac_lomac \
54	security/mac_mls security/mac_partition \
55	ufs/ffs ufs/ufs
56
57LSUBSUBDIRS=	dev/mpt/mpilib
58
59.if ${MACHINE_ARCH} == "powerpc" || ${MACHINE_ARCH} == "powerpc64"
60_dev_powermac_nvram=	dev/powermac_nvram
61.endif
62
63.if ${MK_GPIB} != "no"
64_dev_ieee488=	dev/ieee488
65.endif
66
67.if ${MK_HESIOD} != "no"
68INCS+=	hesiod.h
69.endif
70
71.if ${MK_ICONV} != "no"
72INCS+=	iconv.h
73.endif
74
75.if ${MK_BLUETOOTH} != "no"
76LSUBSUBDIRS+=	netgraph/bluetooth/include
77.endif
78
79#.if ${MK_IPX} != "no"
80_netipx=	netipx
81#.endif
82
83# Define SHARED to indicate whether you want symbolic links to the system
84# source (``symlinks''), or a separate copy (``copies'').  ``symlinks'' is
85# probably only useful for developers and should be avoided if you do not
86# wish to tie your /usr/include and /usr/src together.
87#SHARED=	symlinks
88SHARED?=	copies
89
90INCS+=	osreldate.h
91
92osreldate.h: ${.CURDIR}/../sys/conf/newvers.sh ${.CURDIR}/../sys/sys/param.h \
93    ${.CURDIR}/Makefile
94	@${ECHO} creating osreldate.h from newvers.sh
95	@MAKE=${MAKE}; \
96	PARAMFILE=${.CURDIR}/../sys/sys/param.h; \
97	. ${.CURDIR}/../sys/conf/newvers.sh; \
98	echo "$$COPYRIGHT" > osreldate.h; \
99	echo "#ifdef _KERNEL" >> osreldate.h; \
100	echo "#error \"<osreldate.h> cannot be used in the kernel, use <sys/param.h>\"" >> osreldate.h; \
101	echo "#else" >> osreldate.h; \
102	echo "#undef __FreeBSD_version" >> osreldate.h; \
103	echo "#define __FreeBSD_version $$RELDATE" >> osreldate.h; \
104	echo "#endif" >> osreldate.h
105
106.for i in ${LHDRS}
107INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
108.endfor
109.for i in ${MHDRS}
110INCSLINKS+=	machine/$i ${INCLUDEDIR}/$i
111.endfor
112.for i in ${PHDRS}
113INCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
114.endfor
115
116.if ${MACHINE} != ${MACHINE_CPUARCH}
117_MARCHS=	${MACHINE_CPUARCH}
118.endif
119.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
120_MARCHS+=	x86
121.endif
122
123.if ${MK_STAGING} != "no"
124# tell bsd.incs.mk that we have it covered
125stage_includes:
126.endif
127
128.include <bsd.prog.mk>
129
130.if ${MK_STAGING} != "no" && !defined(_SKIP_BUILD)
131.if make(all)
132DESTDIR= ${STAGE_OBJTOP}
133# we want to keep this separate from the folk who
134# do staging "normally"
135INCLUDEDIR=	/include
136
137all:	stage_includes
138installincludes: buildincludes
139buildincludes: stage_prep
140
141stage_prep:
142	@mkdir -p ${DESTDIR}${INCLUDEDIR}
143	@touch $@
144
145stage_includes: .dirdep installincludes
146	@find ${DESTDIR}${INCLUDEDIR} -type d | while read d; do \
147		rm -f $$d/.dirdep; \
148		{ ln .dirdep $$d/.dirdep 2> /dev/null || \
149		cp -p .dirdep $$d/.dirdep; }; \
150	done
151	@touch $@
152.endif
153.endif
154
155installincludes: ${SHARED}
156${SHARED}: compat
157
158# Take care of stale directory-level symlinks.
159compat:
160.for i in ${LDIRS} ${LSUBDIRS} machine ${_MARCHS} crypto
161	if [ -L ${DESTDIR}${INCLUDEDIR}/$i ]; then \
162		rm -f ${DESTDIR}${INCLUDEDIR}/$i; \
163	fi
164.endfor
165	mtree -deU ${MTREE_FOLLOWS_SYMLINKS} \
166	    -f ${.CURDIR}/../etc/mtree/BSD.include.dist \
167	    -p ${DESTDIR}${INCLUDEDIR} > /dev/null
168.if ${MK_BIND_LIBS} != "no"
169	mtree -deU ${MTREE_FOLLOWS_SYMLINKS} \
170	    -f ${.CURDIR}/../etc/mtree/BIND.include.dist \
171	    -p ${DESTDIR}${INCLUDEDIR} > /dev/null
172.endif
173
174copies:
175.for i in ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} altq crypto machine machine/pc \
176	${_MARCHS}
177.if exists(${DESTDIR}${INCLUDEDIR}/$i)
178	cd ${DESTDIR}${INCLUDEDIR}/$i; \
179	for h in *.h; do \
180		if [ -L $$h ]; then rm -f $$h; fi; \
181	done
182.endif
183.endfor
184.for i in ${LDIRS} ${LSUBDIRS:Ndev/acpica:Ndev/bktr:Ndev/nand} ${LSUBSUBDIRS}
185	cd ${.CURDIR}/../sys; \
186	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
187	    ${DESTDIR}${INCLUDEDIR}/$i
188.endfor
189	cd ${.CURDIR}/../sys/dev/acpica; \
190	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 acpiio.h \
191	    ${DESTDIR}${INCLUDEDIR}/dev/acpica
192	cd ${.CURDIR}/../sys/dev/bktr; \
193	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 ioctl_*.h \
194	    ${DESTDIR}${INCLUDEDIR}/dev/bktr
195.if ${MK_NAND} != "no"
196	cd ${.CURDIR}/../sys/dev/nand; \
197	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nandsim.h \
198	    ${DESTDIR}${INCLUDEDIR}/dev/nand; \
199	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 nand_dev.h \
200	    ${DESTDIR}${INCLUDEDIR}/dev/nand
201.endif
202	cd ${.CURDIR}/../sys/contrib/altq/altq; \
203	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
204	    ${DESTDIR}${INCLUDEDIR}/altq
205	cd ${.CURDIR}/../sys/fs/cd9660/; \
206	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
207	    ${DESTDIR}${INCLUDEDIR}/isofs/cd9660
208.if ${MK_IPFILTER} != "no"
209	cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
210	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
211	    ${DESTDIR}${INCLUDEDIR}/netinet
212.endif
213	cd ${.CURDIR}/../sys/crypto; \
214	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 rijndael/rijndael.h \
215	    ${DESTDIR}${INCLUDEDIR}/crypto
216	cd ${.CURDIR}/../sys/opencrypto; \
217	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
218	    ${DESTDIR}${INCLUDEDIR}/crypto
219	cd ${.CURDIR}/../sys/${MACHINE}/include; \
220	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
221	    ${DESTDIR}${INCLUDEDIR}/machine
222.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
223	cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
224	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
225	    ${DESTDIR}${INCLUDEDIR}/machine/pc
226.endif
227.for _MARCH in ${_MARCHS}
228.if exists(${.CURDIR}/../sys/${_MARCH}/include)
229	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
230	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
231	cd ${.CURDIR}/../sys/${_MARCH}/include; \
232	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
233	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}
234.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
235	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
236	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
237	cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
238	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
239	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc
240.endif
241.endif
242.endfor
243	cd ${.CURDIR}/../sys/rpc; \
244	${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 types.h \
245	    ${DESTDIR}${INCLUDEDIR}/rpc
246
247symlinks:
248	@${ECHO} "Setting up symlinks to kernel source tree..."
249.for i in ${LDIRS}
250	cd ${.CURDIR}/../sys/$i; \
251	for h in *.h; do \
252		ln -fs ../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
253	done
254.endfor
255.for i in ${LSUBDIRS:Ndev/acpica:Ndev/bktr:Ndev/nand}
256	cd ${.CURDIR}/../sys/$i; \
257	for h in *.h; do \
258		ln -fs ../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
259	done
260.endfor
261	cd ${.CURDIR}/../sys/dev/acpica; \
262	for h in acpiio.h; do \
263		ln -fs ../../../../sys/dev/acpica/$$h \
264		    ${DESTDIR}${INCLUDEDIR}/dev/acpica; \
265	done
266	cd ${.CURDIR}/../sys/dev/bktr; \
267	for h in ioctl_*.h; do \
268		ln -fs ../../../../sys/dev/bktr/$$h \
269		    ${DESTDIR}${INCLUDEDIR}/dev/bktr; \
270	done
271.if ${MK_NAND} != "no"
272	cd ${.CURDIR}/../sys/dev/nand; \
273	for h in nandsim.h nand_dev.h; do \
274		ln -fs ../../../../sys/dev/nand/$$h \
275		    ${DESTDIR}${INCLUDEDIR}/dev/nand; \
276	done
277.endif
278.for i in ${LSUBSUBDIRS}
279	cd ${.CURDIR}/../sys/$i; \
280	for h in *.h; do \
281		ln -fs ../../../../../sys/$i/$$h ${DESTDIR}${INCLUDEDIR}/$i; \
282	done
283.endfor
284	cd ${.CURDIR}/../sys/contrib/altq/altq; \
285	for h in *.h; do \
286		ln -fs ../../../sys/contrib/altq/altq/$$h \
287		    ${DESTDIR}${INCLUDEDIR}/altq; \
288	done
289.if ${MK_IPFILTER} != "no"
290	cd ${.CURDIR}/../sys/contrib/ipfilter/netinet; \
291	for h in *.h; do \
292		ln -fs ../../../sys/contrib/ipfilter/netinet/$$h \
293		    ${DESTDIR}${INCLUDEDIR}/netinet; \
294	done
295.endif
296	cd ${.CURDIR}/../sys/crypto; \
297	for h in rijndael/rijndael.h; do \
298		ln -fs ../../../sys/crypto/$$h \
299		    ${DESTDIR}${INCLUDEDIR}/crypto; \
300	done
301	cd ${.CURDIR}/../sys/opencrypto; \
302	for h in *.h; do \
303		ln -fs ../../../sys/opencrypto/$$h \
304		    ${DESTDIR}${INCLUDEDIR}/crypto; \
305	done
306	cd ${.CURDIR}/../sys/${MACHINE}/include; \
307	for h in *.h; do \
308		ln -fs ../../../sys/${MACHINE}/include/$$h \
309		    ${DESTDIR}${INCLUDEDIR}/machine; \
310	done
311.if exists(${.CURDIR}/../sys/${MACHINE}/include/pc)
312	cd ${.CURDIR}/../sys/${MACHINE}/include/pc; \
313	for h in *.h; do \
314		ln -fs ../../../../sys/${MACHINE}/include/pc/$$h \
315		    ${DESTDIR}${INCLUDEDIR}/machine/pc; \
316	done
317.endif
318.for _MARCH in ${_MARCHS}
319.if exists(${.CURDIR}/../sys/${_MARCH}/include)
320	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
321	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
322	cd ${.CURDIR}/../sys/${_MARCH}/include; \
323	for h in *.h; do \
324		ln -fs ../../../sys/${_MARCH}/include/$$h \
325		    ${DESTDIR}${INCLUDEDIR}/${_MARCH}; \
326	done
327.if exists(${.CURDIR}/../sys/${_MARCH}/include/pc)
328	${INSTALL} -d -o ${BINOWN} -g ${BINGRP} -m 755 \
329	    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
330	cd ${.CURDIR}/../sys/${_MARCH}/include/pc; \
331	for h in *.h; do \
332		ln -fs ../../../../sys/${_MARCH}/include/pc/$$h \
333		    ${DESTDIR}${INCLUDEDIR}/${_MARCH}/pc; \
334	done
335.endif
336.endif
337.endfor
338	cd ${.CURDIR}/../sys/fs/cd9660; \
339	for h in *.h; do \
340		ln -fs ../../../../sys/fs/cd9660/$$h \
341		    ${DESTDIR}${INCLUDEDIR}/isofs/cd9660; \
342	done
343	cd ${.CURDIR}/../sys/rpc; \
344	for h in types.h; do \
345		ln -fs ../../../sys/rpc/$$h \
346		    ${DESTDIR}${INCLUDEDIR}/rpc; \
347	done
348