diff --git a/GMLMIP-0.1/makefile b/GMLMIP-0.1/makefile
index 2493ce4219a5965e71ef35d46eae28390b67044b..41b0b348d496707461b1785c5212678a11dd0625 100644
--- a/GMLMIP-0.1/makefile
+++ b/GMLMIP-0.1/makefile
@@ -4,20 +4,26 @@ GCCFLAGS = -Wall -Wno-deprecated
 POBJS = ./parser/lex.yy.o ./parser/mlf-parser.tab.o ./parser/mlf-driver.o
 FOBJS = ./formulas/formula.o ./formulas/GML_formula.o ./formulas/PML_formula.o ./formulas/rational.o ./formulas/satisfyingassignment.o
 ROBJS = ./rules/premise.o ./rules/GML_premise.o ./rules/PML_premise.o ./rules/valuation.o ./rules/setofconclusions.o ./rules/sizefunctions.o ./rules/radixtree.o
-SUBDIRS = parser formulas rules
+
+HEADERS = parser/mlf-parser.tab.h \
+parser/mlf-driver.h     \
+formulas/formula.h      \
+formulas/satisfyingassignment.h \
+parser/lex.yy.h
 
 .PHONY: all clean parser formulas rules
 
 all: main onestep
 
-parser:
-	make -C parser
+parser/%:
+	make -C parser/ $(@:parser/%=%)
+
+formulas/%:
+	make -C formulas/ $(@:formulas/%=%)
 
-formulas:
-	make -C formulas
+rules/%:
+	make -C rules/ $(@:rules/%=%)
 
-rules:
-	make -C rules
 
 main: main.o $(POBJS) $(FOBJS) $(ROBJS)
 	$(GCC) $(GCCFLAGS) $(POBJS) $(FOBJS) $(ROBJS) -lbdd -lm -lglpk $< -o $@
@@ -26,14 +32,11 @@ onestep: onestep.o $(POBJS) $(FOBJS) $(ROBJS)
 	$(GCC) $(GCCFLAGS) $(POBJS) $(FOBJS) $(ROBJS) -lbdd -lm -lglpk $< -o $@
 
 
-main.o: main.cpp ./parser/mlf-driver.h ./formulas/formula.h ./formulas/satisfyingassignment.h $(SUBDIRS)
+main.o: main.cpp $(HEADERS)
 	$(GCC) $(GCCFLAGS) -c $< -o $@
 
-onestep.o: onestep.cpp ./parser/mlf-driver.h ./formulas/formula.h ./formulas/satisfyingassignment.h $(SUBDIRS)
+onestep.o: onestep.cpp $(HEADERS)
 	$(GCC) $(GCCFLAGS) -c $<
 
-clean:
+clean: parser/clean formulas/clean rules/clean
 	rm -rf *.o main
-	make -C parser clean
-	make -C formulas clean
-	make -C rules clean
diff --git a/GMLMIP-0.1/parser/makefile b/GMLMIP-0.1/parser/makefile
index f39e8eeaad7080b27d3b701e62434bca7d1b7fad..0f9ca9428baabf058865e9d0971e81ad4e85a4f7 100644
--- a/GMLMIP-0.1/parser/makefile
+++ b/GMLMIP-0.1/parser/makefile
@@ -4,12 +4,18 @@ GCC = g++
 
 GCCFLAGS = -Wall -Wno-deprecated
 
+.PHONY: all clean
+
 all: parser lex.yy.o mlf-parser.tab.o mlf-driver.o
 
+
+../formulas/%:
+	make -C ../formulas/ $(@:../formulas/%=%)
+
 lex.yy.o: lex.yy.h lex.yy.c
 	$(GCC) $(GCCFLAGS) -c lex.yy.c
 	
-mlf-parser.tab.o: mlf-parser.tab.h mlf-parser.tab.cc ../formulas/GML_formula.h ../formulas/PML_formula.h
+mlf-parser.tab.o: mlf-parser.tab.h mlf-parser.tab.cc ../formulas/GML_formula.h ../formulas/PML_formula.h lex.yy.h
 	$(GCC) $(GCCFLAGS) -c mlf-parser.tab.cc
 
 mlf-driver.o: mlf-driver.h mlf-driver.cpp mlf-parser.tab.h lex.yy.h ../formulas/formula.h