diff --git a/Makefile.defs b/Makefile.defs index 96404813121..74c9aa3ba91 100644 --- a/Makefile.defs +++ b/Makefile.defs @@ -529,8 +529,8 @@ endif ifneq (,$(MEM_STATS_HDR)) EXPECTED_MD5=$(shell [ -f $(MEM_STATS_HDR) ] && tail -n 1 $(MEM_STATS_HDR) | awk '{print $$4}') -MODULES_MD5=$(shell find $(dir $(MEM_STATS_HDR))/../modules -name "[Mm]akefile" | \ - awk -F/ '{print $$(NF - 1)}' | sort | $(md5sum_cmd) | awk '{print $$1}') +MODULES_MD5=$(shell find $(dir $(MEM_STATS_HDR))/../modules -maxdepth 2 -name "[Mm]akefile" | \ + awk -F/ '{print $$(NF - 1)}' | sort -u | $(md5sum_cmd) | awk '{print $$1}') ifneq ($(EXPECTED_MD5),$(MODULES_MD5)) REGENERATE_MEM_STATS=remove-mem-stats endif diff --git a/Makefile.modules b/Makefile.modules index 2708db3e81c..b01d682ba15 100644 --- a/Makefile.modules +++ b/Makefile.modules @@ -42,8 +42,8 @@ else md5sum_cmd = md5sum endif EXPECTED_MD5=$(shell [ -f $(MEM_STATS_HDR) ] && tail -n 1 $(MEM_STATS_HDR) | awk '{print $$4}') -MODULES_MD5=$(shell find $(dir $(MEM_STATS_HDR))/../modules -name "[Mm]akefile" | \ - awk -F/ '{print $$(NF - 1)}' | sort | $(md5sum_cmd) | awk '{print $$1}') +MODULES_MD5=$(shell find $(dir $(MEM_STATS_HDR))/../modules -maxdepth 2 -name "[Mm]akefile" | \ + awk -F/ '{print $$(NF - 1)}' | sort -u | $(md5sum_cmd) | awk '{print $$1}') ifneq ($(EXPECTED_MD5),$(MODULES_MD5)) REGENERATE_MEM_STATS=remove-mem-stats endif diff --git a/Makefile.rules b/Makefile.rules index 4c95c4e9b25..83db9dbb2ce 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -68,8 +68,8 @@ Makefile.conf: Makefile.conf.template # no need to generate mem/mem_stats.c from anywhere else mem/mem_stats.c: mem/mem_stats.h - @find modules/ -name "[Mm]akefile" -exec grep "NAME\s*=" {} \; \ - | awk 'BEGIN { FS = "[=\\. ]"; \ + @find modules/ -maxdepth 2 -name "[Mm]akefile" -exec grep "NAME\s*=" {} \; \ + | sort -u | awk 'BEGIN { FS = "[=\\. ]"; \ print "/* This file is auto-generated by running \"make generate-mem-stats\" */"; \ print "/* You should NOT edit this file manually */"; \ print "#ifdef SHM_EXTRA_STATS"; \ @@ -82,8 +82,8 @@ remove-mem-stats: -@rm -f $(MEM_STATS_HDR) %mem_stats.h: $(REGENERATE_MEM_STATS) - @find $(dir $@)/../modules/ -name "[Mm]akefile" -exec grep "NAME\s*=" {} \; \ - | awk 'BEGIN { FS = "[=\\. ]"; \ + @find $(dir $@)/../modules/ -maxdepth 2 -name "[Mm]akefile" -exec grep "NAME\s*=" {} \; \ + | sort -u | awk 'BEGIN { FS = "[=\\. ]"; \ print "/* This file is auto-generated by running \"make generate-mem-stats\" */"; \ print "/* You should NOT edit this file manually */"; \ print "#ifdef SHM_EXTRA_STATS"; \