From c1da7c1d96ddc6631ea02e098429d019c9bb1d90 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= <henrik@tjaders.com>
Date: Thu, 2 Jan 2020 14:17:54 +0100
Subject: [PATCH] Update to latest LLVM 9 and working with KLEE 2

---
 Makefile | 46 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index 86d8dca..558154e 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
-- 
GitLab