+$(foreach backend,$(backends),$(eval $(call backend_template,$(backend))))
+
+# generators
+IR_SPEC_GENERATED_FILES := \
+ include/libfirm/nodeops.h \
+ include/libfirm/opcodes.h \
+ ir/ir/gen_ir_cons.c.inl \
+ ir/ir/gen_irop.c.inl \
+ ir/ir/gen_irnode.c.inl \
+ ir/ir/gen_irnode.h
+IR_SPEC_GENERATOR := scripts/gen_ir.py
+IR_SPEC := scripts/ir_spec.py
+
+$(IR_SPEC_GENERATED_FILES): $(IR_SPEC_GENERATOR) $(IR_SPEC) scripts/spec_util.py
+ @echo GEN $@
+ $(Q)$(IR_SPEC_GENERATOR) $(IR_SPEC) ir/ir
+
+IR_IO_GENERATOR := scripts/gen_ir_io.py
+IR_IO_GENERATED_FILES := ir/ir/gen_irio.inl
+
+$(IR_IO_GENERATED_FILES): $(IR_IO_GENERATOR) $(IR_SPEC) scripts/spec_util.py
+ @echo GEN $@
+ $(Q)$(IR_IO_GENERATOR) $(IR_SPEC) ir/ir
+
+ir/ir/irio.c: $(IR_IO_GENERATED_FILES)
+
+libfirm_OBJECTS = $(libfirm_SOURCES:%.c=$(builddir)/%.o)
+libfirm_DEPS = $(libfirm_OBJECTS:%.o=%.d)
+-include $(libfirm_DEPS)
+
+$(libfirm_a): $(libfirm_OBJECTS)
+ @echo AR $@
+ $(Q)$(AR) -cru $@ $^
+
+$(libfirm_dll): $(libfirm_OBJECTS)
+ @echo LINK $@
+ $(Q)$(LINK) -shared $(LINKFLAGS) -o $@ $^
+
+# Generic rules
+UNUSED := $(shell mkdir -p $(libfirm_DIRS:%=$(builddir)/%))
+$(builddir)/%.o: %.c $(IR_SPEC_GENERATED_FILES) config.h
+ @echo CC $@
+ $(Q)$(CC) $(CFLAGS) $(CPPFLAGS) $(libfirm_CPPFLAGS) -MMD -c -o $@ $<
+
+$(docdir)/libfirm.tag: $(IR_SPEC_GENERATED_FILES) Doxyfile $(wildcard include/libfirm/*.h) $(wildcard include/libfirm/adt/*.h)
+ @echo Doxygen $@
+ $(Q)$(DOXYGEN)
+
+DOCU_GENERATOR := scripts/gen_docu.py
+$(docdir)/html/nodes.html: $(docdir)/libfirm.tag $(DOCU_GENERATOR) $(IR_SPEC) scripts/spec_util.py scripts/style.css
+ @echo gen_docu.py $@
+ $(Q)$(DOCU_GENERATOR) $(IR_SPEC) $(docdir)/libfirm.tag "" $@
+ $(Q)cp scripts/style.css $(docdir)/html
+
+.PHONY: doc
+doc: $(docdir)/libfirm.tag $(docdir)/html/nodes.html
+
+.PHONY: clean
+clean:
+ @echo CLEAN
+ $(Q)rm -f $(libfirm_OBJECTS)
+ $(Q)rm -f $(libfirm_TARGET)
+ $(Q)rm -f $(shell find ir/ -name "gen_*.[ch]")