diff --git a/Makefile b/Makefile index 86d8dcab183902462161a90826058a74070ec6b0..558154edbb1177a67ca61e63433b616c8fe7b7c3 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,15 @@ endif # Optimize for size #OPTIMIZE = -Os # No optimization at all -OPTIMIZE = -O0 -Xclang -disable-O0-optnone +ifeq "$(MAKECMDGOALS)" "rel" +# GCC +OPTIMIZE = -O0 +else ifeq "$(MAKECMDGOALS)" "wcet" +OPTIMIZE = -O0 +else +# CLANG +OPTIMIZE = -O0 -Xclang -disable-O0-optnone +endif #INCSEARCH = include #SRCIGNORE =! -iname 'tiny_printf.c' @@ -91,16 +99,34 @@ else # Start of the CLANG block # CLANG -CLANGMCFLAGS =-target $(TARGETTRIPLE) # -fno-integrated-as +CLANGMCFLAGS = #-target $(TARGETTRIPLE) # -fno-integrated-as # MCU Specific flags -MCFLAGS = -mcpu=$(MCU) -mlittle-endian -mthumb -ffreestanding \ - -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fshort-enums \ - -g3 -std=gnu11 -Wall -Wextra +#MCFLAGS = -mcpu=$(MCU) -mlittle-endian -mthumb -ffreestanding \ + #-fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fshort-enums \ + #-g3 -std=gnu11 -Wall -Wextra + +ifeq "$(MAKECMDGOALS)" "rel" +TARGETHWFLAGS = -target $(TARGETTRIPLE) -mcpu=$(MCU) -mlittle-endian -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard +TARGETHWLDFLAGS = + +else ifeq "$(MAKECMDGOALS)" "wcet" +TARGETHWFLAGS = -target $(TARGETTRIPLE) -mcpu=$(MCU) -mlittle-endian -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard +TARGETHWLDFLAGS = + +else +TARGETHWFLAGS = +# Link for some triple, not really used, but needed for linking with interrupt vectors +TARGETHWLDFLAGS = -mtriple=$(TARGETTRIPLE) -march=thumb -mcpu=$(MCU) -float-abi=hard +endif + +MCFLAGS = -ffreestanding \ + -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections \ + -fshort-enums -g3 -std=gnu11 -Wall -Wextra # For creating object file from LLVM IR -LLCFLAGS = -mtriple=$(TARGETTRIPLE) -march=thumb -mcpu=$(MCU) -filetype=obj -float-abi=hard +LLCFLAGS = $(TARGETHWLDFLAGS) -filetype=obj -# Assembler flags +# Assembler flags (unnused) ASFLAGS = -mcpu=$(MCU) -mlittle-endian -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard @@ -110,11 +136,11 @@ LDFLAGS = --specs=nosys.specs -Wl,-T "ldscripts/flash.ld" -nostartfiles -Wl,-no # Not used: #--specs=nano.specs --specs=nosys.specs -lc -lnosys -CLANGLDFLAGS = -flto -target $(TARGETTRIPLE) -mfloat-abi=hard # -save-temps=obj -#or if you want .bc in objects -save-temps=obj +CLANGLDFLAGS = -flto +#or if you want .bc for each object: -save-temps=obj # Build the compile command -CFLAGS = $(CLANGMCFLAGS) $(MCFLAGS) $(OPTIMIZE) $(DEFS) +CFLAGS = $(CLANGMCFLAGS) $(TARGETHWFLAGS) $(MCFLAGS) $(OPTIMIZE) $(DEFS) # Recursively add all .c files