From: Michel Pollet Date: Tue, 22 May 2012 18:10:45 +0000 (+0100) Subject: Makefiles: Tweaked to build using clang/llvm X-Git-Tag: v1.0~119 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=438cc451e19de412a731c3ad3679589ec4ec3c38;p=sx%2Fsimavr.git Makefiles: Tweaked to build using clang/llvm Converted makefiles and tweaked to make it all work with clang etc. Welcome to the future! Signed-off-by: Michel Pollet --- diff --git a/Makefile.common b/Makefile.common index 75f687c..23dddec 100644 --- a/Makefile.common +++ b/Makefile.common @@ -30,13 +30,11 @@ ARCH = ${shell $(CC) -dumpmachine | sed -e 's/^x/i/' -e 's/\(.\).*/\1/'} CFLAGS += -O2 -Wall +CFLAGS += -g ifeq ($(ARCH), i) -CFLAGS += -mfpmath=sse -msse2 +CFLAGS += -msse2 endif -CFLAGS += -g --std=gnu99 -Wall -CFLAGS += ${patsubst %,-I%,${subst :, ,${IPATH}}} - ifeq (${shell uname}, Darwin) AVR_ROOT := "/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/" AVR_INC := ${AVR_ROOT}/avr-4/ @@ -53,7 +51,12 @@ AVR := avr- CFLAGS += -fPIC endif -CC ?= gcc +CPPFLAGS += --std=gnu99 -Wall +CPPFLAGS += ${patsubst %,-I%,${subst :, ,${IPATH}}} + +AVR_CPPFLAGS= ${CPPFLAGS} -idirafter ${AVR_INC}/include + +CC = gcc AR ?= ar RANLIB ?= ranlib MKDIR ?= mkdir -p @@ -104,22 +107,22 @@ endif # this rule has precedence ${OBJ}/sim_%.o : cores/sim_%.c ifeq ($(V),1) - $(CC) $(CFLAGS) -MMD \ - -I${AVR_INC}/include/ \ + $(CC) $(CPPFLAGS) $(CFLAGS) -MMD \ + ${AVR_CPPFLAGS} \ $< -c -o $@ else - @$(CC) $(CFLAGS) -MMD \ - -I${AVR_INC}/include/ \ + @$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS) -MMD \ + ${AVR_CPPFLAGS} \ $< -c -o $@ @echo CORE $< endif ${OBJ}/%.o: %.c ifeq ($(V),1) - $(CC) $(CFLAGS) -MMD \ + $(CC) $(CPPFLAGS) $(CFLAGS) -MMD \ $< -c -o $@ else - @$(CC) $(CFLAGS) -MMD \ + @$(CC) $(CPPFLAGS) $(CFLAGS) -MMD \ $< -c -o $@ @echo CC $< endif diff --git a/simavr/Makefile b/simavr/Makefile index 6155d5a..61e0efc 100644 --- a/simavr/Makefile +++ b/simavr/Makefile @@ -95,6 +95,12 @@ endif config: ${OBJ}/cores.deps sim_core_config.h sim_core_decl.h +# +# this tries to preprocess all the cores and decide +# which ones have a chance of compiling at all. Some platform +# ship with old version of avr-gcc and associated and needs +# to be verified +# sim_core_config.h ${OBJ}/cores.deps: $(cores) Makefile @echo CONF $@ @conf=""; decl=""; array=""; \ @@ -102,7 +108,7 @@ sim_core_config.h ${OBJ}/cores.deps: $(cores) Makefile for core in cores/*.c ; do \ file=$$core; global=$${core/cores\/sim_}; global=$${global/.c}; \ upper=$$(echo $$global|tr '[a-z]' '[A-Z]'); \ - if $(CC) -E $(CFLAGS) -I$(AVR_INC)/include $$file \ + if $(CC) -E $(CFLAGS) ${AVR_CPPFLAGS} $$file \ >/dev/null 2>&1 ; then \ conf+="#define CONFIG_$$upper 1\n"; \ obj=$${file/.c/.o} ; obj=$${obj/cores\/}; \ @@ -118,6 +124,11 @@ sim_core_config.h ${OBJ}/cores.deps: $(cores) Makefile printf "#endif\n"; \ ) >sim_core_config.h +# +# This take the config file that was generated, and create the static +# table of all available cores for name lookups, as well as a C +# config file +# sim_core_decl.h: sim_core_config.h $(cores) Makefile @echo CONF $@ @decl=""; array=""; \ diff --git a/tests/Makefile b/tests/Makefile index 922312c..7bc3d34 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -40,10 +40,10 @@ axf: ${sources:.c=.axf} ${OBJ}/%.tst: tests.c %.c ifeq ($(V),1) - $(CC) -MMD ${CFLAGS} ${LFLAGS} -o $@ $^ $(LDFLAGS) + $(CC) -MMD ${CPPFLAGS} ${CFLAGS} ${LFLAGS} -o $@ ${patsubst %.h,, ${^}} $(LDFLAGS) else @echo TST $@ - @$(CC) -MMD ${CFLAGS} ${LFLAGS} -o $@ $^ $(LDFLAGS) + @$(CC) -MMD ${CPPFLAGS} ${CFLAGS} ${LFLAGS} -o $@ ${patsubst %.h,, ${^}} $(LDFLAGS) endif run_tests: all