prepare for clang switch, but still use gcc

This commit is contained in:
King Kévin 2016-08-28 23:16:13 +02:00
parent f2fb84c7df
commit 7861140027
1 changed files with 27 additions and 12 deletions

View File

@ -47,7 +47,10 @@ LIB_OBJ = $(patsubst %.c,%.o,$(LIB_CSRC))
# executables for linking, compiling, debugging, ...
PREFIX ?= arm-none-eabi
# use gcc as compiler
CC := $(PREFIX)-gcc
# use clang as compiler
#CC := clang -target $(PREFIX)
LD := $(PREFIX)-ld
AR := $(PREFIX)-ar
AS := $(PREFIX)-as
@ -92,8 +95,20 @@ CFLAGS += -std=c99
CFLAGS += -Wpedantic -Wall -Werror -Wundef -Wextra -Wshadow -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes -Wstrict-overflow=5
# add options for better code optimization
CFLAGS += -fno-common -ffunction-sections -fdata-sections
# use variable size enum (opencm3 and libc do)
CFLAGS += -fshort-enums
# use no variable size enum
#CFLAGS += -fno-short-enums
# don't use system main definition (the starting point)
CFLAGS += -ffreestanding
# don't use the standard library
#CFLAGS += -nostdlib -nostdinc
# include musl libc
#CFLAGS += -I /media/data/tmp/arm-linux-musleabi/arm-linux-musleabi/include
# include newlib libc
#CFLAGS += -I/usr/arm-none-eabi/include/
# include gcc standard library (for printf)
#CFLAGS += -I/usr/lib/gcc/arm-none-eabi/6.1.1/include/
# include own libraries
CFLAGS += -I . $(patsubst %,-I%,$(LIB))
# include opencm3 libraries
@ -107,21 +122,21 @@ LDFLAGS += -static
# don's include the system start files
LDFLAGS += -nostartfiles
# don't use system libraries
LDFLAGS += -nostdlib -nostdinc
# opencm3 libraries
LDFLAGS += --library-path=$(OPENCM3_LIB)
#LDFLAGS += -L. $(patsubst %,-L%,$(LIB))
# add c,m,nosys system libraries
LDFLAGS += -L/usr/arm-none-eabi/lib/armv7-m/
# add gcc system library
LDFLAGS += -L/usr/lib/gcc/arm-none-eabi/6.1.1/armv7-m/
# linker definitions for micro-controller
LDFLAGS += -T$(LDSCRIPT)
#LDFLAGS += -nostdlib -nostdinc
# only keep used sections
LDFLAGS += --gc-sections
# opencm3 libraries
LDFLAGS += --library-path $(OPENCM3_LIB)
# add c,m,nosys system libraries
LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/
# add gcc system library
LDFLAGS += --library-path /usr/lib/gcc/arm-none-eabi/*/armv7-m/
# linker script with definitions for micro-controller
LDFLAGS += --script $(LDSCRIPT)
# used libraries (must be provided after objects)
LDLIBS += -l$(STM32F1_LIB) -lc -lgcc -lnosys -lm
LDLIBS += --library $(STM32F1_LIB) --library c --library gcc --library nosys --library m
# target micro-controller information (ARM Cortex-M3 supports thumb and thumnb2, but does not include a floating point unit)
ARCH_FLAGS = -mthumb -mcpu=cortex-m3 -msoft-float
@ -216,4 +231,4 @@ else ifeq ($(SWD_ADAPTER),BMP)
$(Q)$(GDB) --eval-command="target extended-remote $(BMPPORT)" --eval-command="monitor version" --eval-command="monitor swdp_scan" --eval-command="attach 1" $(<)
endif
.PHONY: clean elf bin hex srec list libraries flash reset
.PHONY: clean elf bin hex srec list flash reset