Makefile revision 104489
1218893Sdim#	@(#)Makefile	8.2 (Berkeley) 1/4/94
2193323Sed# $FreeBSD: head/include/Makefile 104489 2002-10-04 20:44:28Z sam $
3193323Sed#
4193323Sed# Doing a make install builds /usr/include
5193323Sed#
6193323Sed# The ``rm -rf''s used below are safe because rm doesn't follow symbolic
7193323Sed# links.
8193323Sed
9193323SedCLEANFILES= osreldate.h version vers.c
10218893SdimSUBDIR= arpa protocols rpcsvc rpc
11218893SdimINCS=	a.out.h ar.h assert.h bitstring.h complex.h cpio.h ctype.h db.h \
12218893Sdim	dirent.h \
13193323Sed	dlfcn.h elf.h elf-hints.h err.h fnmatch.h fmtmsg.h fstab.h \
14193323Sed	fts.h getopt.h glob.h grp.h \
15193323Sed	hesiod.h histedit.h ieeefp.h ifaddrs.h inttypes.h iso646.h kenv.h \
16249423Sdim	langinfo.h \
17249423Sdim	libgen.h limits.h link.h locale.h malloc.h memory.h monetary.h mpool.h \
18249423Sdim	ndbm.h netconfig.h netdb.h nl_types.h nlist.h nsswitch.h objformat.h \
19193323Sed	paths.h pthread.h pthread_np.h pwd.h \
20199989Srdivacky	ranlib.h readpassphrase.h regex.h regexp.h resolv.h rune.h runetype.h \
21249423Sdim	search.h setjmp.h sgtty.h \
22199989Srdivacky	signal.h stab.h stdbool.h stddef.h stdio.h stdlib.h strhash.h \
23199989Srdivacky	string.h stringlist.h strings.h sysexits.h tar.h time.h timeconv.h \
24249423Sdim	timers.h ttyent.h ulimit.h unistd.h utime.h utmp.h vis.h wchar.h \
25249423Sdim	wctype.h
26249423Sdim
27249423SdimMHDRS=	float.h floatingpoint.h stdarg.h varargs.h
28249423Sdim
29249423Sdim# posix4/aio.h conflicts with dysons and isn't installed,
30249423Sdim# posix4/mqueue.h is useless without an implementation and isn't installed:
31249423SdimPHDRS=	sched.h semaphore.h _semaphore.h # aio.h mqueue.h
32249423Sdim
33249423SdimLHDRS=	aio.h errno.h fcntl.h linker_set.h poll.h stdint.h syslog.h \
34249423Sdim	termios.h ucontext.h
35198090Srdivacky
36212904SdimLDIRS=	cam net netatalk netatm netgraph netinet netinet6 \
37249423Sdim	netipx netkey netnatm netncp netns netsmb nfs nfsclient nfsserver \
38193323Sed	pccard posix4 sys vm
39193323Sed
40193323SedLSUBDIRS=	cam/scsi dev/an dev/ic dev/iicbus dev/ppbus dev/smbus \
41193323Sed	dev/usb dev/wi fs/devfs \
42193323Sed	fs/fdescfs fs/fifofs fs/msdosfs fs/ntfs fs/nullfs fs/nwfs fs/portalfs \
43193323Sed	fs/procfs fs/smbfs fs/umapfs fs/unionfs isofs/cd9660 \
44193323Sed	netatm/ipatm netatm/sigpvc netatm/spans netatm/uni \
45193323Sed	security/lomac security/mac_biba security/mac_bsdextended \
46193323Sed	security/mac_mls ufs/ffs ufs/ufs
47193323Sed
48193323Sed# For SHARED=symlinks, cam and netatm are symlinks, so cam/scsi and netatm/*
49198892Srdivacky# are taken care of
50199989SrdivackyLSYMSUBDIRS=	${LSUBDIRS:Ncam/scsi:Nnetatm/*}
51199989Srdivacky
52199989Srdivacky# Define SHARED to indicate whether you want symbolic links to the system
53199989Srdivacky# source (``symlinks''), or a separate copy (``copies'').  ``symlinks'' is
54199989Srdivacky# probably only useful for developers and should be avoided if you do not
55199989Srdivacky# wish to tie your /usr/include and /usr/src together.
56193323Sed#SHARED=	symlinks
57193323SedSHARED?=	copies
58193323Sed
59193323SedINCS+=	osreldate.h
60193323Sed
61243830Sdimosreldate.h:	${.CURDIR}/../sys/conf/newvers.sh \
62243830Sdim		${.CURDIR}/../sys/sys/param.h \
63243830Sdim		${.CURDIR}/Makefile
64243830Sdim	@${ECHO} creating osreldate.h from newvers.sh
65199989Srdivacky	setvar PARAMFILE ${.CURDIR}/../sys/sys/param.h; \
66243830Sdim	. ${.CURDIR}/../sys/conf/newvers.sh;			\
67193323Sed	echo "$$COPYRIGHT" > osreldate.h;			\
68193323Sed	echo "#ifdef _KERNEL" >> osreldate.h;			\
69193323Sed	echo '#error "/usr/include/osreldate.h cannot be used in the kernel, use sys/param.h"' >> osreldate.h; \
70210299Sed	echo "#else" >> osreldate.h;				\
71210299Sed	echo \#'undef __FreeBSD_version' >> osreldate.h;	\
72210299Sed	echo \#'define __FreeBSD_version' $$RELDATE >> osreldate.h; \
73210299Sed	echo "#endif" >> osreldate.h
74210299Sed
75193323Sed.for i in ${LHDRS}
76210299SedINCSLINKS+=	sys/$i ${INCLUDEDIR}/$i
77210299Sed.endfor
78210299Sed.for i in ${MHDRS}
79210299SedINCSLINKS+=	machine/$i ${INCLUDEDIR}/$i
80210299Sed.endfor
81210299Sed.for i in ${PHDRS}
82210299SedINCSLINKS+=	posix4/$i ${INCLUDEDIR}/$i
83210299Sed.endfor
84210299Sed
85218893Sdimcopies:
86218893Sdim.for i in ${LDIRS} ${LSYMSUBDIRS} machine crypto
87243830Sdim	if [ -L ${DESTDIR}/usr/include/$i ]; then \
88243830Sdim		rm -f ${DESTDIR}/usr/include/$i; \
89234353Sdim	fi
90239462Sdim.endfor
91251662Sdim	mtree -deU ${MTREE_FOLLOWS_SYMLINKS} -f ${.CURDIR}/../etc/mtree/BSD.include.dist \
92239462Sdim		-p ${DESTDIR}/usr/include
93239462Sdim.for i in ${LDIRS} ${LSUBDIRS}
94193323Sed	cd ${.CURDIR}/../sys; \
95193323Sed		${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 $i/*.h \
96218893Sdim		${DESTDIR}/usr/include/$i
97218893Sdim.endfor
98218893Sdim	cd ${.CURDIR}/../sys; \
99243830Sdim		${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 opencrypto/*.h \
100243830Sdim		${DESTDIR}/usr/include/crypto
101251662Sdim.if exists(${.CURDIR}/../sys/${MACHINE_ARCH}/include)
102251662Sdim	cd ${.CURDIR}/../sys/${MACHINE_ARCH}/include; \
103251662Sdim		${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
104251662Sdim		${DESTDIR}/usr/include/machine
105251662Sdim.if exists(${.CURDIR}/../sys/${MACHINE_ARCH}/include/pc)
106251662Sdim	cd ${.CURDIR}/../sys/${MACHINE_ARCH}/include/pc; \
107251662Sdim		${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 *.h \
108251662Sdim		${DESTDIR}/usr/include/machine/pc
109251662Sdim.endif
110251662Sdim.endif
111251662Sdim
112251662Sdimsymlinks:
113251662Sdim	@${ECHO} "Setting up symlinks to kernel source tree..."
114251662Sdim.for i in ${LDIRS}
115251662Sdim	rm -rf ${DESTDIR}/usr/include/$i
116251662Sdim	ln -s ../../sys/$i ${DESTDIR}/usr/include/$i
117251662Sdim.endfor
118251662Sdim	rm -rf ${DESTDIR}/usr/include/crypto
119251662Sdim	ln -s ../../sys/opencrypto ${DESTDIR}/usr/include/crypto
120251662Sdim.for i in ${LSYMSUBDIRS}
121251662Sdim	rm -rf ${DESTDIR}/usr/include/$i
122251662Sdim	ln -s ../../../sys/$i ${DESTDIR}/usr/include/$i
123251662Sdim.endfor
124251662Sdim	rm -rf ${DESTDIR}/usr/include/machine
125251662Sdim	ln -s ../../sys/${MACHINE_ARCH}/include ${DESTDIR}/usr/include/machine
126251662Sdim
127251662Sdim.include <bsd.prog.mk>
128251662Sdim
129251662Sdiminstallincludes: ${SHARED}
130234353Sdim