xref: /freebsd/tools/build/test-includes/Makefile (revision d80ab37f9883cb981c9b359d50bbfe8f0d6f2884)
1dd55767bSWarner Losh#
2dd55767bSWarner Losh# A number of header files in sys/* have, going back to 7th Edition Unix in
3dd55767bSWarner Losh# 1979, reqiured other files (like sys/types.h) to compile. Likewise the 4BSD
4dd55767bSWarner Losh# networking code has had prerequisites. However, going back to around the turn
5dd55767bSWarner Losh# of the century, other systems have made them be independently includable
6dd55767bSWarner Losh# (wide-spread header include protection post-dates 7th edition Unix by maybe 4
7dd55767bSWarner Losh# or 5 years judging from netnews sources). Start down the path of making them
8dd55767bSWarner Losh# all independently includable by creating this test that fails buildworld when
9dd55767bSWarner Losh# they are not.
10dd55767bSWarner Losh#
11dd55767bSWarner Losh# The _foo.h files are excluded as they are internal-only headers and/or have
12dd55767bSWarner Losh# special requirements. Since the purpose of this is to allow autoconfig
13dd55767bSWarner Losh# programs to detect FreeBSD has different headers, omitting internal
14dd55767bSWarner Losh# headers cuts down on the noise w/o causing problems for the goal.
15dd55767bSWarner Losh#
167a171e30SWarner LoshLIB=	test-includes
177a171e30SWarner LoshINTERNALLIB=	This is a compile-only test
18dd55767bSWarner LoshMAN=
1944b36b80SBrooks DavisHDRS!=	(cd ${SRCTOP}/sys; ls sys/[!_]*.h | sort ; ls net*/[!_]*.h | sort)
207a171e30SWarner LoshNO_PIC=	yes
21dd55767bSWarner Losh
22dd55767bSWarner Losh# Some files have to be clean for extra defines too...
23dd55767bSWarner LoshCFLAGS.event.c=	-D_WANT_KEVENT32 -D_WANT_FREEBSD11_KEVENT
24dd55767bSWarner Losh
25259e6fefSWarner Losh# We currently support C89 and newer compilers. Catch the odd little fussy
26259e6fefSWarner Losh# details like __inline that the header files must follow to support C89.
27259e6fefSWarner LoshCFLAGS+=-ansi
28259e6fefSWarner Losh
29*d80ab37fSMark Johnston# Make sure we're pulling in headers from the src tree.
30*d80ab37fSMark JohnstonCFLAGS+=-I${SRCTOP}/sys
31*d80ab37fSMark Johnston
32dd55767bSWarner Losh.include "badfiles.inc"
33dd55767bSWarner Losh
345ae6cc00SWarner Losh.for h c in ${HDRS:@x@$x ${x:S,/,_,g:R}.c@}
35dd55767bSWarner Losh.if !${BADHDRS:M${h}}
365ae6cc00SWarner LoshSRCS+= $c
375ae6cc00SWarner LoshCLEANFILES+=$c
385ae6cc00SWarner Losh$c:
39dd55767bSWarner Losh	echo "#include <$h>" > ${.TARGET}
40dd55767bSWarner Losh.endif
41dd55767bSWarner Losh.endfor
42dd55767bSWarner Losh
437a171e30SWarner Loshtest-includes: lib${LIB}.a .PHONY
447a171e30SWarner Losh
45dd55767bSWarner Losh#
46dd55767bSWarner Losh# Target to make the current known bad list. In general, this list should only
47dd55767bSWarner Losh# ever shrink and never grow.
48dd55767bSWarner Losh#
49dd55767bSWarner Losh.PHONY:	badfiles.inc
50dd55767bSWarner Loshbadfiles.inc:
51dd55767bSWarner Losh	@(cd ${SRCTOP}/sys;							\
52dd55767bSWarner Losh	echo "# DO NOT EDIT-- this file is automatically @""generated.";	\
53dd55767bSWarner Losh	echo "BADHDRS= \\";							\
542f3c018bSKristof Provost	for i in ${HDRS}; do						\
55dd55767bSWarner Losh		echo "#include <$$i>" |						\
56dd55767bSWarner Losh			${CC} ${CFLAGS} -xc - -c -o /dev/null 2> /dev/null ||	\
57dd55767bSWarner Losh			echo "	$$i \\";					\
58dd55767bSWarner Losh	done;									\
59dd55767bSWarner Losh	echo) > ${.CURDIR}/badfiles.inc
60dd55767bSWarner Losh
617a171e30SWarner Losh.include <bsd.lib.mk>
62