diff --git a/Makefile b/Makefile
index 40d47a87ee2002fd04436c442358e4ff145f5c51..7b4477c91beecc23b401d400237a193c02f8c409 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,39 @@
-include Makefile.include
+CXXFLAGS = -Wall
 
 ifeq ($(shell uname -o), Cygwin)
-	DYNARE_M = dynare_m.exe
+# Detection of uninitialized variables is buggy in Cygwin and generates spurious warnings
+CXXFLAGS += -Wno-uninitialized
+CXXFLAGS += -mno-cygwin
+endif
+
+ifeq ($(CROSS_WIN32), yes)
+CXX = i586-mingw32msvc-g++
+AR = i586-mingw32msvc-ar
+# Detection of uninitialized variables is buggy in MinGW and generates spurious warnings
+CXXFLAGS += -Wno-uninitialized
+endif
+
+ifeq ($(DEBUG),yes)
+CXXFLAGS += -ggdb
 else
-	DYNARE_M = dynare_m
+CXXFLAGS += -O3
+endif
+
+ifeq ($(VALGRIND), yes)
+CXXFLAGS = -Wall -O -g -fno-inline
+endif
+
+ifeq ($(shell uname -o), Cygwin)
+DYNARE_M = dynare_m.exe
+else
+DYNARE_M = dynare_m
 endif
 
 ifeq ($(CROSS_WIN32), yes)
-	DYNARE_M = dynare_m.exe
+DYNARE_M = dynare_m.exe
 endif
 
-OBJS = \
+MAIN_OBJS = \
 	DynareFlex.o \
 	DynareBison.o \
 	ComputingTasks.o \
@@ -36,35 +59,65 @@ OBJS = \
 	DynareMain.o \
 	DynareMain2.o
 
+MACRO_OBJS = \
+	macro/MacroFlex.o \
+	macro/MacroBison.o \
+	macro/MacroDriver.o \
+	macro/MacroValue.o
+
+$(MAIN_OBJS) $(MAIN_OBJS:.o=.d): CPPFLAGS = -Iinclude
 
-# Build rules
 
-all: all-recursive $(DYNARE_M)
+# Build rules
 
-all-recursive:
-	make -C macro
+.PHONY: all
+all: $(DYNARE_M)
 
-$(DYNARE_M): $(OBJS) macro/libmacro.a
-	$(CXX) $(CXXFLAGS) -o $(DYNARE_M) $(OBJS) -Lmacro -lmacro
+$(DYNARE_M): $(MAIN_OBJS) $(MACRO_OBJS)
+	$(CXX) $(CXXFLAGS) -o $(DYNARE_M) $(MAIN_OBJS) $(MACRO_OBJS)
 	cp $(DYNARE_M) ../matlab/
 
 
-# Dependencies
-
--include $(OBJS:.o=.P)
+# Build rules for Flex and Bison files
 
-DynareFlex.cc: DynareFlex.ll include/DynareBison.hh include/ParsingDriver.hh
+DynareFlex.cc: DynareFlex.ll
 	flex -oDynareFlex.cc DynareFlex.ll
 
-DynareBison.cc include/DynareBison.hh: DynareBison.yy include/ParsingDriver.hh
+DynareBison.cc include/DynareBison.hh include/location.hh include/stack.hh include/position.hh: DynareBison.yy
 	bison --verbose -o DynareBison.cc DynareBison.yy
 	mv DynareBison.hh location.hh stack.hh position.hh include/
 
