switch to ELLCC cross-compiler
This commit is contained in:
parent
085a627b76
commit
aa1aa7162d
62
Makefile
62
Makefile
|
@ -35,8 +35,7 @@ OBJ = $(patsubst %.c,%.o,$(CSRC))
|
|||
|
||||
# my library collection
|
||||
LIB = lib
|
||||
# the library files to use
|
||||
# this will be populated using includes based DEPENDENCIES
|
||||
# the library files to use (this will be populated using includes based DEPENDENCIES)
|
||||
LIB_CSRC =
|
||||
LIB_CHDR = $(patsubst %.c,%.h,$(LIB_CSRC))
|
||||
LIB_OBJ = $(patsubst %.c,%.o,$(LIB_CSRC))
|
||||
|
@ -45,20 +44,19 @@ LIB_OBJ = $(patsubst %.c,%.o,$(LIB_CSRC))
|
|||
DEPENDENCIES = $(patsubst %.c,%.inc,$(CSRC))
|
||||
# populates LIB_CSRC based on the library files used
|
||||
-include $(DEPENDENCIES)
|
||||
$(info $(DEPENDENCIES))
|
||||
|
||||
# executables for linking, compiling, debugging, ...
|
||||
PREFIX ?= arm-none-eabi
|
||||
# use gcc as compiler
|
||||
CC := $(PREFIX)-gcc
|
||||
# use clang as compiler
|
||||
#CC := clang -target $(PREFIX)
|
||||
# use ELLCC cross-compiling chain (based on clang/llvm + musl)
|
||||
ELLCC := /opt/ellcc/
|
||||
# use ELLCC as compile
|
||||
CC := $(ELLCC)bin/ecc -target arm-none-eabi
|
||||
LD := $(PREFIX)-ld
|
||||
AR := $(PREFIX)-ar
|
||||
AS := $(PREFIX)-as
|
||||
OBJCOPY := $(PREFIX)-objcopy
|
||||
OBJDUMP := $(PREFIX)-objdump
|
||||
GDB := $(PREFIX)-gdb
|
||||
LD := $(ELLCC)bin/ecc-ld -m armelf
|
||||
AR := $(ELLCC)bin/ecc-ar
|
||||
AS := $(ELLCC)bin/ecc-as
|
||||
OBJCOPY := $(ELLCC)bin/ecc-objcopy
|
||||
OBJDUMP := $(ELLCC)bin/ecc-objdump
|
||||
GDB := $(ELLCC)bin/ecc-gdb
|
||||
|
||||
# opencm3 libraries
|
||||
OPENCM3_DIR := libopencm3
|
||||
|
@ -83,7 +81,7 @@ DEFS += -DSTM32F1 -D$(BOARD)
|
|||
# optimize for size
|
||||
CFLAGS += -Os
|
||||
# add debug symbols (remove for smaller release)
|
||||
CFLAGS += -g
|
||||
CFLAGS += -ggdb
|
||||
# use C99 (supported by most an sufficient)
|
||||
CFLAGS += -std=c99
|
||||
# have strict warning (for better code)
|
||||
|
@ -92,18 +90,14 @@ CFLAGS += -Wpedantic -Wall -Werror -Wundef -Wextra -Wshadow -Wredundant-decls -W
|
|||
CFLAGS += -fno-common -ffunction-sections -fdata-sections
|
||||
# use variable size enum (opencm3, gcc, and compiler-rt do)
|
||||
CFLAGS += -fshort-enums
|
||||
# use no variable size enum (musl does not)
|
||||
#CFLAGS += -fno-short-enums
|
||||
# use no variable size enum (ELLCC/musl does not)
|
||||
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/
|
||||
CFLAGS += -nostdlib -nostdinc
|
||||
# include ELLCC libraries
|
||||
CFLAGS += -I$(ELLCC)libecc/include/ -I$(ELLCC)libecc/include/arm/
|
||||
# include own libraries
|
||||
CFLAGS += -I . $(patsubst %,-I%,$(LIB))
|
||||
# include opencm3 libraries
|
||||
|
@ -119,25 +113,15 @@ LDFLAGS += -nostartfiles
|
|||
# only keep used sections
|
||||
LDFLAGS += --gc-sections
|
||||
# don't use system libraries
|
||||
#LDFLAGS += -nostdlib -nostdinc
|
||||
# add musl libraries (for libc, libm)
|
||||
#LDFLAGS += --library-path /media/data/tmp/arm-linux-musleabi/arm-linux-musleabi/lib
|
||||
# add system libraries (for libc, libm, libnosys)
|
||||
LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/
|
||||
# add gcc library (for ARM ABI to be used by gcc)
|
||||
LDFLAGS += --library-path /usr/lib/gcc/arm-none-eabi/*/armv7-m/
|
||||
# add compiler-rt library (for ARM ABI to be used by clang)
|
||||
#LDFLAGS += --library-path /usr/arm-none-eabi/lib/armv7-m/
|
||||
LDFLAGS += -nostdlib -nostdinc
|
||||
# add ELLCC standard libraries (for libc, libm, libgcc)
|
||||
LDFLAGS += --library-path $(ELLCC)libecc/lib/cortex-m3-linux/
|
||||
# opencm3 libraries
|
||||
LDFLAGS += --library-path $(OPENCM3_LIB)
|
||||
|
||||
# linker script with definitions for micro-controller
|
||||
LDFLAGS += --script $(LDSCRIPT)
|
||||
|
||||
# used libraries when using gcc (must be provided after objects)
|
||||
LDLIBS += --library $(STM32F1_LIB) --library c --library gcc --library nosys --library m
|
||||
# used libraries when using clang (must be provided after objects)
|
||||
#LDLIBS += --library $(STM32F1_LIB) --library c --library m --library clang_rt.builtins
|
||||
# used libraries (gcc provides the ARM ABI, not sure how to replace with compiler-rt)
|
||||
LDLIBS += --library $(STM32F1_LIB) --library c --library m --library gcc
|
||||
|
||||
# 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
|
||||
|
@ -201,7 +185,7 @@ doc: Doxyfile README.md $(CSRC) $(CHDR) $(LIB_CSRC) $(LIB_CHDR)
|
|||
$(Q)doxygen $(<)
|
||||
|
||||
clean:
|
||||
$(Q)$(RM) $(BINARY).elf $(BINARY).bin $(BINARY).hex $(BINARY).map $(OBJ) $(LIB_OBJ) $(LIB)/*.o $(DEPENDENCIES)
|
||||
$(Q)$(RM) $(BINARY).elf $(BINARY).bin $(BINARY).hex $(BINARY).map $(OBJ) $(LIB_OBJ) $(LIB)/*.o $(DEPENDENCIES) $(LIB)/*.inc
|
||||
|
||||
# make libopencm3 if library for STM32F1 is not yet existing
|
||||
$(OPENCM3_LIB)/lib$(STM32F1_LIB).a:
|
||||
|
|
Loading…
Reference in New Issue