Index: bin/Makefile =================================================================== --- bin/Makefile +++ bin/Makefile @@ -47,5 +47,7 @@ .include SUBDIR_PARALLEL= +# Skip make includes for this part of the tree +SUBDIR_WITH_INCS= .include Index: cddl/Makefile =================================================================== --- cddl/Makefile +++ cddl/Makefile @@ -7,6 +7,7 @@ SUBDIR.${MK_TESTS}+= tests +SUBDIR_WITH_INCS=lib usr.bin usr.sbin SUBDIR_PARALLEL= .include Index: cddl/usr.bin/Makefile =================================================================== --- cddl/usr.bin/Makefile +++ cddl/usr.bin/Makefile @@ -22,6 +22,7 @@ .endif .endif +SUBDIR_WITH_INCS=${_zinject} ${_zstream} SUBDIR_PARALLEL= .include Index: cddl/usr.sbin/Makefile =================================================================== --- cddl/usr.sbin/Makefile +++ cddl/usr.sbin/Makefile @@ -47,6 +47,7 @@ _lockstat= lockstat .endif +SUBDIR_WITH_INCS=zdb SUBDIR_PARALLEL= .include Index: gnu/Makefile =================================================================== --- gnu/Makefile +++ gnu/Makefile @@ -8,6 +8,7 @@ SUBDIR.${MK_TESTS}+= tests +SUBDIR_WITH_INCS=lib SUBDIR_PARALLEL= .include Index: kerberos5/Makefile =================================================================== --- kerberos5/Makefile +++ kerberos5/Makefile @@ -28,4 +28,6 @@ ${MAKE} MK_KERBEROS=no install .endfor +SUBDIR_WITH_INCS=lib + .include Index: lib/geom/Makefile =================================================================== --- lib/geom/Makefile +++ lib/geom/Makefile @@ -1,6 +1,8 @@ # $FreeBSD$ SUBDIR=${GEOM_CLASSES} +# Skip unncessary make includes in the subdirectories. +SUBDIR_WITH_INCS= .include "Makefile.inc" .include Index: lib/kyua/Makefile =================================================================== --- lib/kyua/Makefile +++ lib/kyua/Makefile @@ -7,4 +7,7 @@ store \ utils +# Skip unncessary make includes in the subdirectories. +SUBDIR_WITH_INCS= + .include Index: lib/libalias/Makefile =================================================================== --- lib/libalias/Makefile +++ lib/libalias/Makefile @@ -2,4 +2,7 @@ SUBDIR= libalias modules +# Skip unncessary make includes in the modules subdirectories +SUBDIR_WITH_INCS=libalias + .include Index: lib/libiconv_modules/Makefile =================================================================== --- lib/libiconv_modules/Makefile +++ lib/libiconv_modules/Makefile @@ -7,4 +7,6 @@ mapper_parallel mapper_serial mapper_std mapper_zone SUBDIR_PARALLEL= +# Skip unncessary make includes in the subdirectories. +SUBDIR_WITH_INCS= .include Index: lib/libpam/Makefile =================================================================== --- lib/libpam/Makefile +++ lib/libpam/Makefile @@ -30,5 +30,6 @@ SUBDIR+= static_libpam SUBDIR_DEPEND_static_libpam= modules SUBDIR_PARALLEL= +SUBDIR_WITH_INCS= libpam .include Index: lib/libpmc/Makefile =================================================================== --- lib/libpmc/Makefile +++ lib/libpmc/Makefile @@ -122,4 +122,7 @@ pmclog.3 pmclog_feed.3 \ pmclog.3 pmclog_read.3 +# Skip unncessary make includes in the subdirectories. +SUBDIR_WITH_INCS= + .include Index: lib/libxo/Makefile =================================================================== --- lib/libxo/Makefile +++ lib/libxo/Makefile @@ -6,5 +6,6 @@ SUBDIR.${MK_TESTS}+= tests SUBDIR = libxo .WAIT encoder +SUBDIR_WITH_INCS=libxo .include Index: libexec/Makefile =================================================================== --- libexec/Makefile +++ libexec/Makefile @@ -119,4 +119,7 @@ .include +# Skip make includes for this part of the tree +SUBDIR_WITH_INCS= + .include Index: sbin/Makefile =================================================================== --- sbin/Makefile +++ sbin/Makefile @@ -93,5 +93,7 @@ .include SUBDIR_PARALLEL= +# Skip make includes for this part of the tree +SUBDIR_WITH_INCS= .include Index: secure/Makefile =================================================================== --- secure/Makefile +++ secure/Makefile @@ -38,4 +38,6 @@ ${MAKE} MK_CRYPT=no install .endfor +SUBDIR_WITH_INCS=lib + .include Index: secure/lib/Makefile =================================================================== --- secure/lib/Makefile +++ secure/lib/Makefile @@ -12,4 +12,6 @@ SUBDIR.${MK_TESTS}+= tests +SUBDIR_WITH_INCS=libcrypto + .include Index: share/Makefile =================================================================== --- share/Makefile +++ share/Makefile @@ -92,5 +92,7 @@ .endif SUBDIR_PARALLEL= +# Skip make includes for this part of the tree +SUBDIR_WITH_INCS= .include Index: share/mk/bsd.incs.mk =================================================================== --- share/mk/bsd.incs.mk +++ share/mk/bsd.incs.mk @@ -108,3 +108,18 @@ .endif .endif # ${MK_INCLUDES} != "no" + +# Sanity check that SUBDIR_WITH_INCS was set correctly +.if defined(_HAVE_INCS) +.for group in ${INCSGROUPS:UINCS} +.if defined(${group}) && !empty(${group}) +.if ${_HAVE_INCS} == "no" +.error ${.CURDIR}: Found includes but _HAVE_INCS=${_HAVE_INCS}. \ + Did you forget to set SUBDIR_WITH_INCS in the parent directory? +.elif defined(_SANITY_CHECK_INCS) && ${_HAVE_INCS} == "maybe" +.warning ${.CURDIR}: Found includes but _HAVE_INCS=${_HAVE_INCS}. \ + Did you forget to set SUBDIR_WITH_INCS in the parent directory? +.endif +.endif +.endfor +.endif Index: share/mk/bsd.subdir.mk =================================================================== --- share/mk/bsd.subdir.mk +++ share/mk/bsd.subdir.mk @@ -19,6 +19,10 @@ # subdirectories. SUBDIR.yes and SUBDIR.yes.yes are # automatically appended to this list. # +# SUBDIR_WITH_INCS A list of subdirectories that installs includes. If this +# variable is not set, it will behave as if set to SUBDIR excluding "test" +# and "tests". +# # +++ targets +++ # # distribute: @@ -140,7 +144,7 @@ fi; \ ${ECHODIR} "===> ${DIRPRFX}$${dir} ($${target})"; \ cd ${.CURDIR}/$${dir}; \ - ${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/ + _HAVE_INCS=$${have_incs} ${MAKE} $${target} DIRPRFX=${DIRPRFX}$${dir}/ # This is kept for compatibility only. The normal handling of attaching to # SUBDIR_TARGETS will create a target for each directory. @@ -155,6 +159,35 @@ ${__dir}: all_subdir_${DIRPRFX}${__dir} .PHONY .endfor + +# Skip the includes/installincludes target for subdirs that don't have includes +# as this massively speeds up the make includes part of buildworld. +# We assume that tests don't need to install includes by default (if they do, +# you can just set SUBDIR_WITH_INCS=tests in the Makefile). +.for __dir in ${SUBDIR:N.WAIT} +.if defined(SUBDIR_INCS_ALL_DIRS) +# SUBDIR_INCS_ALL_DIRS can be set to skip this `make includes` optimzation. +__have_incs_${__dir}=maybe +.elif ${_HAVE_INCS:Umaybe} == "no" +# If this directory was marked as not having includes, the same applies to all +# subdirectories +__have_incs_${__dir}=no +.elif defined(SUBDIR_WITH_INCS) +.if ${SUBDIR_WITH_INCS:M${__dir}} +__have_incs_${__dir}=yes +.else +__have_incs_${__dir}=no +.endif +.else +.if ${__dir} == "test" || ${__dir} == "tests" +# Assume that tests don't need to install includes by default. +__have_incs_${__dir}=no +.else +__have_incs_${__dir}=maybe +.endif +.endif +.endfor + .for __target in ${SUBDIR_TARGETS} # Can ordering be skipped for this and SUBDIR_PARALLEL forced? .if ${STANDALONE_SUBDIR_TARGETS:M${__target}} @@ -181,11 +214,14 @@ __deps:= ${__subdir_targets} .endif # defined(SUBDIR_PARALLEL) .endif # ${_is_standalone_target} == 0 +.if (${__target} != "installincludes" && ${__target} != "includes") || \ + ${__have_incs_${__dir}} != "no" || defined(_SANITY_CHECK_INCS) ${__target}_subdir_${DIRPRFX}${__dir}: .PHONY .MAKE .SILENT ${__deps} @${_+_}target=${__target:realinstall=install}; \ - dir=${__dir}; \ + dir=${__dir}; have_incs=${__have_incs_${__dir}}; \ ${_SUBDIR_SH}; __subdir_targets+= ${__target}_subdir_${DIRPRFX}${__dir} +.endif .endif # ${__dir} == .WAIT .endfor # __dir in ${SUBDIR} Index: stand/Makefile =================================================================== --- stand/Makefile +++ stand/Makefile @@ -38,4 +38,7 @@ .endif .endfor +# Skip make includes for this part of the tree +SUBDIR_WITH_INCS= + .include Index: tests/Makefile =================================================================== --- tests/Makefile +++ tests/Makefile @@ -12,6 +12,8 @@ SUBDIR+= sys SUBDIR_PARALLEL= +# Skip make includes for this part of the tree +SUBDIR_WITH_INCS= afterinstall: install-tests-local install-tests-local: .PHONY Index: usr.bin/Makefile =================================================================== --- usr.bin/Makefile +++ usr.bin/Makefile @@ -298,5 +298,7 @@ .include SUBDIR_PARALLEL= +# Only lex installs includes, skip it for all other directories +SUBDIR_WITH_INCS=lex .include Index: usr.sbin/Makefile =================================================================== --- usr.sbin/Makefile +++ usr.sbin/Makefile @@ -221,5 +221,7 @@ .include SUBDIR_PARALLEL= +# Only bsnmpd/modules installs includes. +SUBDIR_WITH_INCS= bsnmpd .include Index: usr.sbin/bsnmpd/Makefile =================================================================== --- usr.sbin/bsnmpd/Makefile +++ usr.sbin/bsnmpd/Makefile @@ -5,4 +5,5 @@ modules \ tools +SUBDIR_WITH_INCS= modules .include