Remove duplicate flags for ar.
[libfirm] / Makefile
index d17d8a7..719474f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -20,14 +20,15 @@ Q ?= @
 
 CC ?= cc
 LINK ?= $(CC)
-AR ?= ar ru
-RANLIB ?= ranlib
+AR ?= ar
+DLLEXT ?= .so
 
 # Variants
-CFLAGS_debug      = -O0 -g3 -DDEBUG_libfirm
-CFLAGS_profile    = -O3 -pg -DNDEBUG -fno-inline
+CFLAGS_all        = -fPIC
+CFLAGS_debug      = $(CFLAGS_all) -O0 -g3 -DDEBUG_libfirm
+CFLAGS_profile    = $(CFLAGS_all) -O3 -pg -DNDEBUG -fno-inline
 LINKFLAGS_profile = -pg
-CFLAGS_optimize   = -O3 -DNDEBUG
+CFLAGS_optimize   = $(CFLAGS_all) -O3 -DNDEBUG
 
 # General flags
 CFLAGS    += $(CFLAGS_$(variant))
@@ -35,9 +36,22 @@ CFLAGS    += -Wall -W -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wwrite-s
 LINKFLAGS += $(LINKFLAGS_$(variant))
 VPATH = $(srcdir)
 
+REVISION ?= $(shell git describe --abbrev=40 --always --dirty --match '')
+
+# Update revision.h if necessary
+UNUSED := $(shell \
+       REV="\#define libfirm_VERSION_REVISION \"$(REVISION)\""; \
+       echo "$$REV" | cmp -s - firm_revision.h 2> /dev/null || echo "$$REV" > firm_revision.h \
+)
+
 .PHONY: all
 all: firm
 
+# This rule is necessary so that make does not abort if headers get deleted
+# (the deleted header might still be referenced in a .d file)
+%.h:
+       @:
+
 # A very naive way to create a config.h if it is missing
 $(srcdir)config.h:
        @echo MakeConfig $@
@@ -45,8 +59,6 @@ $(srcdir)config.h:
        $(Q)echo "#define libfirm_VERSION_MAJOR 1" >> $@
        $(Q)echo "#define libfirm_VERSION_MICRO 0" >> $@
        $(Q)echo "#define libfirm_VERSION_MINOR 20" >> $@
-       $(Q)echo "#define HAVE_LONG_DOUBLE 1" >> $@
-       $(Q)echo "#define FIRM_STATISTICS" >> $@
 
 # libFirm
 libfirm_DIRS := \
@@ -62,27 +74,29 @@ libfirm_DIRS := \
        ir/ir      \
        ir/lower   \
        ir/libcore \
+       ir/lpp     \
        ir/opt     \
        ir/st      \
        ir/stat    \
        ir/tr      \
        ir/tv      \
