Make sure that get_type_alignment() is not passed a typedef.
[cparser] / Makefile
index 1f8c7b1..2a96248 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,23 @@
--include config.mak
-
 GOAL = $(BUILDDIR)/cparser
 
 BUILDDIR ?= build
+variant  ?= debug# Different libfirm variants (debug, optimize, profile)
 
-FIRM_CFLAGS ?= `pkg-config --cflags libfirm`
-FIRM_LIBS   ?= `pkg-config --libs libfirm`
+FIRM_HOME   = libfirm
+FIRM_CPPFLAGS = -I$(FIRM_HOME)/include
+FIRM_LIBS   = -lm
+LIBFIRM_FILE = build/$(variant)/libfirm.a
+FIRM_VERSION = 1.19.1
+FIRM_URL = http://downloads.sourceforge.net/project/libfirm/libfirm/$(FIRM_VERSION)/libfirm-$(FIRM_VERSION).tar.bz2?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Flibfirm%2Ffiles%2Flibfirm%2F&ts=1299786346&use_mirror=ignum
 
-CPPFLAGS  = -DHAVE_CONFIG_H -DFIRM_BACKEND
-CPPFLAGS += -I.
-CPPFLAGS += $(FIRM_CFLAGS)
+CPPFLAGS  = -I.
+CPPFLAGS += $(FIRM_CPPFLAGS)
 
-CFLAGS += -Wall -W -Wstrict-prototypes -Wmissing-prototypes -Werror -std=c99 -pedantic
-CFLAGS += -O0 -g3
+CFLAGS += -Wall -W -Wstrict-prototypes -Wmissing-prototypes -std=c99 -pedantic
+CFLAGS += -O2 -g
 #CFLAGS += -O3 -march=pentium4 -fomit-frame-pointer -DNDEBUG
 #CFLAGS += -pg -O3 -fno-inline
-ICC_CFLAGS = -O0 -g3 -std=c99 -Wall -Werror
+ICC_CFLAGS = -O0 -g3 -std=c99 -Wall
 #LFLAGS += -pg
 ICC    ?= true
 GCCO1  ?= true
@@ -25,67 +27,90 @@ LFLAGS += $(FIRM_LIBS)
 SOURCES := \
        adt/hashset.c \
        adt/strset.c \
-       adt/obstack.c \
-       adt/obstack_printf.c \
-       adt/xmalloc.c \
+       attribute.c \
+       parser.c \
        ast.c \
        ast2firm.c \
+       builtins.c \
        diagnostic.c \
+       driver/firm_machine.c \
+       driver/firm_opt.c \
+       driver/firm_timing.c \
+       entity.c \
        entitymap.c \
        format_check.c \
+       input.c \
        lexer.c \
        main.c \
-       parser.c \
+       mangle.c \
+       preprocessor.c \
+       printer.c \
        symbol_table.c \
        token.c \
        type.c \
-       types.c \
        type_hash.c \
+       types.c \
+       help.c \
        warning.c \
-       write_fluffy.c \
-       driver/firm_cmdline.c \
-       driver/firm_timing.c \
-       driver/firm_codegen.c \
-       driver/firm_opt.c \
-       driver/gen_firm_asm.c \
+       walk.c \
+       wrappergen/write_fluffy.c \
+       wrappergen/write_jna.c
 
 OBJECTS = $(SOURCES:%.c=build/%.o)
 
 SPLINTS = $(addsuffix .splint, $(SOURCES))
 CPARSERS = $(addsuffix .cparser, $(SOURCES))
 CPARSEROS = $(SOURCES:%.c=build/cpb/%.o)
+CPARSEROS_E = $(SOURCES:%.c=build/cpbe/%.o)
 CPARSEROS2 = $(SOURCES:%.c=build/cpb2/%.o)
 
 Q = @
 
-all: $(DIRS) $(GOAL)
+all: $(GOAL)
 
-.PHONY: all clean dirs bootstrap bootstrap2
+.PHONY: all clean bootstrap bootstrap2 $(FIRM_HOME)/$(LIBFIRM_FILE)
 
 ifeq ($(findstring $(MAKECMDGOALS), clean depend),)
 -include .depend
 endif
 
+config.h:
+       cp config.h.in $@
+
 %.h:
        @true
 
-.depend: $(SOURCES)
-       @echo "#define cparser_REVISION \"`svnversion -n .`\"" > .revision.h
+REVISION ?= $(shell git describe --always --dirty --match '')
+
+revision.h:
+       @echo "===> GEN $@"
+       @echo "#define cparser_REVISION \"$(REVISION)\"" > .revision.h
        $(Q)if diff -Nq .revision.h revision.h > /dev/null; then \
              rm .revision.h;                                    \
            else                                                 \
              echo "===> UPDATING revision.h";                   \
              mv .revision.h revision.h;                         \
            fi
