diff --git a/makefile b/makefile
index baa09727a4ad59f9a4dd2a1df4022b491ef81f5a..474f166440cd4ec1924f25a5a7f6037dbfb5321e 100644
--- a/makefile
+++ b/makefile
@@ -5,6 +5,8 @@ BINFOLDER = bin
 SUBDIRS_LIBS = alib adeterminize
 SUBDIRS_BINS = acat aconvert aconvert.dot aconvert.gastex aconvert.regexp aconvert.automaton aminimize adeterminize.fsm adiff adiff.automaton adiff.grammar aepsilon
 
+SUBDIRS_WITH_MAKE = $(dir $(wildcard */makefile))
+
 .PHONY: $(SUBDIRS_LIBS) $(SUBDIRS_BINS)
 
 all: $(SUBDIRS_LIBS) $(SUBDIRS_BINS) copy
@@ -15,6 +17,11 @@ $(SUBDIRS_LIBS):
 $(SUBDIRS_BINS):
 	$(MAKE) -C $@
 
+clean:
+	for dir in $(SUBDIRS_WITH_MAKE); do \
+	    $(MAKE) -C $$dir clean; \
+	done
+
 copy:
 	mkdir -p $(BINFOLDER)
 	rm -rf $(BINFOLDER)/*