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= 19*44b36b80SBrooks 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 25dd55767bSWarner Losh.include "badfiles.inc" 26dd55767bSWarner Losh 275ae6cc00SWarner Losh.for h c in ${HDRS:@x@$x ${x:S,/,_,g:R}.c@} 28dd55767bSWarner Losh.if !${BADHDRS:M${h}} 295ae6cc00SWarner LoshSRCS+= $c 305ae6cc00SWarner LoshCLEANFILES+=$c 315ae6cc00SWarner Losh$c: 32dd55767bSWarner Losh echo "#include <$h>" > ${.TARGET} 33dd55767bSWarner Losh.endif 34dd55767bSWarner Losh.endfor 35dd55767bSWarner Losh 367a171e30SWarner Loshtest-includes: lib${LIB}.a .PHONY 377a171e30SWarner Losh 38dd55767bSWarner Losh# 39dd55767bSWarner Losh# Target to make the current known bad list. In general, this list should only 40dd55767bSWarner Losh# ever shrink and never grow. 41dd55767bSWarner Losh# 42dd55767bSWarner Losh.PHONY: badfiles.inc 43dd55767bSWarner Loshbadfiles.inc: 44dd55767bSWarner Losh @(cd ${SRCTOP}/sys; \ 45dd55767bSWarner Losh echo "# DO NOT EDIT-- this file is automatically @""generated."; \ 46dd55767bSWarner Losh echo "BADHDRS= \\"; \ 472f3c018bSKristof Provost for i in ${HDRS}; do \ 48dd55767bSWarner Losh echo "#include <$$i>" | \ 49dd55767bSWarner Losh ${CC} ${CFLAGS} -xc - -c -o /dev/null 2> /dev/null || \ 50dd55767bSWarner Losh echo " $$i \\"; \ 51dd55767bSWarner Losh done; \ 52dd55767bSWarner Losh echo) > ${.CURDIR}/badfiles.inc 53dd55767bSWarner Losh 547a171e30SWarner Losh.include <bsd.lib.mk> 55