From 9e2f435fc14b0121dbaa7b87b7841a0dcd209b7b Mon Sep 17 00:00:00 2001 From: Bryan Drewery Date: Wed, 31 Aug 2016 19:30:52 +0000 Subject: [PATCH] Add a 'make print-dir' that simply traverses all directories and prints them. This is useful for finding connected directories. MFC after: 1 week Sponsored by: EMC / Isilon Storage Division --- Makefile | 9 +++++++-- share/mk/bsd.dep.mk | 6 +++--- share/mk/bsd.init.mk | 2 +- share/mk/bsd.subdir.mk | 18 ++++++++++++++---- share/mk/local.meta.sys.mk | 3 ++- share/mk/sys.mk | 2 +- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index cf973dcad417..00dbc23bb79c 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,8 @@ # Note: we use this awkward construct to be compatible with FreeBSD's # old make used in 10.0 and 9.2 and earlier. -.if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && !make(showconfig) +.if defined(MK_DIRDEPS_BUILD) && ${MK_DIRDEPS_BUILD} == "yes" && \ + !make(showconfig) && !make(print-dir) # targets/Makefile plays the role of top-level .include "targets/Makefile" .else @@ -132,7 +133,7 @@ TGTS= all all-man buildenv buildenvvars buildkernel buildworld \ xdev-links native-xtools stageworld stagekernel stage-packages \ create-world-packages create-kernel-packages create-packages \ packages installconfig real-packages sign-packages package-pkg \ - test-system-compiler + print-dir test-system-compiler # XXX: r156740: This can't work since bsd.subdir.mk is not included ever. # It will only work for SUBDIR_TARGETS in make.conf. @@ -257,6 +258,10 @@ _TARGET_ARCH= ${XDEV_ARCH} _TARGET?= ${MACHINE} _TARGET_ARCH?= ${MACHINE_ARCH} +.if make(print-dir) +.SILENT: +.endif + # # Make sure we have an up-to-date make(1). Only world and buildworld # should do this as those are the initial targets used for upgrades. diff --git a/share/mk/bsd.dep.mk b/share/mk/bsd.dep.mk index f84abaa9f187..e1f35af17c6e 100644 --- a/share/mk/bsd.dep.mk +++ b/share/mk/bsd.dep.mk @@ -82,9 +82,9 @@ _meta_filemon= 1 # since it will track dependencies itself. OBJS_DEPEND_GUESS is still used. .if !empty(.MAKEFLAGS:M-V${_V_READ_DEPEND}) || make(obj) || make(clean*) || \ ${.TARGETS:M*install*} == ${.TARGETS} || \ - make(analyze) || defined(_meta_filemon) + make(analyze) || defined(_meta_filemon) || make(print-dir) _SKIP_READ_DEPEND= 1 -.if ${MK_DIRDEPS_BUILD} == "no" +.if ${MK_DIRDEPS_BUILD} == "no" || make(analyze) || make(print-dir) .MAKE.DEPENDFILE= /dev/null .endif .endif @@ -198,7 +198,7 @@ CFLAGS+= ${DEPEND_CFLAGS} .endif # !defined(_meta_filemon) .endif # defined(SRCS) -.if ${MK_DIRDEPS_BUILD} == "yes" +.if ${MK_DIRDEPS_BUILD} == "yes" && !make(analyze) && !make(print-dir) # Prevent meta.autodep.mk from tracking "local dependencies". .depend: .include diff --git a/share/mk/bsd.init.mk b/share/mk/bsd.init.mk index 25ab7625ec65..b7a45d9ac43a 100644 --- a/share/mk/bsd.init.mk +++ b/share/mk/bsd.init.mk @@ -31,7 +31,7 @@ _SKIP_BUILD = not building at level 0 .if ${MK_META_MODE} == "yes" .if !exists(/dev/filemon) && \ ${UPDATE_DEPENDFILE:Uyes:tl} != "no" && !defined(NO_FILEMON) && \ - !make(showconfig) && ${.MAKEFLAGS:M-V} == "" + !make(showconfig) && !make(print-dir) && ${.MAKEFLAGS:M-V} == "" .warning The filemon module (/dev/filemon) is not loaded. .warning META_MODE is less useful for incremental builds without filemon. .warning 'kldload filemon' or pass -DNO_FILEMON to suppress this warning. diff --git a/share/mk/bsd.subdir.mk b/share/mk/bsd.subdir.mk index dfe0afab577d..786eef1eba9c 100644 --- a/share/mk/bsd.subdir.mk +++ b/share/mk/bsd.subdir.mk @@ -42,15 +42,15 @@ SUBDIR_TARGETS+= \ all all-man analyze buildconfig buildfiles buildincludes \ checkdpadd clean cleandepend cleandir cleanilinks \ cleanobj depend distribute files includes installconfig \ - installfiles installincludes realinstall lint maninstall \ - manlint obj objlink tags \ + installfiles installincludes print-dir realinstall lint \ + maninstall manlint obj objlink tags \ # Described above. STANDALONE_SUBDIR_TARGETS+= \ all-man buildconfig buildfiles buildincludes check checkdpadd \ clean cleandepend cleandir cleanilinks cleanobj files includes \ - installconfig installincludes installfiles maninstall manlint \ - obj objlink \ + installconfig installincludes installfiles print-dir \ + maninstall manlint obj objlink # It is safe to install in parallel when staging. .if defined(NO_ROOT) @@ -59,6 +59,16 @@ STANDALONE_SUBDIR_TARGETS+= realinstall .include +.if make(print-dir) +NEED_SUBDIR= 1 +ECHODIR= : +.SILENT: +.if ${RELDIR:U.} != "." +print-dir: .PHONY + @echo ${RELDIR} +.endif +.endif + .if !defined(NEED_SUBDIR) .if ${.MAKE.LEVEL} == 0 && ${MK_DIRDEPS_BUILD} == "yes" && !empty(SUBDIR) && !(make(clean*) || make(destroy*)) .include diff --git a/share/mk/local.meta.sys.mk b/share/mk/local.meta.sys.mk index b24afd1dc38e..2ac23d613b1f 100644 --- a/share/mk/local.meta.sys.mk +++ b/share/mk/local.meta.sys.mk @@ -214,7 +214,8 @@ CSU_DIR := ${CSU_DIR.${MACHINE_ARCH}} .if !empty(TIME_STAMP) TRACER= ${TIME_STAMP} ${:U} .endif -.if !defined(_RECURSING_PROGS) && !defined(_RECURSING_CRUNCH) +.if !defined(_RECURSING_PROGS) && !defined(_RECURSING_CRUNCH) && \ + !make(print-dir) WITH_META_STATS= t .endif diff --git a/share/mk/sys.mk b/share/mk/sys.mk index 31a302b51047..dbc2fd91e372 100644 --- a/share/mk/sys.mk +++ b/share/mk/sys.mk @@ -97,7 +97,7 @@ META_MODE?= normal # This needs to be done early - before .PATH is computed # Don't do this for 'make showconfig' as it enables all options where meta mode # is not expected. -.if !make(showconfig) +.if !make(showconfig) && !make(print-dir) .sinclude .endif .endif