SRC_DIRS=$(shell dirname $(shell find . -name Makefile | grep src/Makefile | grep -v _working_ ))
CLEAN_CMD=$(foreach subdir, $(SRC_DIRS), clean-rule/$(subdir))
DISTCLEAN_CMD=$(foreach subdir, $(SRC_DIRS), distclean-rule/$(subdir))
SHELL:= /bin/bash

clean: $(CLEAN_CMD)

clean-rule/%:
	@if [[ -d $* ]]; then \
		echo "Clean $*"; \
		$(MAKE) -C $* clean; \
	fi

distclean: $(DISTCLEAN_CMD)

distclean-rule/%:
	@if [[ -d $* ]]; then \
		echo "Distclean $*"; \
		$(MAKE) -C $* distclean; \
	fi
