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