+
+.depend: config.h revision.h $(SOURCES)
        @echo "===> DEPEND"
        @rm -f $@ && touch $@ && makedepend -p "$@ build/" -Y -f $@ -- $(CPPFLAGS) -- $(SOURCES) 2> /dev/null && rm $@.bak
 
-DIRS = build build/adt build/driver build/cpb build/cpb/adt build/cpb/driver build/cpb2 build/cpb2/adt build/cpb2/driver
+DIRS = build build/adt build/driver build/wrappergen build/cpb build/cpb/adt build/cpb/driver build/cpb/wrappergen build/cpb2 build/cpb2/adt build/cpb2/driver build/cpb2/wrappergen build/cpbe build/cpbe/adt build/cpbe/driver build/cpbe2/wrappergen
 UNUSED := $(shell mkdir -p $(DIRS))
 
-$(GOAL): $(OBJECTS)
+$(FIRM_HOME)/$(LIBFIRM_FILE):
+ifeq "$(wildcard $(FIRM_HOME) )" ""
+       @echo 'Download and extract libfirm tarball ...'
+       $(Q)curl -s -L "${FIRM_URL}" -o "libfirm-$(FIRM_VERSION).tar.bz2"
+       $(Q)tar xf "libfirm-$(FIRM_VERSION).tar.bz2"
+       $(Q)mv "libfirm-$(FIRM_VERSION)" libfirm
+endif
+       cd libfirm && $(MAKE) $(LIBFIRM_FILE)
+
+$(GOAL): $(FIRM_HOME)/$(LIBFIRM_FILE) $(OBJECTS)
        @echo "===> LD $@"
-       $(Q)$(CC) $(OBJECTS) $(LFLAGS) -o $(GOAL)
+       $(Q)$(CC) $(OBJECTS) $(LFLAGS) $(FIRM_HOME)/$(LIBFIRM_FILE) -o $(GOAL)
 
 splint: $(SPLINTS)
 
@@ -93,6 +118,8 @@ selfcheck: $(CPARSERS)
 
 bootstrap: build/cpb build/cpb/adt build/cpb/driver $(CPARSEROS) cparser.bootstrap
 
+bootstrape: build/cpb build/cpb/adt build/cpb/driver $(CPARSEROS_E) cparser.bootstrape
+
 bootstrap2: build/cpb2 build/cpb2/adt build/cpb2/driver $(CPARSEROS2) cparser.bootstrap2
 
 %.c.splint: %.c
@@ -103,13 +130,13 @@ bootstrap2: build/cpb2 build/cpb2/adt build/cpb2/driver $(CPARSEROS2) cparser.bo
        @echo '===> CPARSER $<'
        $(Q)./cparser $(CPPFLAGS) -fsyntax-only $<
 
-$(DIRS):
-       @echo "===> MKDIR $@"
-       $(Q)mkdir -p $@
-
 build/cpb/%.o: %.c build/cparser
        @echo '===> CPARSER $<'
-       $(Q)./build/cparser $(CPPFLAGS) -Wall -g3 -c $< -o $@
+       $(Q)./build/cparser $(CPPFLAGS) -std=c99 -Wall -g3 -c $< -o $@
+
+build/cpbe/%.o: %.c
+       @echo '===> ECCP $<'
+       $(Q)eccp $(CPPFLAGS) -std=c99 -Wall -c $< -o $@
 
 build/cpb2/%.o: %.c cparser.bootstrap
        @echo '===> CPARSER.BOOTSTRAP $<'
@@ -119,14 +146,18 @@ cparser.bootstrap: $(CPARSEROS)
        @echo "===> LD $@"
        $(Q)./build/cparser $(CPARSEROS) $(LFLAGS) -o $@
 
+cparser.bootstrape: $(CPARSEROS_E)
+       @echo "===> LD $@"
+       $(Q)gcc $(CPARSEROS_E) $(LFLAGS) -o $@
+
 cparser.bootstrap2: $(CPARSEROS2)
        @echo "===> LD $@"
        $(Q)./cparser.bootstrap $(CPARSEROS2) $(LFLAGS) -o $@
 
 build/%.o: %.c
        @echo '===> CC $<'
-       $(Q)$(ICC) $(CPPFLAGS) $(ICC_CFLAGS) -c $< -o $@
-       $(Q)$(GCCO1) $(CPPFLAGS) $(CFLAGS) -O1 -c $< -o $@
+#$(Q)$(ICC) $(CPPFLAGS) $(ICC_CFLAGS) -c $< -o $@
+#$(Q)$(GCCO1) $(CPPFLAGS) $(CFLAGS) -O1 -c $< -o $@
        $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
 
 clean: