xref: /freebsd/tools/build/test-includes/Makefile (revision 9768746b)
1#
2# A number of header files in sys/* have, going back to 7th Edition Unix in
3# 1979, reqiured other files (like sys/types.h) to compile. Likewise the 4BSD
4# networking code has had prerequisites. However, going back to around the turn
5# of the century, other systems have made them be independently includable
6# (wide-spread header include protection post-dates 7th edition Unix by maybe 4
7# or 5 years judging from netnews sources). Start down the path of making them
8# all independently includable by creating this test that fails buildworld when
9# they are not.
10#
11# The _foo.h files are excluded as they are internal-only headers and/or have
12# special requirements. Since the purpose of this is to allow autoconfig
13# programs to detect FreeBSD has different headers, omitting internal
14# headers cuts down on the noise w/o causing problems for the goal.
15#
16LIB=	test-includes
17INTERNALLIB=	This is a compile-only test
18MAN=
19HDRS!=	(cd ${SRCTOP}/sys; ls sys/[!_]*.h | sort ; ls net*/[!_]*.h | sort)
20NO_PIC=	yes
21
22# Some files have to be clean for extra defines too...
23CFLAGS.event.c=	-D_WANT_KEVENT32 -D_WANT_FREEBSD11_KEVENT
24
25.include "badfiles.inc"
26
27.for h c in ${HDRS:@x@$x ${x:S,/,_,g:R}.c@}
28.if !${BADHDRS:M${h}}
29SRCS+= $c
30CLEANFILES+=$c
31$c:
32	echo "#include <$h>" > ${.TARGET}
33.endif
34.endfor
35
36test-includes: lib${LIB}.a .PHONY
37
38#
39# Target to make the current known bad list. In general, this list should only
40# ever shrink and never grow.
41#
42.PHONY:	badfiles.inc
43badfiles.inc:
44	@(cd ${SRCTOP}/sys;							\
45	echo "# DO NOT EDIT-- this file is automatically @""generated.";	\
46	echo "BADHDRS= \\";							\
47	for i in ${HDRS}; do						\
48		echo "#include <$$i>" |						\
49			${CC} ${CFLAGS} -xc - -c -o /dev/null 2> /dev/null ||	\
50			echo "	$$i \\";					\
51	done;									\
52	echo) > ${.CURDIR}/badfiles.inc
53
54.include <bsd.lib.mk>
55