From fa92193eab4d3d9e75cdecc3d28fdf60d6df7466 Mon Sep 17 00:00:00 2001
From: Alejandro Mery <amery@geeks.cl>
Date: Sat, 26 Sep 2009 20:33:33 +0200
Subject: [PATCH] Added new global Makefile

---
 Makefile | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 Makefile

diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..04f35d8
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,19 @@
+TEMPLATES=$(wildcard root/*/*.zone.in)
+ZONES=$(addprefix stage/,$(notdir $(basename $(TEMPLATES))))
+
+.PHONY: all
+
+all: $(ZONES)
+
+root/preprocessor.sed: root/preprocessor.sh $(wildcard root/*.in) root/servers.txt
+	@$< > $@
+
+define ZONE_TEMPLATE
+stage/$(2).zone: $(1) root/preprocessor.sed
+	@echo "$(2)"
+	@sed -f root/preprocessor.sed \
+		-e 's,@@DOMAIN@@,$(2),g' \
+		$$< > $$@
+endef
+
+$(foreach tpl,$(TEMPLATES),$(eval $(call ZONE_TEMPLATE,$(tpl),$(patsubst %.zone.in,%,$(notdir $(tpl))))))