+DIRS = Legacy-2 Base-2 LambdaDelta-2
+
+SILENTMAKE = $(H)$(MAKE) $(S) --no-print-directory H=$(H) S=$(S)
+
+MAS = $(shell find $(DIRS) -mindepth 2 -name "*.ma")
+
+all: depends
+ $(H)$(RM) $(LOG)
+ $(SILENTMAKE) build
+
+opt all.opt: depends
+ $(H)$(RM) $(LOG)
+ $(SILENTMAKE) build.opt
+
+%.build.opt:
+ $(SILENTMAKE) $(patsubst %.mma, %.ma, $(shell find $* -name "*.mma"))
+ $(H)echo $*/theory.ma `$(BIN)matitadep.opt -stdout $*/theory.ma` >> depends
+
+build: $(DIRS:%=%.build.opt)
+ $(H)$(BIN)matitac $(MATITAOPTIONS) 2>> $(LOG)
+ $(H)$(RM) depends
+
+build.opt: $(DIRS:%=%.build.opt)
+ $(H)$(BIN)matitac.opt $(MATITAOPTIONS) 2>> $(LOG)
+ $(H)$(RM) depends