diff --git a/Makefile b/Makefile index 70644eea..e364f654 100755 --- a/Makefile +++ b/Makefile @@ -93,6 +93,7 @@ include make/clean.mk include make/crosstool.mk include make/development-tools.mk include make/ffmpeg-$(BOXTYPE).mk +include make/helpers.mk include make/gstreamer.mk include make/image-updates.mk include make/images.mk diff --git a/make/helpers.mk b/make/helpers.mk new file mode 100644 index 00000000..94bd714e --- /dev/null +++ b/make/helpers.mk @@ -0,0 +1,88 @@ +# +# makefile to keep buildsystem helpers +# +# ----------------------------------------------------------------------------- + +archives-list: + @rm -f $(BUILD_TMP)/$@ + @make -qp | grep --only-matching '^\$(ARCHIVE).*:' | sed "s|:||g" > $(BUILD_TMP)/$@ + +DOCLEANUP ?= no +GETMISSING ?= no +archives-info: archives-list + @echo "[ ** ] Unused targets in make/archives.mk" + @grep --only-matching '^\$$(ARCHIVE).*:' make/archives.mk | sed "s|:||g" | \ + while read target; do \ + found=false; \ + for makefile in make/*.mk; do \ + if [ "$${makefile##*/}" = "archives.mk" ]; then \ + continue; \ + fi; \ + if [ "$${makefile: -9}" = "-extra.mk" ]; then \ + continue; \ + fi; \ + if grep -q "$$target" $$makefile; then \ + found=true; \ + fi; \ + if [ "$$found" = "true" ]; then \ + continue; \ + fi; \ + done; \ + if [ "$$found" = "false" ]; then \ + echo -e "[$(TERM_RED) !! $(TERM_NORMAL)] $$target"; \ + fi; \ + done; + @echo "[ ** ] Unused archives" + @find $(ARCHIVE)/ -maxdepth 1 -type f | \ + while read archive; do \ + if ! grep -q $$archive $(BUILD_TMP)/archives-list; then \ + echo -e "[$(TERM_YELLOW) rm $(TERM_NORMAL)] $$archive"; \ + if [ "$(DOCLEANUP)" = "yes" ]; then \ + rm $$archive; \ + fi; \ + fi; \ + done; + @echo "[ ** ] Missing archives" + @cat $(BUILD_TMP)/archives-list | \ + while read archive; do \ + if [ -e $$archive ]; then \ + #echo -e "[$(TERM_GREEN) ok $(TERM_NORMAL)] $$archive"; \ + true; \ + else \ + echo -e "[$(TERM_YELLOW) -- $(TERM_NORMAL)] $$archive"; \ + if [ "$(GETMISSING)" = "yes" ]; then \ + make $$archive; \ + fi; \ + fi; \ + done; + @$(REMOVE)/archives-list + +# ----------------------------------------------------------------------------- + +# FIXME - how to resolve variables while grepping makefiles? +patches-info: + @echo "[ ** ] Unused patches" + @for patch in $(PATCHES)/*; do \ + if [ ! -f $$patch ]; then \ + continue; \ + fi; \ + patch=$${patch##*/}; \ + found=false; \ + for makefile in make/*.mk; do \ + if grep -q "$$patch" $$makefile; then \ + found=true; \ + fi; \ + if [ "$$found" = "true" ]; then \ + continue; \ + fi; \ + done; \ + if [ "$$found" = "false" ]; then \ + echo -e "[$(TERM_RED) !! $(TERM_NORMAL)] $$patch"; \ + fi; \ + done; + +# ----------------------------------------------------------------------------- + +PHONY += archives-list +PHONY += archives-info +PHONY += patches-info diff --git a/make/prerequisites.mk b/make/prerequisites.mk index ad208425..acfd5494 100644 --- a/make/prerequisites.mk +++ b/make/prerequisites.mk @@ -147,90 +147,9 @@ ni-sources: $(SOURCE_DIR) \ # ----------------------------------------------------------------------------- -archives-list: - @rm -f $(BUILD_TMP)/$@ - @make -qp | grep --only-matching '^\$(ARCHIVE).*:' | sed "s|:||g" > $(BUILD_TMP)/$@ - -DOCLEANUP ?= no -GETMISSING ?= no -archives-info: archives-list - @echo "[ ** ] Unused targets in make/archives.mk" - @grep --only-matching '^\$$(ARCHIVE).*:' make/archives.mk | sed "s|:||g" | \ - while read target; do \ - found=false; \ - for makefile in make/*.mk; do \ - if [ "$${makefile##*/}" = "archives.mk" ]; then \ - continue; \ - fi; \ - if [ "$${makefile: -9}" = "-extra.mk" ]; then \ - continue; \ - fi; \ - if grep -q "$$target" $$makefile; then \ - found=true; \ - fi; \ - if [ "$$found" = "true" ]; then \ - continue; \ - fi; \ - done; \ - if [ "$$found" = "false" ]; then \ - echo -e "[$(TERM_RED) !! $(TERM_NORMAL)] $$target"; \ - fi; \ - done; - @echo "[ ** ] Unused archives" - @find $(ARCHIVE)/ -maxdepth 1 -type f | \ - while read archive; do \ - if ! grep -q $$archive $(BUILD_TMP)/archives-list; then \ - echo -e "[$(TERM_YELLOW) rm $(TERM_NORMAL)] $$archive"; \ - if [ "$(DOCLEANUP)" = "yes" ]; then \ - rm $$archive; \ - fi; \ - fi; \ - done; - @echo "[ ** ] Missing archives" - @cat $(BUILD_TMP)/archives-list | \ - while read archive; do \ - if [ -e $$archive ]; then \ - #echo -e "[$(TERM_GREEN) ok $(TERM_NORMAL)] $$archive"; \ - true; \ - else \ - echo -e "[$(TERM_YELLOW) -- $(TERM_NORMAL)] $$archive"; \ - if [ "$(GETMISSING)" = "yes" ]; then \ - make $$archive; \ - fi; \ - fi; \ - done; - @$(REMOVE)/archives-list - -# FIXME - how to resolve variables while grepping makefiles? -patches-info: - @echo "[ ** ] Unused patches" - @for patch in $(PATCHES)/*; do \ - if [ ! -f $$patch ]; then \ - continue; \ - fi; \ - patch=$${patch##*/}; \ - found=false; \ - for makefile in make/*.mk; do \ - if grep -q "$$patch" $$makefile; then \ - found=true; \ - fi; \ - if [ "$$found" = "true" ]; then \ - continue; \ - fi; \ - done; \ - if [ "$$found" = "false" ]; then \ - echo -e "[$(TERM_RED) !! $(TERM_NORMAL)] $$patch"; \ - fi; \ - done; - -# ----------------------------------------------------------------------------- - PHONY += init PHONY += find-% PHONY += toolcheck PHONY += bashcheck PHONY += preqs PHONY += ni-sources -PHONY += archives-list -PHONY += archives-info -PHONY += patches-info