+macro/MacroFlex.cc: macro/MacroFlex.ll
+	cd macro && flex -oMacroFlex.cc MacroFlex.ll
+
+macro/MacroBison.cc macro/MacroBison.hh macro/location.hh macro/stack.hh macro/position.hh: macro/MacroBison.yy
+	cd macro && bison --verbose -o MacroBison.cc MacroBison.yy
+
+
+# Dependencies
+
+# General rule for creating per-source dependencies Makefile
+# We use -MG to avoid failing on generated headers (MacroBison.hh, DynareBison.hh)
+# As a consequence, these headers are included without path-prefix
+%.d: %.cc
+	@set -e; rm -f $@; \
+	 $(CXX) -MM -MG $(CPPFLAGS) $< > $@.$$$$; \
+	 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
+	 rm -f $@.$$$$
+
+# These files are included in the .d files without their path, so we force them
+vpath DynareBison.hh include
+vpath MacroBison.hh macro
+
+-include $(MAIN_OBJS:.o=.d)
+-include $(MACRO_OBJS:.o=.d)
+
 
 # Clean
 
-clean: clean-recursive
-	rm -f *.o *.P \
+.PHONY: clean
+clean:
+	rm -f *.o *.d \
 		*~ include/*~ \
 		DynareFlex.cc \
 		DynareBison.output \
@@ -74,8 +127,11 @@ clean: clean-recursive
 		include/location.hh \
 		include/DynareBison.hh \
 		$(DYNARE_M)
-
-clean-recursive:
-	make -C macro clean
-
-.PHONY: all all-recursive clean clean-recursive
+	cd macro && rm -f *.o *.d *~ \
+		MacroFlex.cc \
+		MacroBison.output \
+		MacroBison.cc \
+		MacroBison.hh \
+		location.hh \
+		stack.hh \
+		position.hh
diff --git a/Makefile.include b/Makefile.include
deleted file mode 100644
index 0a3cdbc46175b2d5d8075e428760ed30216b9100..0000000000000000000000000000000000000000
--- a/Makefile.include
+++ /dev/null
@@ -1,36 +0,0 @@
-CXXFLAGS = -Wall
-
-ifeq ($(shell uname -o), Cygwin)
-	# Detection of uninitialized variables is buggy in Cygwin and generates spurious warnings
-	CXXFLAGS += -Wno-uninitialized
-	CXXFLAGS += -mno-cygwin
-endif
-
-ifeq ($(CROSS_WIN32), yes)
-	CXX = i586-mingw32msvc-g++
-	AR = i586-mingw32msvc-ar
-	# Detection of uninitialized variables is buggy in MinGW and generates spurious warnings
-	CXXFLAGS += -Wno-uninitialized
-endif
-
-ifeq ($(DEBUG),yes)
-	CXXFLAGS += -ggdb
-else
-	CXXFLAGS += -O3
-endif
-
-ifeq ($(VALGRIND), yes)
-	CXXFLAGS = -Wall -O -g -fno-inline
-endif
-
-# General rule for compilation
-%.o : %.cc
-	$(CXX) $(CXXFLAGS) -MD -I include -c $<
-	@cp $*.d $*.P; \
-	  sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-	      -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
-	  rm -f $*.d
-
-# Local variables:
-# mode: makefile
-# End:
diff --git a/macro/Makefile b/macro/Makefile
deleted file mode 100644
index 8ce93aa98a5509018d63bbec1b6304499ac27967..0000000000000000000000000000000000000000
--- a/macro/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-include ../Makefile.include
-
-OBJ = MacroFlex.o MacroBison.o MacroDriver.o MacroValue.o
-
-libmacro.a: $(OBJ)
-	$(AR) crs libmacro.a $(OBJ)
-
--include $(OBJ:.o=.P)
-
-MacroFlex.cc: MacroFlex.ll MacroBison.hh MacroDriver.hh
-	flex -oMacroFlex.cc MacroFlex.ll
-
-MacroBison.cc MacroBison.hh: MacroBison.yy MacroDriver.hh
-	bison --verbose -o MacroBison.cc MacroBison.yy
-
-clean: 
-	rm -f *.o *.P *~ \
-		MacroFlex.cc \
-		MacroBison.output \
-		MacroBison.cc \
-		MacroBison.hh \
-		location.hh \
-		stack.hh \
-		position.hh \
-		libmacro.a
-
-.PHONY: clean