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 25*259e6fefSWarner Losh# We currently support C89 and newer compilers. Catch the odd little fussy 26*259e6fefSWarner Losh# details like __inline that the header files must follow to support C89. 27*259e6fefSWarner LoshCFLAGS+=-ansi 28*259e6fefSWarner Losh 29dd55767bSWarner Losh.include "badfiles.inc" 30dd55767bSWarner Losh 315ae6cc00SWarner Losh.for h c in ${HDRS:@x@$x ${x:S,/,_,g:R}.c@} 32dd55767bSWarner Losh.if !${BADHDRS:M${h}} 335ae6cc00SWarner LoshSRCS+= $c 345ae6cc00SWarner LoshCLEANFILES+=$c 355ae6cc00SWarner Losh$c: 36dd55767bSWarner Losh echo "#include <$h>" > ${.TARGET} 37dd55767bSWarner Losh.endif 38dd55767bSWarner Losh.endfor 39dd55767bSWarner Losh 407a171e30SWarner Loshtest-includes: lib${LIB}.a .PHONY 417a171e30SWarner Losh 42dd55767bSWarner Losh# 43dd55767bSWarner Losh# Target to make the current known bad list. In general, this list should only 44dd55767bSWarner Losh# ever shrink and never grow. 45dd55767bSWarner Losh# 46dd55767bSWarner Losh.PHONY: badfiles.inc 47dd55767bSWarner Loshbadfiles.inc: 48dd55767bSWarner Losh @(cd ${SRCTOP}/sys; \ 49dd55767bSWarner Losh echo "# DO NOT EDIT-- this file is automatically @""generated."; \ 50dd55767bSWarner Losh echo "BADHDRS= \\"; \ 512f3c018bSKristof Provost for i in ${HDRS}; do \ 52dd55767bSWarner Losh echo "#include <$$i>" | \ 53dd55767bSWarner Losh ${CC} ${CFLAGS} -xc - -c -o /dev/null 2> /dev/null || \ 54dd55767bSWarner Losh echo " $$i \\"; \ 55dd55767bSWarner Losh done; \ 56dd55767bSWarner Losh echo) > ${.CURDIR}/badfiles.inc 57dd55767bSWarner Losh 587a171e30SWarner Losh.include <bsd.lib.mk> 59