|
| 1 | +all: |
| 2 | + |
| 3 | +SOFTPACK_VERSION="2.0" |
| 4 | +AVAILABLE_MEMORIES = sram ddram |
| 5 | +AVAILABLE_BOARDS = sama5d4-xplained sama5d4-ek |
| 6 | +MEMORIES = sram ddram |
| 7 | + |
| 8 | +eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1))) |
| 9 | + |
| 10 | +ifndef TARGET |
| 11 | +$(error "No TARGET specified.") |
| 12 | +endif |
| 13 | + |
| 14 | +SELECTED_BOARD=$(strip $(foreach board,$(AVAILABLE_BOARDS),$(if $(call eq,$(TARGET),$(board)),$(board)))) |
| 15 | + |
| 16 | +ifeq (,$(SELECTED_BOARD)) |
| 17 | +$(info The wanted target "$(TARGET)" is not supported) |
| 18 | +$(error Please set TARGET to one value from the list above: $(AVAILABLE_BOARDS)) |
| 19 | +endif |
| 20 | + |
| 21 | +ifeq ("y",$(TARGET:sama5d4-%="y")) |
| 22 | +SERIE=SERIE_SAMA5D4 |
| 23 | +SERIEDIRNAME=sama5d4 |
| 24 | +endif |
| 25 | + |
| 26 | +ifeq ("y",$(TARGET:%-xplained="y")) |
| 27 | +BOARD=BOARD_SAMA5D4_XPLAINED |
| 28 | +CHIP=CHIP_SAMA5D44 |
| 29 | +endif |
| 30 | + |
| 31 | +ifeq ("y",$(TARGET:%-ek="y")) |
| 32 | +BOARD=BOARD_SAMA5D4_EK |
| 33 | +endif |
| 34 | + |
| 35 | +#------------------------------------------------------------------------------- |
| 36 | +# Setup cross-compilation tools |
| 37 | +#------------------------------------------------------------------------------- |
| 38 | +# Tool suffix when cross-compiling |
| 39 | +CROSS_COMPILE = arm-none-eabi- |
| 40 | + |
| 41 | +# Compilation tools |
| 42 | +CC = $(CROSS_COMPILE)gcc |
| 43 | +LD = $(CROSS_COMPILE)ld |
| 44 | +SIZE = $(CROSS_COMPILE)size |
| 45 | +STRIP = $(CROSS_COMPILE)strip |
| 46 | +OBJCOPY = $(CROSS_COMPILE)objcopy |
| 47 | +GDB = $(CROSS_COMPILE)gdb |
| 48 | +NM = $(CROSS_COMPILE)nm |
| 49 | + |
| 50 | +#------------------------------------------------------------------------------- |
| 51 | +# Setup paths |
| 52 | +#------------------------------------------------------------------------------- |
| 53 | +ROOTDIR := $(dir $(lastword $(MAKEFILE_LIST))) |
| 54 | +LIBDIR := $(ROOTDIR)/lib |
| 55 | +TARGETDIR := $(ROOTDIR)/target |
| 56 | +DRIVERDIR := $(ROOTDIR)/drivers |
| 57 | +UTILSDIR := $(ROOTDIR)/utils |
| 58 | +RESOURCEDIR := $(TARGETDIR)/resources/gcc/$(SERIEDIRNAME) |
| 59 | + |
| 60 | +#------------------------------------------------------------------------------- |
| 61 | +# Setup compilation params |
| 62 | +#------------------------------------------------------------------------------- |
| 63 | + |
| 64 | +# include dirs |
| 65 | +INCLUDE_TARGET = -I$(TARGETDIR) -I$(TARGETDIR)/include |
| 66 | +INCLUDE_UTILS = -I$(UTILSDIR) |
| 67 | +INCLUDE_DRIVER = -I$(DRIVERDIR) |
| 68 | +INCLUDE_ROOTDIR = -I$(ROOTDIR) |
| 69 | + |
| 70 | +OPTIMIZE_MEMORY = -Os |
| 71 | +OPTIMIZE_EXEC = -O2 |
| 72 | +optimization = $(if $(call eq,sram,$(1)),$(OPTIMIZE_MEMORY),$(OPTIMIZE_EXEC)) |
| 73 | + |
| 74 | +# C flags |
| 75 | +CFLAGS = -Wall -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int |
| 76 | +CFLAGS += -Werror-implicit-function-declaration -Wmain -Wparentheses |
| 77 | +CFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs |
| 78 | +CFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef |
| 79 | +CFLAGS += -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings |
| 80 | +CFLAGS += -Waggregate-return -Wstrict-prototypes |
| 81 | +CFLAGS += -Wmissing-prototypes -Wmissing-declarations |
| 82 | +CFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations |
| 83 | +CFLAGS += -Wredundant-decls -Wnested-externs -Winline -Wlong-long |
| 84 | +CFLAGS += -Wunreachable-code |
| 85 | +# To reduce application size use only integer printf function. |
| 86 | +CFLAGS += -Dprintf=iprintf |
| 87 | +CFLAGS += -mcpu=cortex-a5 -ffunction-sections |
| 88 | +CFLAGS += -g3 -Wall |
| 89 | +CFLAGS += -D$(CHIP) -D$(BOARD) -D$(SERIE) -DSOFTPACK_VERSION="\"$(SOFTPACK_VERSION)\"" |
| 90 | + |
| 91 | +# linkker flags |
| 92 | +LDFLAGS= -mcpu=cortex-a5 -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=entry -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols |
| 93 | + |
| 94 | +#------------------------------------------------------------------------------- |
| 95 | +# we detect OS (Linux/Windows/Cygwin) |
| 96 | +# not defined for Cygwin |
| 97 | +#ifdef $(OS) |
| 98 | +ifdef SystemRoot |
| 99 | +RM=del |
| 100 | +RMDIR=rmdir /s /q |
| 101 | +PATHSEP=\\ |
| 102 | +else |
| 103 | +RM=rm -f |
| 104 | +RMDIR=rm -fr |
| 105 | +endif |
| 106 | + |
| 107 | +list-boards: |
| 108 | + @echo List of all available boards: |
| 109 | + @echo $(AVAILABLE_BOARDS) |
0 commit comments