+       ir/kaps    \
        ir/be
 libfirm_SOURCES  = $(foreach dir,$(libfirm_DIRS),$(wildcard $(dir)/*.c))
 libfirm_a        = $(builddir)/libfirm.a
-libfirm_so       = $(builddir)/libfirm.so
+libfirm_dll      = $(builddir)/libfirm$(DLLEXT)
 libfirm_CPPFLAGS = -Iinclude/libfirm -Iinclude/libfirm/adt -I. $(foreach dir,$(libfirm_DIRS),-I$(dir))
 
 .PHONY: firm
-firm: $(libfirm_so)
+firm: $(libfirm_dll)
 
 # backends
 backends = amd64 arm ia32 sparc TEMPLATE
 
 EMITTER_GENERATOR = $(srcdir)ir/be/scripts/generate_emitter.pl
+EMITTER_GENERATOR2 = $(srcdir)ir/be/scripts/generate_emitter_new.pl
 REGALLOC_IF_GENERATOR = $(srcdir)ir/be/scripts/generate_regalloc_if.pl
 OPCODES_GENERATOR = $(srcdir)ir/be/scripts/generate_new_opcodes.pl
-MACHINE_GENERATOR = $(srcdir)ir/be/scripts/generate_machine.pl
 
 define backend_template
 $(1)_SOURCES = $$(wildcard ir/be/$(1)/*.c)
@@ -91,7 +105,7 @@ $(1)_GEN_HEADERS =
 
 $(1)_SPEC = ir/be/$(1)/$(1)_spec.pl
 
-$$(srcdir)ir/be/$(1)/gen_$(1)_emitter.h $$(srcdir)ir/be/$(1)/gen_$(1)_emitter.c: $$($(1)_SPEC) $$(EMITTER_GENERATOR)
+$$(srcdir)ir/be/$(1)/gen_$(1)_emitter.h $$(srcdir)ir/be/$(1)/gen_$(1)_emitter.c: $$($(1)_SPEC) $$(EMITTER_GENERATOR) $(EMITTER_GENERATOR2)
        @echo GEN $$@
        $(Q)$$(EMITTER_GENERATOR) $$($(1)_SPEC) $$(srcdir)ir/be/$(1)
 $(1)_SOURCES += ir/be/$(1)/gen_$(1)_emitter.c
@@ -103,12 +117,6 @@ $$(srcdir)ir/be/$(1)/gen_$(1)_regalloc_if.h $$(srcdir)ir/be/$(1)/gen_$(1)_regall
 $(1)_SOURCES += ir/be/$(1)/gen_$(1)_regalloc_if.c
 $(1)_GEN_HEADERS += ir/be/$(1)/gen_$(1)_regalloc_if.h
 
-$$(srcdir)ir/be/$(1)/gen_$(1)_machine.h $$(srcdir)ir/be/$(1)/gen_$(1)_machine.c: $$($(1)_SPEC) $$(MACHINE_GENERATOR)
-       @echo GEN $$@
-       $(Q)$$(MACHINE_GENERATOR) $$($(1)_SPEC) $$(srcdir)ir/be/$(1)
-$(1)_SOURCES += ir/be/$(1)/gen_$(1)_machine.c
-$(1)_GEN_HEADERS += ir/be/$(1)/gen_$(1)_machine.h
-
 $$(srcdir)ir/be/$(1)/gen_$(1)_new_nodes.h $$(srcdir)ir/be/$(1)/gen_$(1)_new_nodes.c.inl: $$($(1)_SPEC) $$(OPCODES_GENERATOR)
        @echo GEN $$@
        $(Q)$$(OPCODES_GENERATOR) $$($(1)_SPEC) $$(srcdir)ir/be/$(1)
@@ -142,10 +150,7 @@ $(IR_SPEC_GENERATED_FILES): $(IR_SPEC_GENERATOR) $(IR_SPEC) scripts/spec_util.py
        $(Q)$(IR_SPEC_GENERATOR) $(IR_SPEC) ir/ir
 
 IR_IO_GENERATOR := scripts/gen_ir_io.py
-IR_IO_GENERATED_FILES := \
-       ir/ir/gen_irio_import.inl \
-       ir/ir/gen_irio_export.inl \
-       ir/ir/gen_irio_lex.inl
+IR_IO_GENERATED_FILES := ir/ir/gen_irio.inl
 
 $(IR_IO_GENERATED_FILES): $(IR_IO_GENERATOR) $(IR_SPEC) scripts/spec_util.py
        @echo GEN $@
@@ -160,10 +165,8 @@ libfirm_DEPS    = $(libfirm_OBJECTS:%.o=%.d)
 $(libfirm_a): $(libfirm_OBJECTS)
        @echo AR $@
        $(Q)$(AR) ru $@ $^
-       @echo RANLIB $@
-       $(Q)$(RANLIB) $@
 
-$(libfirm_so): $(libfirm_OBJECTS)
+$(libfirm_dll): $(libfirm_OBJECTS)
        @echo LINK $@
        $(Q)$(LINK) -shared -o $@ $^
 
@@ -178,3 +181,4 @@ clean:
        @echo CLEAN
        $(Q)rm -f $(libfirm_OBJECTS)
        $(Q)rm -f $(libfirm_TARGET)
+       $(Q)rm -f $(shell find ir/ -name "gen_*.[ch]")