From 417f64bd3ce27cc707cfd50eb1e988ddeb759fec Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 29 Sep 2014 17:50:43 +1000 Subject: [PATCH 1/7] Makefile fix --- drivers/multiple/uGFXnet/driver.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/multiple/uGFXnet/driver.mk b/drivers/multiple/uGFXnet/driver.mk index c9d2749c..a579a659 100644 --- a/drivers/multiple/uGFXnet/driver.mk +++ b/drivers/multiple/uGFXnet/driver.mk @@ -1,6 +1,6 @@ GFXINC += $(GFXLIB)/drivers/multiple/uGFXnet GFXSRC += $(GFXLIB)/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c -ifeq($(OPT_NATIVEOS),win32) +ifeq ($(OPT_NATIVEOS),win32) GFXLIBS += ws2_32 endif From b1b00b1cc9780db403bba2f21837fef20b9d8e8c Mon Sep 17 00:00:00 2001 From: inmarket Date: Tue, 30 Sep 2014 13:33:00 +1000 Subject: [PATCH 2/7] Updated make scripts to be more compatible with older versions of gmake 3.XX --- gfx.mk | 21 ++++++++++++++------- tools/gmake_scripts/compiler_gcc.mk | 12 ++++++++---- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/gfx.mk b/gfx.mk index a0f27c53..89c3282a 100644 --- a/gfx.mk +++ b/gfx.mk @@ -28,18 +28,25 @@ endif # Include the operating system define ifeq ($(OPT_OS),win32) GFXDEFS += GFX_USE_OS_WIN32=TRUE -else ifeq ($(OPT_OS),linux) +endif +ifeq ($(OPT_OS),linux) GFXDEFS += GFX_USE_OS_LINUX=TRUE -else ifeq ($(OPT_OS),osx) +endif +ifeq ($(OPT_OS),osx) GFXDEFS += GFX_USE_OS_OSX=TRUE -else ifeq ($(OPT_OS),chibios) +endif +ifeq ($(OPT_OS),chibios) GFXDEFS += GFX_USE_OS_CHIBIOS=TRUE -else ifeq ($(OPT_OS),freertos) +endif +ifeq ($(OPT_OS),freertos) GFXDEFS += GFX_USE_OS_FREERTOS=TRUE -else ifeq ($(OPT_OS),ecos) +endif +ifeq ($(OPT_OS),ecos) GFXDEFS += GFX_USE_OS_ECOS=TRUE -else ifeq ($(OPT_OS),rawrtos) +endif +ifeq ($(OPT_OS),rawrtos) GFXDEFS += GFX_USE_OS_RAWRTOS=TRUE -else ifeq ($(OPT_OS),raw32) +endif +ifeq ($(OPT_OS),raw32) GFXDEFS += GFX_USE_OS_RAW32=TRUE endif diff --git a/tools/gmake_scripts/compiler_gcc.mk b/tools/gmake_scripts/compiler_gcc.mk index eed78e82..0e5b8098 100644 --- a/tools/gmake_scripts/compiler_gcc.mk +++ b/tools/gmake_scripts/compiler_gcc.mk @@ -23,13 +23,17 @@ endif ifeq ($(BUILDDIR),) ifeq ($(MAKECMDGOALS),Debug) BUILDDIR = bin/Debug - else ifeq ($(MAKECMDGOALS),Release) + endif + ifeq ($(MAKECMDGOALS),Release) BUILDDIR = bin/Release - else ifeq ($(MAKECMDGOALS),cleanDebug) + endif + ifeq ($(MAKECMDGOALS),cleanDebug) BUILDDIR = bin/Debug - else ifeq ($(MAKECMDGOALS),cleanRelease) + endif + ifeq ($(MAKECMDGOALS),cleanRelease) BUILDDIR = bin/Release - else + endif + ifeq ($(BUILDDIR),) BUILDDIR = .build endif endif From f90ea57bff091832c7b52b3825057ac20ded1f01 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 1 Oct 2014 00:44:40 +1000 Subject: [PATCH 3/7] First ARM build to use the new makefile plus makefile updates --- .../base/Linux-Framebuffer/example/Makefile | 36 ++- boards/base/Linux/example/Makefile | 36 ++- boards/base/OSX/example/Makefile | 41 +-- .../Olimex-SAM7EX256-GE8/example/Makefile | 249 ++++-------------- boards/base/Win32/example/Makefile | 63 ++--- drivers/multiple/uGFXnet/driver.mk | 2 +- tools/gmake_scripts/compiler_gcc.mk | 79 +++++- tools/gmake_scripts/os_chibios.mk | 30 +++ tools/gmake_scripts/os_linux.mk | 8 + tools/gmake_scripts/os_osx.mk | 10 + tools/gmake_scripts/os_win32.chibios.mk | 18 ++ tools/gmake_scripts/os_win32.mk | 6 + tools/gmake_scripts/readme.txt | 17 +- 13 files changed, 299 insertions(+), 296 deletions(-) create mode 100644 tools/gmake_scripts/os_chibios.mk create mode 100644 tools/gmake_scripts/os_linux.mk create mode 100644 tools/gmake_scripts/os_osx.mk create mode 100644 tools/gmake_scripts/os_win32.chibios.mk create mode 100644 tools/gmake_scripts/os_win32.mk diff --git a/boards/base/Linux-Framebuffer/example/Makefile b/boards/base/Linux-Framebuffer/example/Makefile index 29b0a266..76b2022a 100644 --- a/boards/base/Linux-Framebuffer/example/Makefile +++ b/boards/base/Linux-Framebuffer/example/Makefile @@ -4,30 +4,37 @@ # Settings # -# See $(GFXLIB)/tools/gmake_scripts/readme.txt for the meaning of these variables -OPT_VERBOSE_COMPILE = no -OPT_GENERATE_LISTINGS = yes -OPT_GENERATE_MAP = yes -OPT_COPY_EXE = no -OPT_NATIVEOS = linux -OPT_OS = linux +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_VERBOSE_COMPILE = no + OPT_GENERATE_LISTINGS = yes + OPT_GENERATE_MAP = yes + OPT_COPY_EXE = no + OPT_LINK_OPTIMIZE = yes + OPT_NONSTANDARD_FLAGS = no + OPT_OS = linux -# See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the meaning of these variables -GFXLIB = ../uGFX -GFXBOARD = Linux-Framebuffer -#GFXDRIVERS = multiple/uGFXnet -GFXDEMO = modules/gdisp/basics +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = Linux-Framebuffer + #GFXDRIVERS = multiple/uGFXnet + GFXDEMO = modules/gdisp/basics + +# Linux settings + # See $(GFXLIB)/tools/gmake_scripts/os_linux.mk for the list of variables ############################################################################################## # Set these for your project # ARCH = -SRCFLAGS = -m32 -ggdb -O0 -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm +SRCFLAGS = -ggdb -O0 +SRCFLAGS+= -m32 CFLAGS = CXXFLAGS = ASFLAGS = -LDFLAGS = -pthread +LDFLAGS = SRC = DEFS = @@ -40,5 +47,6 @@ LIBPATH = # include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk # *** EOF *** diff --git a/boards/base/Linux/example/Makefile b/boards/base/Linux/example/Makefile index 87b80434..d6402c8a 100644 --- a/boards/base/Linux/example/Makefile +++ b/boards/base/Linux/example/Makefile @@ -4,30 +4,37 @@ # Settings # -# See $(GFXLIB)/tools/gmake_scripts/readme.txt for the meaning of these variables -OPT_VERBOSE_COMPILE = no -OPT_GENERATE_LISTINGS = yes -OPT_GENERATE_MAP = yes -OPT_COPY_EXE = no -OPT_NATIVEOS = linux -OPT_OS = linux +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_VERBOSE_COMPILE = no + OPT_GENERATE_LISTINGS = yes + OPT_GENERATE_MAP = yes + OPT_COPY_EXE = no + OPT_LINK_OPTIMIZE = yes + OPT_NONSTANDARD_FLAGS = no + OPT_OS = linux -# See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the meaning of these variables -GFXLIB = ../uGFX -GFXBOARD = Linux -#GFXDRIVERS = multiple/uGFXnet -GFXDEMO = modules/gdisp/basics +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = Linux + #GFXDRIVERS = multiple/uGFXnet + GFXDEMO = modules/gdisp/basics + +# Linux settings + # See $(GFXLIB)/tools/gmake_scripts/os_linux.mk for the list of variables ############################################################################################## # Set these for your project # ARCH = -SRCFLAGS = -m32 -ggdb -O0 -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm +SRCFLAGS = -ggdb -O0 +SRCFLAGS+= -m32 CFLAGS = CXXFLAGS = ASFLAGS = -LDFLAGS = -pthread +LDFLAGS = SRC = DEFS = @@ -40,5 +47,6 @@ LIBPATH = # include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk # *** EOF *** diff --git a/boards/base/OSX/example/Makefile b/boards/base/OSX/example/Makefile index d3502528..956608ff 100644 --- a/boards/base/OSX/example/Makefile +++ b/boards/base/OSX/example/Makefile @@ -4,33 +4,39 @@ # Settings # -# See $(GFXLIB)/tools/gmake_scripts/readme.txt for the meaning of these variables -OPT_VERBOSE_COMPILE = no -OPT_GENERATE_LISTINGS = yes -OPT_GENERATE_MAP = yes -OPT_COPY_EXE = no -OPT_NATIVEOS = osx -OPT_OS = osx +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_VERBOSE_COMPILE = no + OPT_GENERATE_LISTINGS = yes + OPT_GENERATE_MAP = yes + OPT_COPY_EXE = no + OPT_LINK_OPTIMIZE = yes + OPT_NONSTANDARD_FLAGS = no + OPT_OS = osx -# See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the meaning of these variables -GFXLIB = ../uGFX -GFXBOARD = OSX -#GFXDRIVERS = multiple/uGFXnet -GFXDEMO = modules/gdisp/basics +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = OSX + #GFXDRIVERS = multiple/uGFXnet + GFXDEMO = modules/gdisp/basics + +# OSX settings + # See $(GFXLIB)/tools/gmake_scripts/os_osx.mk for the list of variables + OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk + OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 ############################################################################################## # Set these for your project # -OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk -OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 - ARCH = -SRCFLAGS = -m32 -ggdb -O0 -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm -isysroot $(OSX_SDK) $(OSX_ARCH) +SRCFLAGS = -ggdb -O0 +SRCFLAGS+= -m32 CFLAGS = CXXFLAGS = ASFLAGS = -LDFLAGS = -pthread -Wl,-syslibroot,$(OSX_SDK) $(OSX_ARCH) +LDFLAGS = SRC = DEFS = @@ -43,5 +49,6 @@ LIBPATH = # include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk # *** EOF *** diff --git a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile index e9fdde2d..aa11abad 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile +++ b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile @@ -1,205 +1,64 @@ -############################################################################## -# Build global options -# NOTE: Can be overridden externally. +# Possible Targets: all clean Debug cleanDebug Release cleanRelease + +############################################################################################## +# Settings # -# Compiler options here. -ifeq ($(USE_OPT),) - # If you are using gcc V4.5.1 or older then replace -g with -ggdb -gstabs+ - # For debugging you probably want -O0 rather than -O2 - USE_OPT = -O0 -g -fomit-frame-pointer -mabi=apcs-gnu +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_VERBOSE_COMPILE = no + OPT_GENERATE_LISTINGS = yes + OPT_GENERATE_MAP = yes + OPT_COPY_EXE = no + OPT_LINK_OPTIMIZE = yes + OPT_NONSTANDARD_FLAGS = no + OPT_NATIVEOS = chibios + OPT_OS = chibios + +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = Olimex-SAM7EX256-GE8 + #GFXDRIVERS = multiple/uGFXnet + GFXDEMO = modules/gdisp/basics + +# ChibiOS settings +ifeq ($(OPT_OS),chibios) + # See $(GFXLIB)/tools/gmake_scripts/os_chibios.mk for the list of variables + CHIBIOS = ../ChibiOS + CHIBIOS_BOARD = OLIMEX_SAM7_EX256 + CHIBIOS_PLATFORM = AT91SAM7 + CHIBIOS_PORT = GCC/ARM/AT91SAM7 + CHIBIOS_DEFS = + #CHIBIOS_LDSCRIPT = $(PORTLD)/AT91SAM7X256.ld + # We define a non standard linker script here just to give us some more stack space + CHIBIOS_LDSCRIPT = linker.ld endif -# C specific options here (added to USE_OPT). -ifeq ($(USE_COPT),) - USE_COPT = -endif - -# C++ specific options here (added to USE_OPT). -ifeq ($(USE_CPPOPT),) - USE_CPPOPT = -fno-rtti -endif - -# Enable this if you want the linker to remove unused code and data -ifeq ($(USE_LINK_GC),) - USE_LINK_GC = yes -endif - -# If enabled, this option allows to compile the application in THUMB mode. -ifeq ($(USE_THUMB),) - USE_THUMB = no -endif - -# Enable this if you want to see the full log while compiling. -ifeq ($(USE_VERBOSE_COMPILE),) - USE_VERBOSE_COMPILE = no -endif - -# -# Build global options -############################################################################## - -############################################################################## -# Project, sources and paths +############################################################################################## +# Set these for your project # -# Define project name here -PROJECT = ch +ARCH = arm-none-eabi- +SRCFLAGS = -ggdb -O0 +SRCFLAGS+= -mcpu=arm7tdmi -mabi=apcs-gnu -mno-thumb-interwork +CFLAGS = +CXXFLAGS = -fno-rtti +ASFLAGS = +LDFLAGS = -mcpu=arm7tdmi -# Imported source files and paths for ChibiOS -CHIBIOS = ../ChibiOS -include $(CHIBIOS)/boards/OLIMEX_SAM7_EX256/board.mk -include $(CHIBIOS)/os/hal/platforms/AT91SAM7/platform.mk -include $(CHIBIOS)/os/hal/hal.mk -include $(CHIBIOS)/os/ports/GCC/ARM/AT91SAM7/port.mk -include $(CHIBIOS)/os/kernel/kernel.mk +SRC = +DEFS = +LIBS = +INCPATH = +LIBPATH = +LDSCRIPT = -# We define a non standard linker script here just to give us some more stack space -# LDSCRIPT= $(PORTLD)/AT91SAM7X256.ld -LDSCRIPT= linker.ld - -# Imported source files and paths for uGFX -GFXLIB = ../uGFX -include $(GFXLIB)/gfx.mk -include $(GFXLIB)/boards/base/Olimex-SAM7EX256-GE8/board.mk - -# Where is our source code - alter these for your project. -# Either just include the demo makefile or add your own definitions -include $(GFXLIB)/demos/modules/gdisp/basics/demo.mk -#MYFILES = my-project-directory -#MYCSRC = $(MYFILES)/main.c -#MYDEFS = - -# C sources that can be compiled in ARM or THUMB mode depending on the global -# setting. -CSRC = $(PORTSRC) \ - $(KERNSRC) \ - $(TESTSRC) \ - $(HALSRC) \ - $(PLATFORMSRC) \ - $(BOARDSRC) \ - $(GFXSRC) \ - $(MYCSRC) - -# C++ sources that can be compiled in ARM or THUMB mode depending on the global -# setting. -CPPSRC = - -# C sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACSRC = - -# C++ sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACPPSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCPPSRC = - -# List ASM source files here -ASMSRC = $(PORTASM) - -INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) \ - $(GFXINC) \ - $(MYFILES) - -# -# Project, sources and paths -############################################################################## - -############################################################################## -# Compiler settings +############################################################################################## +# These should be at the end # -MCU = arm7tdmi - -#TRGT = arm-elf- -TRGT = arm-none-eabi- -CC = $(TRGT)gcc -CPPC = $(TRGT)g++ -# Enable loading with g++ only if you need C++ runtime support. -# NOTE: You can use C++ even without C++ support if you are careful. C++ -# runtime support makes code size explode. -# If you are using gcc V4.5.1 or older then add -ggdb -gstabs+ to the LD line -LD = $(TRGT)gcc -#LD = $(TRGT)g++ -CP = $(TRGT)objcopy -AS = $(TRGT)gcc -x assembler-with-cpp -OD = $(TRGT)objdump -SZ = $(TRGT)size -HEX = $(CP) -O ihex -BIN = $(CP) -O binary - -# ARM-specific options here -AOPT = - -# THUMB-specific options here -TOPT = -mthumb -DTHUMB - -# Define C warning options here -CWARN = -Wall -Wextra -Wstrict-prototypes - -# Define C++ warning options here -CPPWARN = -Wall -Wextra - -# -# Compiler settings -############################################################################## - -############################################################################## -# Start of default section -# - -# List all default C defines here, like -D_DEBUG=1 -DDEFS = $(GFXDEFS) - -# List all default ASM defines here, like -D_DEBUG=1 -DADEFS = - -# List all default directories to look for include files here -DINCDIR = - -# List the default directory to look for the libraries here -DLIBDIR = - -# List all default libraries here -DLIBS = - -# -# End of default section -############################################################################## - -############################################################################## -# Start of user section -# - -# List all user C define here, like -D_DEBUG=1 -UDEFS = - -# Define ASM defines here -UADEFS = - -# List all user directories here -UINCDIR = - -# List the user directory to look for the libraries here -ULIBDIR = - -# List all user libraries here -ULIBS = - -# -# End of user defines -############################################################################## - -include $(CHIBIOS)/os/ports/GCC/ARM/rules.mk +include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk +include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk +# *** EOF *** diff --git a/boards/base/Win32/example/Makefile b/boards/base/Win32/example/Makefile index 502cf1ac..4bf6c603 100644 --- a/boards/base/Win32/example/Makefile +++ b/boards/base/Win32/example/Makefile @@ -4,33 +4,39 @@ # Settings # -# See $(GFXLIB)/tools/gmake_scripts/readme.txt for the meaning of these variables -OPT_VERBOSE_COMPILE = no -OPT_GENERATE_LISTINGS = yes -OPT_GENERATE_MAP = yes -OPT_COPY_EXE = no -OPT_NATIVEOS = win32 -OPT_OS = win32 +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_VERBOSE_COMPILE = no + OPT_GENERATE_LISTINGS = yes + OPT_GENERATE_MAP = yes + OPT_COPY_EXE = no + OPT_LINK_OPTIMIZE = yes + OPT_NONSTANDARD_FLAGS = no + # For Win32 this variable can be set to "win32" (native win32 api) or "win32.chibios" (ChibiOS simulator). + OPT_OS = win32 -# See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the meaning of these variables -GFXLIB = ../uGFX -GFXBOARD = Win32 -#GFXDRIVERS = multiple/uGFXnet -GFXDEMO = modules/gdisp/basics +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = Win32 + #GFXDRIVERS = multiple/uGFXnet + GFXDEMO = modules/gdisp/basics -# Win32 - ChibiOS simulator -ifeq ($(OPT_OS),chibios) - # Required: Location of the ChibiOS code - CHIBIOS = ../ChibiOS +# ChibiOS settings +ifeq ($(OPT_OS),win32.chibios) + # See $(GFXLIB)/tools/gmake_scripts/os_win32.chibios.mk for the list of variables + CHIBIOS = ../ChibiOS endif +# Win32 settings + # See $(GFXLIB)/tools/gmake_scripts/os_win32.mk for the list of variables ############################################################################################## # Set these for your project # ARCH = i686-pc-mingw32- -SRCFLAGS = -ggdb -O0 -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm +SRCFLAGS = -ggdb -O0 CFLAGS = CXXFLAGS = ASFLAGS = @@ -42,32 +48,11 @@ LIBS = INCPATH = LIBPATH = -############################################################################################## -# Optional: Win32 - ChibiOS Simulator -# - -ifeq ($(OPT_OS),chibios) - include $(CHIBIOS)/boards/simulator/board.mk - include $(CHIBIOS)/os/hal/hal.mk - include $(CHIBIOS)/os/hal/platforms/Win32/platform.mk - include $(CHIBIOS)/os/ports/GCC/SIMIA32/port.mk - include $(CHIBIOS)/os/kernel/kernel.mk - DEFS += SIMULATOR SHELL_USE_IPRINTF=FALSE - INCPATH += $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) - # $(CHIBIOS)/os/various - SRC += $(PORTSRC) \ - $(KERNSRC) \ - $(TESTSRC) \ - $(HALSRC) \ - $(PLATFORMSRC) \ - $(BOARDSRC) -endif - ############################################################################################## # These should be at the end # include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk # *** EOF *** diff --git a/drivers/multiple/uGFXnet/driver.mk b/drivers/multiple/uGFXnet/driver.mk index a579a659..f0bd64d5 100644 --- a/drivers/multiple/uGFXnet/driver.mk +++ b/drivers/multiple/uGFXnet/driver.mk @@ -1,6 +1,6 @@ GFXINC += $(GFXLIB)/drivers/multiple/uGFXnet GFXSRC += $(GFXLIB)/drivers/multiple/uGFXnet/gdisp_lld_uGFXnet.c -ifeq ($(OPT_NATIVEOS),win32) +ifeq ($(basename $(OPT_OS)),win32) GFXLIBS += ws2_32 endif diff --git a/tools/gmake_scripts/compiler_gcc.mk b/tools/gmake_scripts/compiler_gcc.mk index 0e5b8098..cb3a3e2b 100644 --- a/tools/gmake_scripts/compiler_gcc.mk +++ b/tools/gmake_scripts/compiler_gcc.mk @@ -13,9 +13,18 @@ endif ifeq ($(XLD),) XLD = $(ARCH)gcc endif +ifeq ($(XOC),) + XOC = $(ARCH)objcopy +endif +ifeq ($(XOD),) + XOD = $(ARCH)objdump +endif # Default project name is the project directory name ifeq ($(PROJECT),) + ifneq ($(firstword $(abspath $(firstword $(MAKEFILE_LIST)))),$(lastword $(abspath $(firstword $(MAKEFILE_LIST))))) + $(error Your directory contains spaces. Gmake barfs at that. Please define PROJECT) + endif PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))) endif @@ -45,24 +54,50 @@ SRCFILE = $< OBJFILE = $@ LSTFILE = $(@:.o=.lst) MAPFILE = $(BUILDDIR)/$(PROJECT).map -ifeq ($(OPT_NATIVEOS),win32) +EXEFILE = +ifeq ($(basename $(OPT_OS)),win32) EXEFILE = $(BUILDDIR)/$(PROJECT).exe -else + TARGETS = $(EXEFILE) +endif +ifeq ($(basename $(OPT_OS)),linux) EXEFILE = $(BUILDDIR)/$(PROJECT) + TARGETS = $(EXEFILE) +endif +ifeq ($(basename $(OPT_OS)),osx) + EXEFILE = $(BUILDDIR)/$(PROJECT) + TARGETS = $(EXEFILE) +endif +ifeq ($(EXEFILE),) + LDFLAGS += -nostartfiles + EXEFILE = $(BUILDDIR)/$(PROJECT).elf + TARGETS = $(EXEFILE) $(BUILDDIR)/$(PROJECT).hex $(BUILDDIR)/$(PROJECT).bin $(BUILDDIR)/$(PROJECT).dmp endif SRCFLAGS += -I. $(patsubst %,-I%,$(INCPATH)) $(patsubst %,-D%,$(patsubst -D%,%,$(DEFS))) LDFLAGS += $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(patsubst -l%,%,$(LIBS))) OBJS = $(addprefix $(OBJDIR)/,$(subst ../,_dot_dot/,$(addsuffix .o,$(basename $(SRC))))) +ifneq ($(OPT_NONSTANDARD_FLAGS),yes) + SRCFLAGS += -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm +endif +ifeq ($(OPT_LINK_OPTIMIZE),yes) + SRCFLAGS += -ffunction-sections -fdata-sections +endif ifeq ($(OPT_GENERATE_MAP),yes) - LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch + ifeq ($(OPT_LINK_OPTIMIZE),yes) + LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch,--gc-sections + else + LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch + endif endif ifeq ($(OPT_GENERATE_LISTINGS),yes) CFLAGS += -Wa,-alms=$(LSTFILE) CXXFLAGS += -Wa,-alms=$(LSTFILE) ASFLAGS += -Wa,-amhls=$(LSTFILE) endif +ifneq ($(LDSCRIPT),) + LDFLAGS += -T$(LDSCRIPT) +endif # Generate dependency information SRCFLAGS += -MMD -MP -MF $(DEPDIR)/$(@F).d @@ -76,7 +111,7 @@ SRCFLAGS += -MMD -MP -MF $(DEPDIR)/$(@F).d Debug Release: all cleanDebug cleanRelease: clean -all: builddirs fakefile.o $(EXEFILE) +all: builddirs fakefile.o $(TARGETS) builddirs: @mkdir -p $(BUILDDIR) @@ -140,7 +175,41 @@ else @$(XLD) $(OBJS) $(LDFLAGS) -o $@ endif ifeq ($(OPT_COPY_EXE),yes) - @cp $(EXEFILE) . + @cp $@ . +endif + +%.hex: %.elf $(LDSCRIPT) +ifeq ($(OPT_VERBOSE_COMPILE),yes) + $(XOC) -O ihex $< $@ +else + @echo Creating $@ + @$(XOC) -O ihex $< $@ +endif +ifeq ($(OPT_COPY_EXE),yes) + @cp $@ . +endif + +%.bin: %.elf $(LDSCRIPT) +ifeq ($(USE_VERBOSE_COMPILE),yes) + $(XOC) -O binary $< $@ +else + @echo Creating $@ + @$(XOC) -O binary $< $@ +endif +ifeq ($(OPT_COPY_EXE),yes) + @cp $@ . +endif + +%.dmp: %.elf $(LDSCRIPT) +ifeq ($(USE_VERBOSE_COMPILE),yes) + $(XOD) -x --syms $< > $@ +else + @echo Creating $@ + @$(XOD) -x --syms $< > $@ + @echo Done +endif +ifeq ($(OPT_COPY_EXE),yes) + @cp $@ . endif gcov: diff --git a/tools/gmake_scripts/os_chibios.mk b/tools/gmake_scripts/os_chibios.mk new file mode 100644 index 00000000..8165c269 --- /dev/null +++ b/tools/gmake_scripts/os_chibios.mk @@ -0,0 +1,30 @@ +# See readme.txt for the make API + +# Requirements: +# +# CHIBIOS: The location of the ChibiOS code eg CHIBIOS=../chibios +# CHIBIOS_BOARD The name of the ChibiOS board eg CHIBIOS_BOARD=OLIMEX_SAM7_EX256 +# CHIBIOS_PLATFORM The name of the ChibiOS platform eg CHIBIOS_PLATFORM=AT91SAM7 +# CHIBIOS_PORT The name of the ChibiOS port eg CHIBIOS_PORT=GCC/ARM/AT91SAM7 +# + +# Optional: +# +# CHIBIOS_LDSCRIPT The name of the loader script eg CHIBIOS_LDSCRIPT=$(PORTLD)/AT91SAM7X256.ld +# + +include $(CHIBIOS)/boards/$(CHIBIOS_BOARD)/board.mk +include $(CHIBIOS)/os/hal/platforms/$(CHIBIOS_PLATFORM)/platform.mk +include $(CHIBIOS)/os/hal/hal.mk +include $(CHIBIOS)/os/ports/$(CHIBIOS_PORT)/port.mk +include $(CHIBIOS)/os/kernel/kernel.mk +LDSCRIPT= $(CHIBIOS_LDSCRIPT) +INCPATH += $(PORTINC) $(KERNINC) $(TESTINC) \ + $(HALINC) $(PLATFORMINC) $(BOARDINC) +SRC += $(PORTSRC) \ + $(KERNSRC) \ + $(TESTSRC) \ + $(HALSRC) \ + $(PLATFORMSRC) \ + $(BOARDSRC) \ + $(PORTASM) diff --git a/tools/gmake_scripts/os_linux.mk b/tools/gmake_scripts/os_linux.mk new file mode 100644 index 00000000..39610ca4 --- /dev/null +++ b/tools/gmake_scripts/os_linux.mk @@ -0,0 +1,8 @@ +# See readme.txt for the make API + +# Requirements: +# +# NONE +# + +LDFLAGS += -pthread diff --git a/tools/gmake_scripts/os_osx.mk b/tools/gmake_scripts/os_osx.mk new file mode 100644 index 00000000..8b008f4b --- /dev/null +++ b/tools/gmake_scripts/os_osx.mk @@ -0,0 +1,10 @@ +# See readme.txt for the make API + +# Requirements: +# +# OSX_SDK The location of the SDK eg. OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk +# OSX_ARCH The architecture flags eg. OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 +# + +SRCFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) +LDFLAGS += -pthread -Wl,-syslibroot,$(OSX_SDK) $(OSX_ARCH) diff --git a/tools/gmake_scripts/os_win32.chibios.mk b/tools/gmake_scripts/os_win32.chibios.mk new file mode 100644 index 00000000..5a804c64 --- /dev/null +++ b/tools/gmake_scripts/os_win32.chibios.mk @@ -0,0 +1,18 @@ +# See readme.txt for the make API + +# Requirements: +# +# CHIBIOS: The location of the ChibiOS code eg CHIBIOS=../chibios +# + +# Optional: +# + +CHIBIOS_BOARD = simulator +CHIBIOS_PLATFORM = Win32 +CHIBIOS_PORT = GCC/SIMIA32 + +DEFS += SIMULATOR SHELL_USE_IPRINTF=FALSE + +include $(GFXLIB)/tools/gmake_scripts/os_chibios.mk +include $(GFXLIB)/tools/gmake_scripts/os_win32.mk diff --git a/tools/gmake_scripts/os_win32.mk b/tools/gmake_scripts/os_win32.mk new file mode 100644 index 00000000..1b33ad85 --- /dev/null +++ b/tools/gmake_scripts/os_win32.mk @@ -0,0 +1,6 @@ +# See readme.txt for the make API + +# Requirements: +# +# NONE +# diff --git a/tools/gmake_scripts/readme.txt b/tools/gmake_scripts/readme.txt index d7389e1c..004c1495 100644 --- a/tools/gmake_scripts/readme.txt +++ b/tools/gmake_scripts/readme.txt @@ -12,8 +12,9 @@ OPT_VERBOSE_COMPILE=no|yes - Turn on full compile messages - default no OPT_GENERATE_LISTINGS=no|yes - Generate listing files - default no OPT_GENERATE_MAP=no|yes - Generate a map file - default no OPT_COPY_EXE=no|yes - Copy the final program to the local project directory - default no -OPT_NATIVEOS=win32|linux|osx|chibios|freertos|ecos|raw32|rawrtos - Mandatory: The real operating system of the machine -OPT_OS=win32|linux|osx|chibios|freertos|ecos|raw32|rawrtos - Mandatory: Should be the same as OPT_NATIVEOS except when running an OS simulator +OPT_NONSTANDARD_FLAGS=no - Turn off adding the standard compiler language flags - default no +OPT_LINK_OPTIMIZE=no - Remove unused code/data during link - default no +OPT_OS=win32|win32.chibios|linux|osx|chibios|freertos|ecos|raw32|rawrtos - Mandatory: The operating system BUILDDIR - Build Directory - default is ".build" or "bin/Debug" or "bin/Release" depending on the target PROJECT - Project Name - default is the name of the project directory @@ -23,6 +24,8 @@ XCC - C compiler - default is "$(ARCH)gcc" XCXX - C++ compiler - default is "$(ARCH)g++" XAS - Assembler - default is "$(ARCH)gcc -x assembler-with-cpp" XLD - Linker - default is "$(ARCH)gcc" +XOC - Object Copy - default is "$(ARCH)objcopy" +XOD - Object Dump - default is "$(ARCH)objdump" SRCFLAGS - Compiler defines for c, c++ and assembler files - default is "" CFLAGS - C specific compiler defines - default is "" @@ -39,15 +42,7 @@ LIBPATH - List of library include directories - default is "" DEFS - List of preprocessor defines (any -D prefix is ignored) - default is "" LIBS - List of libraries (any -l prefix is ignored) - default is "" SRC - List of c, c++ and assembler source files - default is "" - -Variables for use in variable defintions ----------------------------------------- - -SRCFILE - The original source file -OBJFILE - The output object file -LSTFILE - The listing file -MAPFILE - The map file -EXEFILE - The final project output file +LDSCRIPT - Custom loader script - default is "" Targets ---------------------------- From e6882aa5f4382e25535e0e78ac5f5d18e581eb1b Mon Sep 17 00:00:00 2001 From: inmarket Date: Thu, 2 Oct 2014 19:52:28 +1000 Subject: [PATCH 4/7] Add makefile support for absolute paths Add makefile support for cygwin gmake versus mingw gmake Add makefile support for "master" directories eg GFXLIB, CHIBIOS etc --- tools/gmake_scripts/compiler_gcc.mk | 70 +++++++++++++++++++---------- tools/gmake_scripts/library_ugfx.mk | 1 + tools/gmake_scripts/os_chibios.mk | 2 + tools/gmake_scripts/readme.txt | 1 + 4 files changed, 50 insertions(+), 24 deletions(-) diff --git a/tools/gmake_scripts/compiler_gcc.mk b/tools/gmake_scripts/compiler_gcc.mk index cb3a3e2b..196e5d5a 100644 --- a/tools/gmake_scripts/compiler_gcc.mk +++ b/tools/gmake_scripts/compiler_gcc.mk @@ -1,5 +1,29 @@ # See readme.txt for the make API +ifeq ($(basename $(OPT_OS)),win32) + # Nasty - must convert all paths into a format make can handle + PATHEXPAND := ARCH XCC XCXX XAS XLD XOC XOD PROJECT BUILDDIR SRC DEFS LIBS INCPATH LIBPATH $(PATHLIST) + + # First convert \'s to /'s + $(foreach var,$(PATHEXPAND),$(eval $(var):=$$(subst \,/,$($(var))))) + + # For cygwin gmake - need to convert all absolute paths (mingw gmake doesn't need this) + ifneq ($(findstring cygdrive,$(PATH)),) + DRIVELETTERS := a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z + $(foreach drv,$(DRIVELETTERS),$(foreach var,$(PATHEXPAND),$(eval $(var):=$$(patsubst $(drv):%,/cygdrive/$(drv)%,$($(var)))))) + endif +endif + +# Path resolution - Functions to convert a source path to a object path and visa-versa +src_obj_fn := $$(1) +obj_src_fn := $$(1) +$(foreach var,$(PATHLIST),$(eval obj_src_fn := $$$$(patsubst $(var)/%,$$$$($(var))/%,$$(obj_src_fn)))) +$(foreach var,$(PATHLIST),$(eval src_obj_fn := $$$$(patsubst $$$$($(var))/%,$(var)/%,$$(src_obj_fn)))) +src_obj_fn := $$(subst :,_drv_drv_,$$(subst ../,_dot_dot/,$(src_obj_fn))) +obj_src_fn := $$(subst _drv_drv_,:,$$(subst _dot_dot/,../,$(obj_src_fn))) +$(eval src_obj=$(src_obj_fn)) +$(eval obj_src=$(obj_src_fn)) + # Add ARCH to each of the compiler programs ifeq ($(XCC),) XCC = $(ARCH)gcc @@ -23,12 +47,12 @@ endif # Default project name is the project directory name ifeq ($(PROJECT),) ifneq ($(firstword $(abspath $(firstword $(MAKEFILE_LIST)))),$(lastword $(abspath $(firstword $(MAKEFILE_LIST))))) - $(error Your directory contains spaces. Gmake barfs at that. Please define PROJECT) + $(error Your directory contains spaces. Gmake barfs at that. Please define PROJECT) endif PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))) endif -# Output directory and files +# Output directories ifeq ($(BUILDDIR),) ifeq ($(MAKECMDGOALS),Debug) BUILDDIR = bin/Debug @@ -46,13 +70,10 @@ ifeq ($(BUILDDIR),) BUILDDIR = .build endif endif - OBJDIR = $(BUILDDIR)/obj DEPDIR = $(BUILDDIR)/dep -SRCFILE = $< -OBJFILE = $@ -LSTFILE = $(@:.o=.lst) +# Output files MAPFILE = $(BUILDDIR)/$(PROJECT).map EXEFILE = ifeq ($(basename $(OPT_OS)),win32) @@ -73,10 +94,12 @@ ifeq ($(EXEFILE),) TARGETS = $(EXEFILE) $(BUILDDIR)/$(PROJECT).hex $(BUILDDIR)/$(PROJECT).bin $(BUILDDIR)/$(PROJECT).dmp endif +# Combine all our compiler arguments SRCFLAGS += -I. $(patsubst %,-I%,$(INCPATH)) $(patsubst %,-D%,$(patsubst -D%,%,$(DEFS))) LDFLAGS += $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(patsubst -l%,%,$(LIBS))) -OBJS = $(addprefix $(OBJDIR)/,$(subst ../,_dot_dot/,$(addsuffix .o,$(basename $(SRC))))) +OBJS = $(addprefix $(OBJDIR)/,$(call src_obj,$(addsuffix .o,$(basename $(SRC))))) +# Handle make API options that affect compiler arguments ifneq ($(OPT_NONSTANDARD_FLAGS),yes) SRCFLAGS += -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm endif @@ -91,9 +114,9 @@ ifeq ($(OPT_GENERATE_MAP),yes) endif endif ifeq ($(OPT_GENERATE_LISTINGS),yes) - CFLAGS += -Wa,-alms=$(LSTFILE) - CXXFLAGS += -Wa,-alms=$(LSTFILE) - ASFLAGS += -Wa,-amhls=$(LSTFILE) + CFLAGS += -Wa,-alms=$(@:.o=.lst) + CXXFLAGS += -Wa,-alms=$(@:.o=.lst) + ASFLAGS += -Wa,-amhls=$(@:.o=.lst) endif ifneq ($(LDSCRIPT),) LDFLAGS += -T$(LDSCRIPT) @@ -102,10 +125,7 @@ endif # Generate dependency information SRCFLAGS += -MMD -MP -MF $(DEPDIR)/$(@F).d -# -# makefile rules -# - +# Targets .PHONY: builddirs fakefile.o all clean Debug Release cleanDebug cleanRelease Debug Release: all @@ -124,8 +144,10 @@ ifneq ($(OPT_VERBOSE_COMPILE),yes) @echo endif +# Implicit Rules + .SECONDEXPANSION: -$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.c) +$(OBJDIR)/%.o : $$(call obj_src,%.c) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) @echo @@ -135,7 +157,7 @@ else @$(XCC) -c $(CPPFLAGS) $(CFLAGS) $(SRCFLAGS) $< -o $@ endif -$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.cpp) +$(OBJDIR)/%.o : $$(call obj_src,%.cpp) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) @echo @@ -145,7 +167,7 @@ else @$(XCXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SRCFLAGS) $< -o $@ endif -$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.c++) +$(OBJDIR)/%.o : $$(call obj_src,%.c++) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) @echo @@ -155,7 +177,7 @@ else @$(XCXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SRCFLAGS) $< -o $@ endif -$(OBJDIR)/%.o : $$(subst _dot_dot/,../,%.s) +$(OBJDIR)/%.o : $$(call obj_src,%.s) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) @echo @@ -165,7 +187,7 @@ else @$(XAS) -c $(CPPFLAGS) $(ASFLAGS) $(SRCFLAGS) $< -o $@ endif -$(EXEFILE): $(OBJS) +$(EXEFILE): $(OBJS) $(LDSCRIPT) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) @echo @@ -178,7 +200,7 @@ ifeq ($(OPT_COPY_EXE),yes) @cp $@ . endif -%.hex: %.elf $(LDSCRIPT) +%.hex: %.elf ifeq ($(OPT_VERBOSE_COMPILE),yes) $(XOC) -O ihex $< $@ else @@ -189,7 +211,7 @@ ifeq ($(OPT_COPY_EXE),yes) @cp $@ . endif -%.bin: %.elf $(LDSCRIPT) +%.bin: %.elf ifeq ($(USE_VERBOSE_COMPILE),yes) $(XOC) -O binary $< $@ else @@ -200,7 +222,7 @@ ifeq ($(OPT_COPY_EXE),yes) @cp $@ . endif -%.dmp: %.elf $(LDSCRIPT) +%.dmp: %.elf ifeq ($(USE_VERBOSE_COMPILE),yes) $(XOD) -x --syms $< > $@ else @@ -212,16 +234,16 @@ ifeq ($(OPT_COPY_EXE),yes) @cp $@ . endif +# Goodness knows why we would want this. gcov: -mkdir gcov $(COV) -u $(subst /,\,$(SRC)) -mv *.gcov ./gcov -# # Include the dependency files, should be the last of the makefile except for clean -# -include $(shell mkdir -p $(DEPDIR) 2>/dev/null) $(wildcard $(DEPDIR)/*) +# Clean clean: -rm -fR $(BUILDDIR) diff --git a/tools/gmake_scripts/library_ugfx.mk b/tools/gmake_scripts/library_ugfx.mk index 7dbf9d99..24c501fe 100644 --- a/tools/gmake_scripts/library_ugfx.mk +++ b/tools/gmake_scripts/library_ugfx.mk @@ -12,6 +12,7 @@ # GFXDEMO: Compile a uGFX standard demo? If blank you need to include your own project files. eg GFXDEMO=modules/gwin/widgets # +PATHLIST += GFXLIB include $(GFXLIB)/gfx.mk SRC += $(GFXSRC) diff --git a/tools/gmake_scripts/os_chibios.mk b/tools/gmake_scripts/os_chibios.mk index 8165c269..a81c9803 100644 --- a/tools/gmake_scripts/os_chibios.mk +++ b/tools/gmake_scripts/os_chibios.mk @@ -13,6 +13,8 @@ # CHIBIOS_LDSCRIPT The name of the loader script eg CHIBIOS_LDSCRIPT=$(PORTLD)/AT91SAM7X256.ld # +PATHLIST += CHIBIOS + include $(CHIBIOS)/boards/$(CHIBIOS_BOARD)/board.mk include $(CHIBIOS)/os/hal/platforms/$(CHIBIOS_PLATFORM)/platform.mk include $(CHIBIOS)/os/hal/hal.mk diff --git a/tools/gmake_scripts/readme.txt b/tools/gmake_scripts/readme.txt index 004c1495..979ca364 100644 --- a/tools/gmake_scripts/readme.txt +++ b/tools/gmake_scripts/readme.txt @@ -18,6 +18,7 @@ OPT_OS=win32|win32.chibios|linux|osx|chibios|freertos|ecos|raw32|rawrtos - Manda BUILDDIR - Build Directory - default is ".build" or "bin/Debug" or "bin/Release" depending on the target PROJECT - Project Name - default is the name of the project directory +PATHLIST - A list of variable names of "master" paths that contain source and other objects of interest - default is "" ARCH - Architecture - default is "" XCC - C compiler - default is "$(ARCH)gcc" From bbc7b6e039d179c92fe53a6ad522131e64412432 Mon Sep 17 00:00:00 2001 From: inmarket Date: Sat, 4 Oct 2014 17:12:33 +1000 Subject: [PATCH 5/7] Update to makefiles to support ChibiOS v3, making ARM thumb targets, CPU specific flags etc Also put license in the gmake master scripts. --- .../base/Linux-Framebuffer/example/Makefile | 4 +- boards/base/Linux/example/Makefile | 4 +- .../example_chibios_2.x/Makefile | 282 ++++-------------- .../example_chibios_3.x/Makefile | 279 ++++------------- boards/base/OSX/example/Makefile | 4 +- .../Olimex-SAM7EX256-GE8/example/Makefile | 14 +- .../Olimex-SAM7EX256-GE8/example/readme.txt | 2 - boards/base/Win32/example/Makefile | 1 + boards/base/Win32/example/readme.txt | 5 +- tools/gmake_scripts/compiler_gcc.mk | 226 +++++++++----- tools/gmake_scripts/library_ugfx.mk | 7 + tools/gmake_scripts/os_chibios.mk | 50 +++- tools/gmake_scripts/os_linux.mk | 7 + tools/gmake_scripts/os_osx.mk | 10 +- tools/gmake_scripts/os_win32.chibios.mk | 7 + tools/gmake_scripts/os_win32.mk | 8 + tools/gmake_scripts/readme.txt | 12 + 17 files changed, 377 insertions(+), 545 deletions(-) diff --git a/boards/base/Linux-Framebuffer/example/Makefile b/boards/base/Linux-Framebuffer/example/Makefile index 76b2022a..fb0c1b7a 100644 --- a/boards/base/Linux-Framebuffer/example/Makefile +++ b/boards/base/Linux-Framebuffer/example/Makefile @@ -13,6 +13,8 @@ OPT_LINK_OPTIMIZE = yes OPT_NONSTANDARD_FLAGS = no OPT_OS = linux + # Change this next setting (or add the explicit compiler flags) if you are not compiling for x86 linux + OPT_CPU = x86 # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables @@ -30,13 +32,13 @@ ARCH = SRCFLAGS = -ggdb -O0 -SRCFLAGS+= -m32 CFLAGS = CXXFLAGS = ASFLAGS = LDFLAGS = SRC = +OBJS = DEFS = LIBS = INCPATH = diff --git a/boards/base/Linux/example/Makefile b/boards/base/Linux/example/Makefile index d6402c8a..3d6d3d60 100644 --- a/boards/base/Linux/example/Makefile +++ b/boards/base/Linux/example/Makefile @@ -13,6 +13,8 @@ OPT_LINK_OPTIMIZE = yes OPT_NONSTANDARD_FLAGS = no OPT_OS = linux + # Change this next setting (or add the explicit compiler flags) if you are not compiling for x86 linux + OPT_CPU = x86 # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables @@ -30,13 +32,13 @@ ARCH = SRCFLAGS = -ggdb -O0 -SRCFLAGS+= -m32 CFLAGS = CXXFLAGS = ASFLAGS = LDFLAGS = SRC = +OBJS = DEFS = LIBS = INCPATH = diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile index 7b982d80..ac483689 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile @@ -1,236 +1,66 @@ -############################################################################## -# Build global options -# NOTE: Can be overridden externally. +# Possible Targets: all clean Debug cleanDebug Release cleanRelease + +############################################################################################## +# Settings # -# Compiler options here. -ifeq ($(USE_OPT),) - # Replace -O0 with -O2 for a production build. -O2 just messes with the debugger. - USE_OPT = -O0 -g -fomit-frame-pointer -falign-functions=16 +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_VERBOSE_COMPILE = no + OPT_GENERATE_LISTINGS = yes + OPT_GENERATE_MAP = yes + OPT_COPY_EXE = no + OPT_LINK_OPTIMIZE = yes + OPT_NONSTANDARD_FLAGS = no + OPT_NATIVEOS = chibios + OPT_OS = chibios + OPT_THUMB = yes + OPT_CPU = stm32m4 + +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = Mikromedia-STM32-M4-ILI9341 + #GFXDRIVERS = multiple/uGFXnet + GFXDEMO = modules/gdisp/basics + +# ChibiOS settings +ifeq ($(OPT_OS),chibios) + # See $(GFXLIB)/tools/gmake_scripts/os_chibios.mk for the list of variables + CHIBIOS = ../ChibiOS + CHIBIOS_BOARD = + CHIBIOS_PLATFORM = STM32F4xx + CHIBIOS_PORT = GCC/ARMCMx/STM32F4xx + CHIBIOS_DEFS = + CHIBIOS_LDSCRIPT = STM32F407xG.ld + # We define a non standard board script as this is not a standard ChibiOS supported board + include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.mk endif -# C specific options here (added to USE_OPT). -ifeq ($(USE_COPT),) - USE_COPT = -endif - -# C++ specific options here (added to USE_OPT). -ifeq ($(USE_CPPOPT),) - USE_CPPOPT = -fno-rtti -endif - -# Enable this if you want the linker to remove unused code and data -ifeq ($(USE_LINK_GC),) - USE_LINK_GC = yes -endif - -# If enabled, this option allows to compile the application in THUMB mode. -ifeq ($(USE_THUMB),) - USE_THUMB = yes -endif - -# Enable this if you want to see the full log while compiling. -ifeq ($(USE_VERBOSE_COMPILE),) - USE_VERBOSE_COMPILE = no -endif - -# -# Build global options -############################################################################## - -############################################################################## -# Architecture or project specific options +############################################################################################## +# Set these for your project # -# Enables the use of FPU on Cortex-M4. -# Enable this if you really want to use the STM FWLib. -ifeq ($(USE_FPU),) - USE_FPU = no -endif +ARCH = arm-none-eabi- +SRCFLAGS = -ggdb -O0 +CFLAGS = +CXXFLAGS = -fno-rtti +ASFLAGS = +LDFLAGS = -# Enable this if you really want to use the STM FWLib. -ifeq ($(USE_FWLIB),) - USE_FWLIB = no -endif +SRC = +OBJS = +DEFS = +LIBS = +INCPATH = +LIBPATH = +LDSCRIPT = -# -# Architecture or project specific options -############################################################################## - -############################################################################## -# Project, sources and paths +############################################################################################## +# These should be at the end # -SW = .. - -# Define project name here -PROJECT = ch - -# Imported source files and paths -CHIBIOS = ../ChibiOS -#include $(CHIBIOS)/boards/MIKROMEDIA_STM32_M4/board.mk # Not a standard ChibiOS supported board -include $(CHIBIOS)/os/hal/platforms/STM32F4xx/platform.mk -include $(CHIBIOS)/os/hal/hal.mk -include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk -include $(CHIBIOS)/os/kernel/kernel.mk -LDSCRIPT= $(PORTLD)/STM32F407xG.ld - -# Imported source files and paths for uGFX -GFXLIB = ../ugfx -include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/board.mk -include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.mk # The replacement ChibiOS board files -include $(GFXLIB)/gfx.mk - -# Where is our source code - alter these for your project. -# Either just include the demo makefile or add your own definitions -include $(GFXLIB)/demos/modules/gdisp/basics/demo.mk -#MYFILES = my-project-directory -#MYCSRC = $(MYFILES)/main.c -#MYDEFS = - -# C sources that can be compiled in ARM or THUMB mode depending on the global -# setting. -CSRC = $(PORTSRC) \ - $(KERNSRC) \ - $(TESTSRC) \ - $(HALSRC) \ - $(PLATFORMSRC) \ - $(BOARDSRC) \ - $(GFXSRC) \ - $(MYCSRC) - -# C++ sources that can be compiled in ARM or THUMB mode depending on the global -# setting. -CPPSRC = - -# C sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACSRC = - -# C++ sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACPPSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCPPSRC = - -# List ASM source files here -ASMSRC = $(PORTASM) - -INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) \ - $(GFXINC) \ - $(MYFILES) - -# -# Project, sources and paths -############################################################################## - -############################################################################## -# Compiler settings -# - -MCU = cortex-m4 - -#TRGT = arm-elf- -TRGT = arm-none-eabi- -CC = $(TRGT)gcc -CPPC = $(TRGT)g++ -# Enable loading with g++ only if you need C++ runtime support. -# NOTE: You can use C++ even without C++ support if you are careful. C++ -# runtime support makes code size explode. -LD = $(TRGT)gcc -#LD = $(TRGT)g++ -CP = $(TRGT)objcopy -AS = $(TRGT)gcc -x assembler-with-cpp -OD = $(TRGT)objdump -SZ = $(TRGT)size -HEX = $(CP) -O ihex -BIN = $(CP) -O binary - -# ARM-specific options here -AOPT = - -# THUMB-specific options here -TOPT = -mthumb -DTHUMB - -# Define C warning options here -CWARN = -Wall -Wextra -Wstrict-prototypes - -# Define C++ warning options here -CPPWARN = -Wall -Wextra - -# -# Compiler settings -############################################################################## - -############################################################################## -# Start of default section -# - -# List all default C defines here, like -D_DEBUG=1 -DDEFS = $(GFXDEFS) - -# List all default ASM defines here, like -D_DEBUG=1 -DADEFS = - -# List all default directories to look for include files here -DINCDIR = - -# List the default directory to look for the libraries here -DLIBDIR = - -# List all default libraries here -DLIBS = - -# -# End of default section -############################################################################## - -############################################################################## -# Start of user section -# - -# List all user C define here, like -D_DEBUG=1 -UDEFS = - -# Define ASM defines here -UADEFS = - -# List all user directories here -UINCDIR = - -# List the user directory to look for the libraries here -ULIBDIR = - -# List all user libraries here -ULIBS = - -# -# End of user defines -############################################################################## - -ifeq ($(USE_FPU),yes) - USE_OPT += -mfloat-abi=softfp -mfpu=fpv4-sp-d16 -fsingle-precision-constant - DDEFS += -DCORTEX_USE_FPU=TRUE -else - DDEFS += -DCORTEX_USE_FPU=FALSE -endif - -ifeq ($(USE_FWLIB),yes) - include $(CHIBIOS)/ext/stm32lib/stm32lib.mk - CSRC += $(STM32SRC) - INCDIR += $(STM32INC) - USE_OPT += -DUSE_STDPERIPH_DRIVER -endif - -include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk +include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk +include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk +# *** EOF *** diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile index 4f55e0fd..d19c3d28 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile @@ -1,53 +1,71 @@ -############################################################################## -# Build global options -# NOTE: Can be overridden externally. +# Possible Targets: all clean Debug cleanDebug Release cleanRelease + +############################################################################################## +# Settings # -# Compiler options here. -ifeq ($(USE_OPT),) - # Replace -O0 with -O2 for a production build. -O2 just messes with the debugger. - USE_OPT = -O0 -g -fomit-frame-pointer -falign-functions=16 +# General settings + # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables + OPT_VERBOSE_COMPILE = no + OPT_GENERATE_LISTINGS = yes + OPT_GENERATE_MAP = yes + OPT_COPY_EXE = no + OPT_LINK_OPTIMIZE = yes + OPT_NONSTANDARD_FLAGS = no + OPT_NATIVEOS = chibios + OPT_OS = chibios + OPT_THUMB = yes + OPT_CPU = stm32m4 + +# uGFX settings + # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables + GFXLIB = ../uGFX + GFXBOARD = Mikromedia-STM32-M4-ILI9341 + #GFXDRIVERS = multiple/uGFXnet + GFXDEMO = modules/gdisp/basics + +# ChibiOS settings +ifeq ($(OPT_OS),chibios) + # See $(GFXLIB)/tools/gmake_scripts/os_chibios.mk for the list of variables + CHIBIOS = ../ChibiOS + CHBIOS_VERSION = 3 + CHIBIOS_BOARD = + CHIBIOS_PLATFORM = STM32/STM32F4xx + CHIBIOS_PORT = ARMCMx/compilers/GCC/mk/port_stm32f4xx + CHIBIOS_DEFS = + CHIBIOS_LDSCRIPT = STM32F407xG.ld + # We define a non standard board script as this is not a standard ChibiOS supported board + include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.mk endif -# C specific options here (added to USE_OPT). -ifeq ($(USE_COPT),) - USE_COPT = -endif - -# C++ specific options here (added to USE_OPT). -ifeq ($(USE_CPPOPT),) - USE_CPPOPT = -fno-rtti -endif - -# Enable this if you want the linker to remove unused code and data -ifeq ($(USE_LINK_GC),) - USE_LINK_GC = yes -endif - -# Linker extra options here. -ifeq ($(USE_LDOPT),) - USE_LDOPT = -endif - -# Enable this if you want link time optimizations (LTO) -ifeq ($(USE_LTO),) - ### disable as can cause segfault - USE_LTO = no -endif - -# If enabled, this option allows to compile the application in THUMB mode. -ifeq ($(USE_THUMB),) - USE_THUMB = yes -endif - -# Enable this if you want to see the full log while compiling. -ifeq ($(USE_VERBOSE_COMPILE),) - USE_VERBOSE_COMPILE = no -endif +############################################################################################## +# Set these for your project # -# Build global options -############################################################################## +ARCH = arm-none-eabi- +SRCFLAGS = -ggdb -O0 +CFLAGS = +CXXFLAGS = -fno-rtti +ASFLAGS = +LDFLAGS = + +SRC = +OBJS = +DEFS = +LIBS = +INCPATH = +LIBPATH = +LDSCRIPT = + +############################################################################################## +# These should be at the end +# + +include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk +include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk +include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk +# *** EOF *** +############################################################################## ############################################################################### # Architecture or project specific options # @@ -64,178 +82,5 @@ ifeq ($(USE_EXCEPTIONS_STACKSIZE),) USE_EXCEPTIONS_STACKSIZE = 0x400 endif -# Enables the use of FPU on Cortex-M4 (no, softfp, hard). -ifeq ($(USE_FPU),) - USE_FPU = no -endif - -# -# Architecture or project specific options -############################################################################## - -############################################################################## -# Project, sources and paths -# - -SW = .. - -# Define project name here -PROJECT = ch - -# Imported source files and paths -CHIBIOS = ../ChibiOS -#include $(CHIBIOS)/boards/MIKROMEDIA_STM32_M4/board.mk # Not a standard ChibiOS supported board -include $(CHIBIOS)/os/hal/hal.mk -include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk -include $(CHIBIOS)/os/hal/osal/rt/osal.mk -include $(CHIBIOS)/os/rt/rt.mk -include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_stm32f4xx.mk -LDSCRIPT= $(PORTLD)/STM32F407xG.ld - -# Imported source files and paths for uGFX -GFXLIB = ../ugfx -include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/board.mk -include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.mk # The replacement ChibiOS board files -include $(GFXLIB)/gfx.mk - -# Where is our source code - alter these for your project. -# Either just include the demo makefile or add your own definitions -include $(GFXLIB)/demos/modules/gdisp/basics/demo.mk -#MYFILES = my-project-directory -#MYCSRC = $(MYFILES)/main.c -#MYDEFS = - -# C sources that can be compiled in ARM or THUMB mode depending on the global -# setting. -CSRC = $(PORTSRC) \ - $(KERNSRC) \ - $(TESTSRC) \ - $(HALSRC) \ - $(PLATFORMSRC) \ - $(BOARDSRC) \ - $(GFXSRC) \ - $(MYCSRC) - -# C++ sources that can be compiled in ARM or THUMB mode depending on the global -# setting. -CPPSRC = - -# C sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACSRC = - -# C++ sources to be compiled in ARM mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -ACPPSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCSRC = - -# C sources to be compiled in THUMB mode regardless of the global setting. -# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler -# option that results in lower performance and larger code size. -TCPPSRC = - -# List ASM source files here -ASMSRC = $(PORTASM) - -INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(OSALINC) $(PLATFORMINC) $(BOARDINC) \ - $(GFXINC) \ - $(MYFILES) - -# -# Project, sources and paths -############################################################################## - -############################################################################## -# Compiler settings -# - -MCU = cortex-m4 - -#TRGT = arm-elf- -TRGT = arm-none-eabi- -CC = $(TRGT)gcc -CPPC = $(TRGT)g++ -# Enable loading with g++ only if you need C++ runtime support. -# NOTE: You can use C++ even without C++ support if you are careful. C++ -# runtime support makes code size explode. -LD = $(TRGT)gcc -#LD = $(TRGT)g++ -CP = $(TRGT)objcopy -AS = $(TRGT)gcc -x assembler-with-cpp -OD = $(TRGT)objdump -SZ = $(TRGT)size -HEX = $(CP) -O ihex -BIN = $(CP) -O binary - -# ARM-specific options here -AOPT = - -# THUMB-specific options here -TOPT = -mthumb -DTHUMB - -# Define C warning options here -CWARN = -Wall -Wextra -Wstrict-prototypes - -# Define C++ warning options here -CPPWARN = -Wall -Wextra - -# -# Compiler settings -############################################################################## - -############################################################################## -# Start of default section -# - -# List all default C defines here, like -D_DEBUG=1 -DDEFS = $(GFXDEFS) - -# List all default ASM defines here, like -D_DEBUG=1 -DADEFS = - -# List all default directories to look for include files here -DINCDIR = - -# List the default directory to look for the libraries here -DLIBDIR = - -# List all default libraries here -DLIBS = - -# -# End of default section -############################################################################## - -############################################################################## -# Start of user section -# - -# List all user C define here, like -D_DEBUG=1 -UDEFS = - -# Define ASM defines here -UADEFS = - -# List all user directories here -UINCDIR = - -# List the user directory to look for the libraries here -ULIBDIR = - -# List all user libraries here -ULIBS = - -# -# End of user defines -############################################################################## - - RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC include $(RULESPATH)/rules.mk \ No newline at end of file diff --git a/boards/base/OSX/example/Makefile b/boards/base/OSX/example/Makefile index 956608ff..5bbcb5df 100644 --- a/boards/base/OSX/example/Makefile +++ b/boards/base/OSX/example/Makefile @@ -24,7 +24,7 @@ # OSX settings # See $(GFXLIB)/tools/gmake_scripts/os_osx.mk for the list of variables OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk - OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 + OSX_ARCH = -mmacosx-version-min=10.3 ############################################################################################## # Set these for your project @@ -32,13 +32,13 @@ ARCH = SRCFLAGS = -ggdb -O0 -SRCFLAGS+= -m32 CFLAGS = CXXFLAGS = ASFLAGS = LDFLAGS = SRC = +OBJS = DEFS = LIBS = INCPATH = diff --git a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile index aa11abad..9130ed5a 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile +++ b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile @@ -14,6 +14,8 @@ OPT_NONSTANDARD_FLAGS = no OPT_NATIVEOS = chibios OPT_OS = chibios + OPT_THUMB = no + OPT_CPU = at91sam7 # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables @@ -30,9 +32,7 @@ ifeq ($(OPT_OS),chibios) CHIBIOS_PLATFORM = AT91SAM7 CHIBIOS_PORT = GCC/ARM/AT91SAM7 CHIBIOS_DEFS = - #CHIBIOS_LDSCRIPT = $(PORTLD)/AT91SAM7X256.ld - # We define a non standard linker script here just to give us some more stack space - CHIBIOS_LDSCRIPT = linker.ld + CHIBIOS_LDSCRIPT = AT91SAM7X256.ld endif ############################################################################################## @@ -41,18 +41,20 @@ endif ARCH = arm-none-eabi- SRCFLAGS = -ggdb -O0 -SRCFLAGS+= -mcpu=arm7tdmi -mabi=apcs-gnu -mno-thumb-interwork CFLAGS = CXXFLAGS = -fno-rtti ASFLAGS = -LDFLAGS = -mcpu=arm7tdmi +LDFLAGS = SRC = +OBJS = DEFS = LIBS = INCPATH = LIBPATH = -LDSCRIPT = + +# We override the standard ChibiOS linker script here just to give us some more stack space +LDSCRIPT = linker.ld ############################################################################################## # These should be at the end diff --git a/boards/base/Olimex-SAM7EX256-GE8/example/readme.txt b/boards/base/Olimex-SAM7EX256-GE8/example/readme.txt index a357dc52..7d0909fd 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/example/readme.txt +++ b/boards/base/Olimex-SAM7EX256-GE8/example/readme.txt @@ -1,3 +1 @@ Copy these files into your own project directory and alter them to suite. - -In particular look at the MYFILES definition and the MYCSRC definition. \ No newline at end of file diff --git a/boards/base/Win32/example/Makefile b/boards/base/Win32/example/Makefile index 4bf6c603..5670f0f1 100644 --- a/boards/base/Win32/example/Makefile +++ b/boards/base/Win32/example/Makefile @@ -43,6 +43,7 @@ ASFLAGS = LDFLAGS = SRC = +OBJS = DEFS = LIBS = INCPATH = diff --git a/boards/base/Win32/example/readme.txt b/boards/base/Win32/example/readme.txt index 78b8552b..23cc1aec 100644 --- a/boards/base/Win32/example/readme.txt +++ b/boards/base/Win32/example/readme.txt @@ -3,7 +3,4 @@ Copy these files into your own project directory and alter them to suite. Notes: 1/ This makefile uses the MINGW compiler tool chain and was run using the cygwin make. -2/ At the top of the Makefile is the define USE_CHIBIOS. Win32 can build uGFX for either - native Win32 (the default) or for the ChibiOS simulator. -3/ The files chconf.h and halconf.h are only needed if compiling for the ChibiOS simulator. -4/ Look at the MYFILES definition and the MYCSRC definition. +2/ The files chconf.h and halconf.h are only needed if compiling for the ChibiOS simulator. diff --git a/tools/gmake_scripts/compiler_gcc.mk b/tools/gmake_scripts/compiler_gcc.mk index 196e5d5a..bc3c216b 100644 --- a/tools/gmake_scripts/compiler_gcc.mk +++ b/tools/gmake_scripts/compiler_gcc.mk @@ -1,24 +1,33 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# # See readme.txt for the make API +# ifeq ($(basename $(OPT_OS)),win32) - # Nasty - must convert all paths into a format make can handle - PATHEXPAND := ARCH XCC XCXX XAS XLD XOC XOD PROJECT BUILDDIR SRC DEFS LIBS INCPATH LIBPATH $(PATHLIST) - - # First convert \'s to /'s - $(foreach var,$(PATHEXPAND),$(eval $(var):=$$(subst \,/,$($(var))))) - - # For cygwin gmake - need to convert all absolute paths (mingw gmake doesn't need this) - ifneq ($(findstring cygdrive,$(PATH)),) - DRIVELETTERS := a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - $(foreach drv,$(DRIVELETTERS),$(foreach var,$(PATHEXPAND),$(eval $(var):=$$(patsubst $(drv):%,/cygdrive/$(drv)%,$($(var)))))) - endif + # Nasty - must convert all paths into a format make can handle + PATHEXPAND := ARCH XCC XCXX XAS XLD XOC XOD XSZ PROJECT BUILDDIR SRC DEFS LIBS INCPATH LIBPATH $(PATHLIST) + + # First convert \'s to /'s + $(foreach var,$(PATHEXPAND),$(eval $(var):=$$(subst \,/,$($(var))))) + + # For cygwin gmake - need to convert all absolute paths (mingw gmake doesn't need this) + ifneq ($(findstring cygdrive,$(PATH)),) + DRIVELETTERS := a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z + $(foreach drv,$(DRIVELETTERS),$(foreach var,$(PATHEXPAND),$(eval $(var):=$$(patsubst $(drv):%,/cygdrive/$(drv)%,$($(var)))))) + endif endif # Path resolution - Functions to convert a source path to a object path and visa-versa src_obj_fn := $$(1) obj_src_fn := $$(1) -$(foreach var,$(PATHLIST),$(eval obj_src_fn := $$$$(patsubst $(var)/%,$$$$($(var))/%,$$(obj_src_fn)))) -$(foreach var,$(PATHLIST),$(eval src_obj_fn := $$$$(patsubst $$$$($(var))/%,$(var)/%,$$(src_obj_fn)))) +$(foreach var,$(PATHLIST),$(eval obj_src_fn := $$$$(patsubst $(var)/%,$$$$($(var))/%,$$(obj_src_fn)))) +$(foreach var,$(PATHLIST),$(eval src_obj_fn := $$$$(patsubst $$$$($(var))/%,$(var)/%,$$(src_obj_fn)))) src_obj_fn := $$(subst :,_drv_drv_,$$(subst ../,_dot_dot/,$(src_obj_fn))) obj_src_fn := $$(subst _drv_drv_,:,$$(subst _dot_dot/,../,$(obj_src_fn))) $(eval src_obj=$(src_obj_fn)) @@ -26,122 +35,188 @@ $(eval obj_src=$(obj_src_fn)) # Add ARCH to each of the compiler programs ifeq ($(XCC),) - XCC = $(ARCH)gcc + XCC = $(ARCH)gcc endif ifeq ($(XCXX),) - XCXX = $(ARCH)g++ + XCXX = $(ARCH)g++ endif ifeq ($(XAS),) - XAS = $(ARCH)gcc -x assembler-with-cpp + XAS = $(ARCH)gcc -x assembler-with-cpp endif ifeq ($(XLD),) - XLD = $(ARCH)gcc + XLD = $(ARCH)gcc endif ifeq ($(XOC),) - XOC = $(ARCH)objcopy + XOC = $(ARCH)objcopy endif ifeq ($(XOD),) - XOD = $(ARCH)objdump + XOD = $(ARCH)objdump endif +ifeq ($(XSZ),) + XSZ = $(ARCH)size + endif # Default project name is the project directory name ifeq ($(PROJECT),) - ifneq ($(firstword $(abspath $(firstword $(MAKEFILE_LIST)))),$(lastword $(abspath $(firstword $(MAKEFILE_LIST))))) - $(error Your directory contains spaces. Gmake barfs at that. Please define PROJECT) - endif - PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))) + ifneq ($(firstword $(abspath $(firstword $(MAKEFILE_LIST)))),$(lastword $(abspath $(firstword $(MAKEFILE_LIST))))) + $(error Your directory contains spaces. Gmake barfs at that. Please define PROJECT) + endif + PROJECT := $(notdir $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST)))))) endif # Output directories ifeq ($(BUILDDIR),) - ifeq ($(MAKECMDGOALS),Debug) - BUILDDIR = bin/Debug - endif - ifeq ($(MAKECMDGOALS),Release) - BUILDDIR = bin/Release - endif - ifeq ($(MAKECMDGOALS),cleanDebug) - BUILDDIR = bin/Debug - endif - ifeq ($(MAKECMDGOALS),cleanRelease) - BUILDDIR = bin/Release - endif - ifeq ($(BUILDDIR),) - BUILDDIR = .build - endif + ifeq ($(MAKECMDGOALS),Debug) + BUILDDIR = bin/Debug + endif + ifeq ($(MAKECMDGOALS),Release) + BUILDDIR = bin/Release + endif + ifeq ($(MAKECMDGOALS),cleanDebug) + BUILDDIR = bin/Debug + endif + ifeq ($(MAKECMDGOALS),cleanRelease) + BUILDDIR = bin/Release + endif + ifeq ($(BUILDDIR),) + BUILDDIR = .build + endif endif OBJDIR = $(BUILDDIR)/obj DEPDIR = $(BUILDDIR)/dep # Output files MAPFILE = $(BUILDDIR)/$(PROJECT).map +FAKEFILE= fakefile.o EXEFILE = ifeq ($(basename $(OPT_OS)),win32) - EXEFILE = $(BUILDDIR)/$(PROJECT).exe - TARGETS = $(EXEFILE) + EXEFILE = $(BUILDDIR)/$(PROJECT).exe + TARGETS = $(EXEFILE) endif ifeq ($(basename $(OPT_OS)),linux) - EXEFILE = $(BUILDDIR)/$(PROJECT) - TARGETS = $(EXEFILE) + EXEFILE = $(BUILDDIR)/$(PROJECT) + TARGETS = $(EXEFILE) endif ifeq ($(basename $(OPT_OS)),osx) - EXEFILE = $(BUILDDIR)/$(PROJECT) - TARGETS = $(EXEFILE) + EXEFILE = $(BUILDDIR)/$(PROJECT) + TARGETS = $(EXEFILE) endif ifeq ($(EXEFILE),) - LDFLAGS += -nostartfiles - EXEFILE = $(BUILDDIR)/$(PROJECT).elf - TARGETS = $(EXEFILE) $(BUILDDIR)/$(PROJECT).hex $(BUILDDIR)/$(PROJECT).bin $(BUILDDIR)/$(PROJECT).dmp + LDFLAGS += -nostartfiles + EXEFILE = $(BUILDDIR)/$(PROJECT).elf + TARGETS = $(EXEFILE) $(BUILDDIR)/$(PROJECT).hex $(BUILDDIR)/$(PROJECT).bin $(BUILDDIR)/$(PROJECT).dmp elfstats endif -# Combine all our compiler arguments -SRCFLAGS += -I. $(patsubst %,-I%,$(INCPATH)) $(patsubst %,-D%,$(patsubst -D%,%,$(DEFS))) -LDFLAGS += $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(patsubst -l%,%,$(LIBS))) -OBJS = $(addprefix $(OBJDIR)/,$(call src_obj,$(addsuffix .o,$(basename $(SRC))))) +# Generate our object file lists +OBJS_THUMB += $(addprefix $(OBJDIR)/,$(call src_obj,$(addsuffix .o,$(basename $(SRC_THUMB))))) +OBJS_NOTHUMB += $(addprefix $(OBJDIR)/,$(call src_obj,$(addsuffix .o,$(basename $(SRC_NOTHUMB))))) +ifeq ($(OPT_THUMB),yes) + OBJS_THUMB += $(OBJS) $(addprefix $(OBJDIR)/,$(call src_obj,$(addsuffix .o,$(basename $(SRC))))) +else + OBJS_NOTHUMB += $(OBJS) $(addprefix $(OBJDIR)/,$(call src_obj,$(addsuffix .o,$(basename $(SRC))))) +endif +ifneq ($(OBJS_THUMB),) + ifneq ($(OBJS_NOTHUMB),) + # Mixed ARM and THUMB mode - enabled only if needed because it kills performance. + SRCFLAGS += -mthumb-interwork + LDFLAGS += -mthumb-interwork + DEFS += THUMB_PRESENT + else + # Pure THUMB mode, THUMB C code cannot be called by ARM asm code directly. + LDFLAGS += -mthumb + DEFS += THUMB_PRESENT THUMB_NO_INTERWORKING + FAKEFILE= fakethumbfile.o + endif +endif # Handle make API options that affect compiler arguments ifneq ($(OPT_NONSTANDARD_FLAGS),yes) - SRCFLAGS += -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm + SRCFLAGS += -fomit-frame-pointer -Wall -Wextra -Wstrict-prototypes -fverbose-asm endif ifeq ($(OPT_LINK_OPTIMIZE),yes) - SRCFLAGS += -ffunction-sections -fdata-sections + SRCFLAGS += -ffunction-sections -fdata-sections -fno-common -flto endif ifeq ($(OPT_GENERATE_MAP),yes) - ifeq ($(OPT_LINK_OPTIMIZE),yes) - LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch,--gc-sections - else - LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch - endif + ifeq ($(OPT_LINK_OPTIMIZE),yes) + LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch,--gc-sections + else + LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch + endif endif ifeq ($(OPT_GENERATE_LISTINGS),yes) - CFLAGS += -Wa,-alms=$(@:.o=.lst) - CXXFLAGS += -Wa,-alms=$(@:.o=.lst) - ASFLAGS += -Wa,-amhls=$(@:.o=.lst) + CFLAGS += -Wa,-alms=$(@:.o=.lst) + CXXFLAGS += -Wa,-alms=$(@:.o=.lst) + ASFLAGS += -Wa,-amhls=$(@:.o=.lst) endif ifneq ($(LDSCRIPT),) - LDFLAGS += -T$(LDSCRIPT) + LDFLAGS += -T$(LDSCRIPT) +endif +ifeq ($(OPT_CPU),x86) + SRCFLAGS += -m32 + LDFLAGS += -m32 +endif +ifeq ($(OPT_CPU),x64) + SRCFLAGS += -m64 + LDFLAGS += -m64 +endif +ifeq ($(OPT_CPU),at91sam7) + SRCFLAGS += -mcpu=arm7tdmi -mabi=apcs-gnu + LDFLAGS += -mcpu=arm7tdmi +endif +ifeq ($(OPT_CPU),stm32m4) + SRCFLAGS += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -falign-functions=16 + LDFLAGS += -mcpu=cortex-m4 + LIBS += m endif # Generate dependency information SRCFLAGS += -MMD -MP -MF $(DEPDIR)/$(@F).d +# Combine all our compiler arguments +SRCFLAGS += -I. $(patsubst %,-I%,$(INCPATH)) $(patsubst %,-D%,$(patsubst -D%,%,$(DEFS))) +LDFLAGS += $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(patsubst -l%,%,$(LIBS))) + # Targets -.PHONY: builddirs fakefile.o all clean Debug Release cleanDebug cleanRelease +.PHONY: builddirs fakefile.o fakethumbfile.o elfstats all clean Debug Release cleanDebug cleanRelease Debug Release: all cleanDebug cleanRelease: clean -all: builddirs fakefile.o $(TARGETS) +all: builddirs $(FAKEFILE) $(TARGETS) builddirs: @mkdir -p $(BUILDDIR) @mkdir -p $(OBJDIR) @mkdir -p $(DEPDIR) -fakefile.o: +$(FAKEFILE): ifneq ($(OPT_VERBOSE_COMPILE),yes) - @echo Compiler Options - $(XCC) -c $(CPPFLAGS) $(CFLAGS) $(SRCFLAGS) fakefile.c -o $(OBJDIR)/$@ - @echo + @echo . + ifneq ($(filter %.cpp,$(SRC) $(SRC_NOTHUMB) $(SRC_THUMB)),) + @echo C++ Compiler Options.. $(XCXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SRCFLAGS) $(@:.o=.cpp) -o $(OBJDIR)/$@ + else + ifneq ($(filter %.c++,$(SRC) $(SRC_NOTHUMB) $(SRC_THUMB)),) + @echo C++ Compiler Options.. $(XCXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SRCFLAGS) $(@:.o=.c++) -o $(OBJDIR)/$@ + endif + endif + ifneq ($(filter %.c,$(SRC) $(SRC_NOTHUMB) $(SRC_THUMB)),) + @echo C Compiler Options.... $(XCC) -c $(CPPFLAGS) $(CFLAGS) $(SRCFLAGS) $(@:.o=.c) -o $(OBJDIR)/$@ + endif + ifneq ($(filter %.s,$(SRC) $(SRC_NOTHUMB) $(SRC_THUMB)),) + @echo Assembler Options..... $(XCC) -c $(CPPFLAGS) $(CFLAGS) $(SRCFLAGS) $(@:.o=.s) -o $(OBJDIR)/$@ + endif + @echo Linker Options........ $(XLD) $(LDFLAGS) $(OBJDIR)/$@ -o $(EXEFILE) + @echo . +endif + +fakethumbfile.o $(OBJS_THUMB): SRCFLAGS += -mthumb -DTHUMB + +elfstats: $(EXEFILE) + @echo . +ifeq ($(USE_VERBOSE_COMPILE),yes) + $(XSZ) $< +else + @$(XSZ) $< endif # Implicit Rules @@ -150,7 +225,7 @@ endif $(OBJDIR)/%.o : $$(call obj_src,%.c) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) - @echo + @echo . $(XCC) -c $(CPPFLAGS) $(CFLAGS) $(SRCFLAGS) $< -o $@ else @echo Compiling $< @@ -160,7 +235,7 @@ endif $(OBJDIR)/%.o : $$(call obj_src,%.cpp) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) - @echo + @echo . $(XCXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SRCFLAGS) $< -o $@ else @echo Compiling $< @@ -170,7 +245,7 @@ endif $(OBJDIR)/%.o : $$(call obj_src,%.c++) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) - @echo + @echo . $(XCXX) -c $(CPPFLAGS) $(CXXFLAGS) $(SRCFLAGS) $< -o $@ else @echo Compiling $< @@ -180,21 +255,21 @@ endif $(OBJDIR)/%.o : $$(call obj_src,%.s) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) - @echo + @echo . $(XAS) -c $(CPPFLAGS) $(ASFLAGS) $(SRCFLAGS) $< -o $@ else @echo Compiling $< @$(XAS) -c $(CPPFLAGS) $(ASFLAGS) $(SRCFLAGS) $< -o $@ endif -$(EXEFILE): $(OBJS) $(LDSCRIPT) +$(EXEFILE): $(OBJS_THUMB) $(OBJS_NOTHUMB) $(LDSCRIPT) @mkdir -p $(dir $@) ifeq ($(OPT_VERBOSE_COMPILE),yes) - @echo - $(XLD) $(OBJS) $(LDFLAGS) -o $@ + @echo . + $(XLD) $(OBJS_THUMB) $(OBJS_NOTHUMB) $(LDFLAGS) -o $@ else @echo Linking $@ - @$(XLD) $(OBJS) $(LDFLAGS) -o $@ + @$(XLD) $(OBJS_THUMB) $(OBJS_NOTHUMB) $(LDFLAGS) -o $@ endif ifeq ($(OPT_COPY_EXE),yes) @cp $@ . @@ -228,7 +303,6 @@ ifeq ($(USE_VERBOSE_COMPILE),yes) else @echo Creating $@ @$(XOD) -x --syms $< > $@ - @echo Done endif ifeq ($(OPT_COPY_EXE),yes) @cp $@ . diff --git a/tools/gmake_scripts/library_ugfx.mk b/tools/gmake_scripts/library_ugfx.mk index 24c501fe..450f6ff6 100644 --- a/tools/gmake_scripts/library_ugfx.mk +++ b/tools/gmake_scripts/library_ugfx.mk @@ -1,3 +1,10 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + # See readme.txt for the make API # Requirements: diff --git a/tools/gmake_scripts/os_chibios.mk b/tools/gmake_scripts/os_chibios.mk index a81c9803..b8205dd3 100644 --- a/tools/gmake_scripts/os_chibios.mk +++ b/tools/gmake_scripts/os_chibios.mk @@ -1,28 +1,60 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + # See readme.txt for the make API # Requirements: # # CHIBIOS: The location of the ChibiOS code eg CHIBIOS=../chibios -# CHIBIOS_BOARD The name of the ChibiOS board eg CHIBIOS_BOARD=OLIMEX_SAM7_EX256 # CHIBIOS_PLATFORM The name of the ChibiOS platform eg CHIBIOS_PLATFORM=AT91SAM7 # CHIBIOS_PORT The name of the ChibiOS port eg CHIBIOS_PORT=GCC/ARM/AT91SAM7 # # Optional: # -# CHIBIOS_LDSCRIPT The name of the loader script eg CHIBIOS_LDSCRIPT=$(PORTLD)/AT91SAM7X256.ld +# CHIBIOS_LDSCRIPT The name of the loader script eg CHIBIOS_LDSCRIPT=AT91SAM7X256.ld +# CHIBIOS_BOARD The name of the ChibiOS board eg CHIBIOS_BOARD=OLIMEX_SAM7_EX256 - if not specified you must include equivalent code yourself +# CHIBIOS_STM32LIB Use the STM32 library source for drivers instead of native drivers (yes or no) - default no +# CHIBIOS_VERSION Which version of ChibiOS is this (2 or 3) - default is 2 # PATHLIST += CHIBIOS -include $(CHIBIOS)/boards/$(CHIBIOS_BOARD)/board.mk -include $(CHIBIOS)/os/hal/platforms/$(CHIBIOS_PLATFORM)/platform.mk -include $(CHIBIOS)/os/hal/hal.mk -include $(CHIBIOS)/os/ports/$(CHIBIOS_PORT)/port.mk -include $(CHIBIOS)/os/kernel/kernel.mk -LDSCRIPT= $(CHIBIOS_LDSCRIPT) +ifeq ($(CHIBIOS_VERSION),3) + include $(CHIBIOS)/os/hal/hal.mk + include $(CHIBIOS)/os/hal/osal/rt/osal.mk + include $(CHIBIOS)/os/hal/ports/$(CHIBIOS_PLATFORM)/platform.mk + include $(CHIBIOS)/os/rt/rt.mk + include $(CHIBIOS)/os/rt/ports/$(CHIBIOS_PORT).mk +else + include $(CHIBIOS)/os/hal/hal.mk + include $(CHIBIOS)/os/hal/platforms/$(CHIBIOS_PLATFORM)/platform.mk + include $(CHIBIOS)/os/kernel/kernel.mk + include $(CHIBIOS)/os/ports/$(CHIBIOS_PORT)/port.mk +endif + +ifneq ($(CHIBIOS_BOARD),) + include $(CHIBIOS)/boards/$(CHIBIOS_BOARD)/board.mk +endif +ifeq ($(LDSCRIPT),) + ifneq ($(CHIBIOS_LDSCRIPT),) + LDSCRIPT= $(PORTLD)/$(CHIBIOS_LDSCRIPT) + endif +endif + +ifeq ($(CHIBIOS_STM32LIB),yes) + include $(CHIBIOS)/ext/stm32lib/stm32lib.mk + SRC += $(STM32SRC) + DEFS += USE_STDPERIPH_DRIVER + INCPATH += $(STM32INC) +endif + INCPATH += $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) + $(HALINC) $(PLATFORMINC) $(BOARDINC) SRC += $(PORTSRC) \ $(KERNSRC) \ $(TESTSRC) \ diff --git a/tools/gmake_scripts/os_linux.mk b/tools/gmake_scripts/os_linux.mk index 39610ca4..0893ca51 100644 --- a/tools/gmake_scripts/os_linux.mk +++ b/tools/gmake_scripts/os_linux.mk @@ -1,3 +1,10 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + # See readme.txt for the make API # Requirements: diff --git a/tools/gmake_scripts/os_osx.mk b/tools/gmake_scripts/os_osx.mk index 8b008f4b..9bfc7024 100644 --- a/tools/gmake_scripts/os_osx.mk +++ b/tools/gmake_scripts/os_osx.mk @@ -1,10 +1,18 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + # See readme.txt for the make API # Requirements: # # OSX_SDK The location of the SDK eg. OSX_SDK = /Developer/SDKs/MacOSX10.7.sdk -# OSX_ARCH The architecture flags eg. OSX_ARCH = -mmacosx-version-min=10.3 -arch i386 +# OSX_ARCH The architecture flags eg. OSX_ARCH = -mmacosx-version-min=10.3 # SRCFLAGS += -isysroot $(OSX_SDK) $(OSX_ARCH) LDFLAGS += -pthread -Wl,-syslibroot,$(OSX_SDK) $(OSX_ARCH) +OPT_CPU = x86 diff --git a/tools/gmake_scripts/os_win32.chibios.mk b/tools/gmake_scripts/os_win32.chibios.mk index 5a804c64..0eccf071 100644 --- a/tools/gmake_scripts/os_win32.chibios.mk +++ b/tools/gmake_scripts/os_win32.chibios.mk @@ -1,3 +1,10 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + # See readme.txt for the make API # Requirements: diff --git a/tools/gmake_scripts/os_win32.mk b/tools/gmake_scripts/os_win32.mk index 1b33ad85..07d15c20 100644 --- a/tools/gmake_scripts/os_win32.mk +++ b/tools/gmake_scripts/os_win32.mk @@ -1,6 +1,14 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + # See readme.txt for the make API # Requirements: # # NONE # +OPT_CPU = x86 diff --git a/tools/gmake_scripts/readme.txt b/tools/gmake_scripts/readme.txt index 979ca364..48ac2c9e 100644 --- a/tools/gmake_scripts/readme.txt +++ b/tools/gmake_scripts/readme.txt @@ -15,6 +15,7 @@ OPT_COPY_EXE=no|yes - Copy the final program to the local project directory - OPT_NONSTANDARD_FLAGS=no - Turn off adding the standard compiler language flags - default no OPT_LINK_OPTIMIZE=no - Remove unused code/data during link - default no OPT_OS=win32|win32.chibios|linux|osx|chibios|freertos|ecos|raw32|rawrtos - Mandatory: The operating system +OPT_CPU=x86|x64|stm32m4|at91sam7 - Add some cpu dependant flags BUILDDIR - Build Directory - default is ".build" or "bin/Debug" or "bin/Release" depending on the target PROJECT - Project Name - default is the name of the project directory @@ -27,6 +28,7 @@ XAS - Assembler - default is "$(ARCH)gcc -x assembler-with-cpp" XLD - Linker - default is "$(ARCH)gcc" XOC - Object Copy - default is "$(ARCH)objcopy" XOD - Object Dump - default is "$(ARCH)objdump" +XSZ - Report binary dump details - default is "$(ARCH)size" SRCFLAGS - Compiler defines for c, c++ and assembler files - default is "" CFLAGS - C specific compiler defines - default is "" @@ -43,8 +45,18 @@ LIBPATH - List of library include directories - default is "" DEFS - List of preprocessor defines (any -D prefix is ignored) - default is "" LIBS - List of libraries (any -l prefix is ignored) - default is "" SRC - List of c, c++ and assembler source files - default is "" +OBJS - List of additional object files - default is "" LDSCRIPT - Custom loader script - default is "" +ARM Specific options +---------------------------- +OPT_THUMB=no|yes - Compile normal sources in thumb mode - default is no + +SRC_THUMB - List of source files that MUST be compiled in thumb mode - default is "" +SRC_NOTHUMB - List of source files that MUST be compiled in non-thumb mode - default is "" +OBJS_THUMB - List of object files that MUST be linked in thumb mode - default is "" +OBJS_NOTHUMB - List of object files that MUST be linked in non-thumb mode - default is "" + Targets ---------------------------- From 5427d3efe5f5b677ff69ce71b5e65df94b3c08a4 Mon Sep 17 00:00:00 2001 From: Joel Bodenmann Date: Sun, 5 Oct 2014 15:03:12 +0200 Subject: [PATCH 6/7] Fixing inclusion problem --- src/gdisp/fonts/fonts.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gdisp/fonts/fonts.h b/src/gdisp/fonts/fonts.h index 253d0e2d..bfb60b1c 100644 --- a/src/gdisp/fonts/fonts.h +++ b/src/gdisp/fonts/fonts.h @@ -1,5 +1,4 @@ - -#include +#include "gfx.h" #if defined(GDISP_INCLUDE_FONT_DEJAVUSANS10) && GDISP_INCLUDE_FONT_DEJAVUSANS10 #define GDISP_FONT_FOUND From 63fd8ab89b9c4cdddcfd91aacbf12871aeff556e Mon Sep 17 00:00:00 2001 From: inmarket Date: Mon, 6 Oct 2014 15:50:19 +1000 Subject: [PATCH 7/7] Update support for ChibiOS v3 to the current repository. Update Make system to match. Add ability to make to a library rather than a program Stop ignoring objcode invalid format errors Multiple make tidy ups --- .../base/Linux-Framebuffer/example/Makefile | 8 +- boards/base/Linux/example/Makefile | 8 +- .../ChibiOS_Board/board.h | 1 + .../example_chibios_2.x/Makefile | 9 +-- .../example_chibios_3.x/Makefile | 35 ++------- .../example_chibios_3.x/chconf.h | 2 +- .../example_chibios_3.x/halconf.h | 18 ++--- .../example_chibios_3.x/mcuconf.h | 2 +- boards/base/OSX/example/Makefile | 8 +- .../Olimex-SAM7EX256-GE8/example/Makefile | 11 +-- boards/base/Win32/example/Makefile | 8 +- src/gos/gos_chibios.h | 4 + tools/gmake_scripts/compiler_gcc.mk | 78 +++++++++++-------- tools/gmake_scripts/cpu_at91sam7.mk | 20 +++++ tools/gmake_scripts/cpu_stm32m4.mk | 19 +++++ tools/gmake_scripts/cpu_x64.mk | 18 +++++ tools/gmake_scripts/cpu_x86.mk | 18 +++++ tools/gmake_scripts/os_chibios.mk | 31 ++++++-- tools/gmake_scripts/readme.txt | 4 + 19 files changed, 180 insertions(+), 122 deletions(-) create mode 100644 tools/gmake_scripts/cpu_at91sam7.mk create mode 100644 tools/gmake_scripts/cpu_stm32m4.mk create mode 100644 tools/gmake_scripts/cpu_x64.mk create mode 100644 tools/gmake_scripts/cpu_x86.mk diff --git a/boards/base/Linux-Framebuffer/example/Makefile b/boards/base/Linux-Framebuffer/example/Makefile index fb0c1b7a..802fddc3 100644 --- a/boards/base/Linux-Framebuffer/example/Makefile +++ b/boards/base/Linux-Framebuffer/example/Makefile @@ -6,13 +6,8 @@ # General settings # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables - OPT_VERBOSE_COMPILE = no - OPT_GENERATE_LISTINGS = yes - OPT_GENERATE_MAP = yes - OPT_COPY_EXE = no - OPT_LINK_OPTIMIZE = yes - OPT_NONSTANDARD_FLAGS = no OPT_OS = linux + OPT_LINK_OPTIMIZE = yes # Change this next setting (or add the explicit compiler flags) if you are not compiling for x86 linux OPT_CPU = x86 @@ -20,7 +15,6 @@ # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables GFXLIB = ../uGFX GFXBOARD = Linux-Framebuffer - #GFXDRIVERS = multiple/uGFXnet GFXDEMO = modules/gdisp/basics # Linux settings diff --git a/boards/base/Linux/example/Makefile b/boards/base/Linux/example/Makefile index 3d6d3d60..d75c1dd2 100644 --- a/boards/base/Linux/example/Makefile +++ b/boards/base/Linux/example/Makefile @@ -6,13 +6,8 @@ # General settings # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables - OPT_VERBOSE_COMPILE = no - OPT_GENERATE_LISTINGS = yes - OPT_GENERATE_MAP = yes - OPT_COPY_EXE = no - OPT_LINK_OPTIMIZE = yes - OPT_NONSTANDARD_FLAGS = no OPT_OS = linux + OPT_LINK_OPTIMIZE = yes # Change this next setting (or add the explicit compiler flags) if you are not compiling for x86 linux OPT_CPU = x86 @@ -20,7 +15,6 @@ # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables GFXLIB = ../uGFX GFXBOARD = Linux - #GFXDRIVERS = multiple/uGFXnet GFXDEMO = modules/gdisp/basics # Linux settings diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.h b/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.h index 41f15201..b5ee34ad 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.h +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.h @@ -49,6 +49,7 @@ * MCU type as defined in the ST header. */ #define STM32F40_41xxx +#define STM32F407xx /* * IO pins assignments. diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile index ac483689..8baa399f 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_2.x/Makefile @@ -6,22 +6,16 @@ # General settings # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables - OPT_VERBOSE_COMPILE = no - OPT_GENERATE_LISTINGS = yes - OPT_GENERATE_MAP = yes - OPT_COPY_EXE = no - OPT_LINK_OPTIMIZE = yes - OPT_NONSTANDARD_FLAGS = no OPT_NATIVEOS = chibios OPT_OS = chibios OPT_THUMB = yes + OPT_LINK_OPTIMIZE = yes OPT_CPU = stm32m4 # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables GFXLIB = ../uGFX GFXBOARD = Mikromedia-STM32-M4-ILI9341 - #GFXDRIVERS = multiple/uGFXnet GFXDEMO = modules/gdisp/basics # ChibiOS settings @@ -31,7 +25,6 @@ ifeq ($(OPT_OS),chibios) CHIBIOS_BOARD = CHIBIOS_PLATFORM = STM32F4xx CHIBIOS_PORT = GCC/ARMCMx/STM32F4xx - CHIBIOS_DEFS = CHIBIOS_LDSCRIPT = STM32F407xG.ld # We define a non standard board script as this is not a standard ChibiOS supported board include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.mk diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile index d19c3d28..55778283 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/Makefile @@ -6,33 +6,27 @@ # General settings # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables - OPT_VERBOSE_COMPILE = no - OPT_GENERATE_LISTINGS = yes - OPT_GENERATE_MAP = yes - OPT_COPY_EXE = no - OPT_LINK_OPTIMIZE = yes - OPT_NONSTANDARD_FLAGS = no OPT_NATIVEOS = chibios OPT_OS = chibios OPT_THUMB = yes + OPT_LINK_OPTIMIZE = yes OPT_CPU = stm32m4 # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables GFXLIB = ../uGFX GFXBOARD = Mikromedia-STM32-M4-ILI9341 - #GFXDRIVERS = multiple/uGFXnet GFXDEMO = modules/gdisp/basics # ChibiOS settings ifeq ($(OPT_OS),chibios) # See $(GFXLIB)/tools/gmake_scripts/os_chibios.mk for the list of variables - CHIBIOS = ../ChibiOS - CHBIOS_VERSION = 3 + CHIBIOS = ../ChibiOS3 + CHIBIOS_VERSION = 3 CHIBIOS_BOARD = + CHIBIOS_CPUCLASS = ARMCMx CHIBIOS_PLATFORM = STM32/STM32F4xx - CHIBIOS_PORT = ARMCMx/compilers/GCC/mk/port_stm32f4xx - CHIBIOS_DEFS = + CHIBIOS_PORT = stm32f4xx CHIBIOS_LDSCRIPT = STM32F407xG.ld # We define a non standard board script as this is not a standard ChibiOS supported board include $(GFXLIB)/boards/base/Mikromedia-STM32-M4-ILI9341/ChibiOS_Board/board.mk @@ -65,22 +59,3 @@ include $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk include $(GFXLIB)/tools/gmake_scripts/os_$(OPT_OS).mk include $(GFXLIB)/tools/gmake_scripts/compiler_gcc.mk # *** EOF *** -############################################################################## -############################################################################### -# Architecture or project specific options -# - -# Stack size to be allocated to the Cortex-M process stack. This stack is -# the stack used by the main() thread. -ifeq ($(USE_PROCESS_STACKSIZE),) - USE_PROCESS_STACKSIZE = 0x400 -endif - -# Stack size to the allocated to the Cortex-M main/exceptions stack. This -# stack is used for processing interrupts and exceptions. -ifeq ($(USE_EXCEPTIONS_STACKSIZE),) - USE_EXCEPTIONS_STACKSIZE = 0x400 -endif - -RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC -include $(RULESPATH)/rules.mk \ No newline at end of file diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/chconf.h b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/chconf.h index 150bd73c..53700421 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/chconf.h +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/chconf.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006-2014 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/halconf.h b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/halconf.h index 40c57eeb..06d3e2ff 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/halconf.h +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/halconf.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006-2014 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -30,13 +30,6 @@ #include "mcuconf.h" -/** - * @brief Enables the TM subsystem. - */ -#if !defined(HAL_USE_TM) || defined(__DOXYGEN__) -#define HAL_USE_TM FALSE -#endif - /** * @brief Enables the PAL subsystem. */ @@ -79,6 +72,13 @@ #define HAL_USE_I2C FALSE #endif +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + /** * @brief Enables the ICU subsystem. */ @@ -104,7 +104,7 @@ * @brief Enables the PWM subsystem. */ #if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -#define HAL_USE_PWM TRUE +#define HAL_USE_PWM FALSE #endif /** diff --git a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/mcuconf.h b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/mcuconf.h index 047224f1..1f8378d2 100644 --- a/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/mcuconf.h +++ b/boards/base/Mikromedia-STM32-M4-ILI9341/example_chibios_3.x/mcuconf.h @@ -1,5 +1,5 @@ /* - ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio + ChibiOS - Copyright (C) 2006-2014 Giovanni Di Sirio Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/boards/base/OSX/example/Makefile b/boards/base/OSX/example/Makefile index 5bbcb5df..4226f613 100644 --- a/boards/base/OSX/example/Makefile +++ b/boards/base/OSX/example/Makefile @@ -6,19 +6,13 @@ # General settings # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables - OPT_VERBOSE_COMPILE = no - OPT_GENERATE_LISTINGS = yes - OPT_GENERATE_MAP = yes - OPT_COPY_EXE = no - OPT_LINK_OPTIMIZE = yes - OPT_NONSTANDARD_FLAGS = no OPT_OS = osx + OPT_LINK_OPTIMIZE = yes # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables GFXLIB = ../uGFX GFXBOARD = OSX - #GFXDRIVERS = multiple/uGFXnet GFXDEMO = modules/gdisp/basics # OSX settings diff --git a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile index 9130ed5a..fe0e5178 100644 --- a/boards/base/Olimex-SAM7EX256-GE8/example/Makefile +++ b/boards/base/Olimex-SAM7EX256-GE8/example/Makefile @@ -6,22 +6,16 @@ # General settings # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables - OPT_VERBOSE_COMPILE = no - OPT_GENERATE_LISTINGS = yes - OPT_GENERATE_MAP = yes - OPT_COPY_EXE = no - OPT_LINK_OPTIMIZE = yes - OPT_NONSTANDARD_FLAGS = no OPT_NATIVEOS = chibios OPT_OS = chibios - OPT_THUMB = no + OPT_THUMB = yes + OPT_LINK_OPTIMIZE = yes OPT_CPU = at91sam7 # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables GFXLIB = ../uGFX GFXBOARD = Olimex-SAM7EX256-GE8 - #GFXDRIVERS = multiple/uGFXnet GFXDEMO = modules/gdisp/basics # ChibiOS settings @@ -31,7 +25,6 @@ ifeq ($(OPT_OS),chibios) CHIBIOS_BOARD = OLIMEX_SAM7_EX256 CHIBIOS_PLATFORM = AT91SAM7 CHIBIOS_PORT = GCC/ARM/AT91SAM7 - CHIBIOS_DEFS = CHIBIOS_LDSCRIPT = AT91SAM7X256.ld endif diff --git a/boards/base/Win32/example/Makefile b/boards/base/Win32/example/Makefile index 5670f0f1..0087ca90 100644 --- a/boards/base/Win32/example/Makefile +++ b/boards/base/Win32/example/Makefile @@ -6,20 +6,14 @@ # General settings # See $(GFXLIB)/tools/gmake_scripts/readme.txt for the list of variables - OPT_VERBOSE_COMPILE = no - OPT_GENERATE_LISTINGS = yes - OPT_GENERATE_MAP = yes - OPT_COPY_EXE = no - OPT_LINK_OPTIMIZE = yes - OPT_NONSTANDARD_FLAGS = no # For Win32 this variable can be set to "win32" (native win32 api) or "win32.chibios" (ChibiOS simulator). OPT_OS = win32 + OPT_LINK_OPTIMIZE = yes # uGFX settings # See $(GFXLIB)/tools/gmake_scripts/library_ugfx.mk for the list of variables GFXLIB = ../uGFX GFXBOARD = Win32 - #GFXDRIVERS = multiple/uGFXnet GFXDEMO = modules/gdisp/basics # ChibiOS settings diff --git a/src/gos/gos_chibios.h b/src/gos/gos_chibios.h index a07c72ab..a3aba712 100644 --- a/src/gos/gos_chibios.h +++ b/src/gos/gos_chibios.h @@ -28,6 +28,10 @@ * are already defined by ChibiOS */ +#if CH_KERNEL_MAJOR == 3 + typedef char bool_t; +#endif + typedef systime_t delaytime_t; typedef systime_t systemticks_t; typedef cnt_t semcount_t; diff --git a/tools/gmake_scripts/compiler_gcc.mk b/tools/gmake_scripts/compiler_gcc.mk index bc3c216b..04a68afc 100644 --- a/tools/gmake_scripts/compiler_gcc.mk +++ b/tools/gmake_scripts/compiler_gcc.mk @@ -9,9 +9,9 @@ # See readme.txt for the make API # +# Win32 Nasty - must convert all paths into a format make can handle ifeq ($(basename $(OPT_OS)),win32) - # Nasty - must convert all paths into a format make can handle - PATHEXPAND := ARCH XCC XCXX XAS XLD XOC XOD XSZ PROJECT BUILDDIR SRC DEFS LIBS INCPATH LIBPATH $(PATHLIST) + PATHEXPAND := ARCH XCC XCXX XAS XLD XOC XOD XSZ XAR PROJECT BUILDDIR SRC DEFS LIBS INCPATH LIBPATH $(PATHLIST) # First convert \'s to /'s $(foreach var,$(PATHEXPAND),$(eval $(var):=$$(subst \,/,$($(var))))) @@ -23,6 +23,14 @@ ifeq ($(basename $(OPT_OS)),win32) endif endif +# Where are we +CURRENTDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + +# Handle cpu specific options +ifneq ($(OPT_CPU),) + include $(CURRENTDIR)cpu_$(OPT_CPU).mk +endif + # Path resolution - Functions to convert a source path to a object path and visa-versa src_obj_fn := $$(1) obj_src_fn := $$(1) @@ -54,7 +62,10 @@ ifeq ($(XOD),) endif ifeq ($(XSZ),) XSZ = $(ARCH)size - endif +endif +ifeq ($(XAR),) + XAR = $(ARCH)ar +endif # Default project name is the project directory name ifeq ($(PROJECT),) @@ -87,6 +98,7 @@ DEPDIR = $(BUILDDIR)/dep # Output files MAPFILE = $(BUILDDIR)/$(PROJECT).map +LIBFILE = $(BUILDDIR)/lib$(PROJECT).a FAKEFILE= fakefile.o EXEFILE = ifeq ($(basename $(OPT_OS)),win32) @@ -135,13 +147,10 @@ ifneq ($(OPT_NONSTANDARD_FLAGS),yes) endif ifeq ($(OPT_LINK_OPTIMIZE),yes) SRCFLAGS += -ffunction-sections -fdata-sections -fno-common -flto + LDFLAGS += -Wl,--gc-sections endif ifeq ($(OPT_GENERATE_MAP),yes) - ifeq ($(OPT_LINK_OPTIMIZE),yes) - LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch,--gc-sections - else - LDFLAGS += -Wl,-Map=$(MAPFILE),--cref,--no-warn-mismatch - endif + LDFLAGS += -Wl,-Map=$(MAPFILE),--cref endif ifeq ($(OPT_GENERATE_LISTINGS),yes) CFLAGS += -Wa,-alms=$(@:.o=.lst) @@ -151,23 +160,6 @@ endif ifneq ($(LDSCRIPT),) LDFLAGS += -T$(LDSCRIPT) endif -ifeq ($(OPT_CPU),x86) - SRCFLAGS += -m32 - LDFLAGS += -m32 -endif -ifeq ($(OPT_CPU),x64) - SRCFLAGS += -m64 - LDFLAGS += -m64 -endif -ifeq ($(OPT_CPU),at91sam7) - SRCFLAGS += -mcpu=arm7tdmi -mabi=apcs-gnu - LDFLAGS += -mcpu=arm7tdmi -endif -ifeq ($(OPT_CPU),stm32m4) - SRCFLAGS += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -falign-functions=16 - LDFLAGS += -mcpu=cortex-m4 - LIBS += m -endif # Generate dependency information SRCFLAGS += -MMD -MP -MF $(DEPDIR)/$(@F).d @@ -176,13 +168,23 @@ SRCFLAGS += -MMD -MP -MF $(DEPDIR)/$(@F).d SRCFLAGS += -I. $(patsubst %,-I%,$(INCPATH)) $(patsubst %,-D%,$(patsubst -D%,%,$(DEFS))) LDFLAGS += $(patsubst %,-L%,$(LIBPATH)) $(patsubst %,-l%,$(patsubst -l%,%,$(LIBS))) -# Targets -.PHONY: builddirs fakefile.o fakethumbfile.o elfstats all clean Debug Release cleanDebug cleanRelease +################# Targets ###################### +.PHONY: builddirs fakefile.o fakethumbfile.o elfstats all exe lib clean Debug Release cleanDebug cleanRelease + +# Many IDE's use these targets instead. Debug Release: all cleanDebug cleanRelease: clean -all: builddirs $(FAKEFILE) $(TARGETS) +# Make a program or a library? +ifeq ($(OPT_MAKE_LIB),yes) + all: lib +else + all: exe +endif + +exe: builddirs $(FAKEFILE) $(TARGETS) +lib: builddirs $(FAKEFILE) $(LIBFILE) builddirs: @mkdir -p $(BUILDDIR) @@ -205,7 +207,9 @@ ifneq ($(OPT_VERBOSE_COMPILE),yes) ifneq ($(filter %.s,$(SRC) $(SRC_NOTHUMB) $(SRC_THUMB)),) @echo Assembler Options..... $(XCC) -c $(CPPFLAGS) $(CFLAGS) $(SRCFLAGS) $(@:.o=.s) -o $(OBJDIR)/$@ endif + ifneq ($(OPT_MAKE_LIB),yes) @echo Linker Options........ $(XLD) $(LDFLAGS) $(OBJDIR)/$@ -o $(EXEFILE) + endif @echo . endif @@ -275,6 +279,18 @@ ifeq ($(OPT_COPY_EXE),yes) @cp $@ . endif +$(LIBFILE): $(OBJS_THUMB) $(OBJS_NOTHUMB) +ifeq ($(OPT_VERBOSE_COMPILE),yes) + @echo . + $(XAR) -r $@ $^ +else + @echo Creating Library $@ + @$(XAR) -r $@ $^ +endif +ifeq ($(OPT_COPY_EXE),yes) + @cp $@ . +endif + %.hex: %.elf ifeq ($(OPT_VERBOSE_COMPILE),yes) $(XOC) -O ihex $< $@ @@ -287,7 +303,7 @@ ifeq ($(OPT_COPY_EXE),yes) endif %.bin: %.elf -ifeq ($(USE_VERBOSE_COMPILE),yes) +ifeq ($(OPT_VERBOSE_COMPILE),yes) $(XOC) -O binary $< $@ else @echo Creating $@ @@ -298,7 +314,7 @@ ifeq ($(OPT_COPY_EXE),yes) endif %.dmp: %.elf -ifeq ($(USE_VERBOSE_COMPILE),yes) +ifeq ($(OPT_VERBOSE_COMPILE),yes) $(XOD) -x --syms $< > $@ else @echo Creating $@ @@ -311,7 +327,7 @@ endif # Goodness knows why we would want this. gcov: -mkdir gcov - $(COV) -u $(subst /,\,$(SRC)) + $(COV) -u $(subst /,\,$(SRC_NOTHUMB) $(SRC_THUMB)) -mv *.gcov ./gcov # Include the dependency files, should be the last of the makefile except for clean diff --git a/tools/gmake_scripts/cpu_at91sam7.mk b/tools/gmake_scripts/cpu_at91sam7.mk new file mode 100644 index 00000000..fe5d528d --- /dev/null +++ b/tools/gmake_scripts/cpu_at91sam7.mk @@ -0,0 +1,20 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# +# See readme.txt for the make API +# + +# Requirements: +# +# NONE +# + +SRCFLAGS += -mcpu=arm7tdmi +LDFLAGS += -mcpu=arm7tdmi +#SRCFLAGS += -mcpu=arm7tdmi -mabi=apcs-gnu +#LDFLAGS += -mcpu=arm7tdmi -Wl,--no-warn-mismatch diff --git a/tools/gmake_scripts/cpu_stm32m4.mk b/tools/gmake_scripts/cpu_stm32m4.mk new file mode 100644 index 00000000..9e105a36 --- /dev/null +++ b/tools/gmake_scripts/cpu_stm32m4.mk @@ -0,0 +1,19 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# +# See readme.txt for the make API +# + +# Requirements: +# +# NONE +# + +SRCFLAGS += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant -falign-functions=16 +LDFLAGS += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 +LIBS += m diff --git a/tools/gmake_scripts/cpu_x64.mk b/tools/gmake_scripts/cpu_x64.mk new file mode 100644 index 00000000..5013e260 --- /dev/null +++ b/tools/gmake_scripts/cpu_x64.mk @@ -0,0 +1,18 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# +# See readme.txt for the make API +# + +# Requirements: +# +# NONE +# + +SRCFLAGS += -m64 +LDFLAGS += -m64 diff --git a/tools/gmake_scripts/cpu_x86.mk b/tools/gmake_scripts/cpu_x86.mk new file mode 100644 index 00000000..0e3e5af1 --- /dev/null +++ b/tools/gmake_scripts/cpu_x86.mk @@ -0,0 +1,18 @@ +# +# This file is subject to the terms of the GFX License. If a copy of +# the license was not distributed with this file, you can obtain one at: +# +# http://ugfx.org/license.html +# + +# +# See readme.txt for the make API +# + +# Requirements: +# +# NONE +# + +SRCFLAGS += -m32 +LDFLAGS += -m32 diff --git a/tools/gmake_scripts/os_chibios.mk b/tools/gmake_scripts/os_chibios.mk index b8205dd3..f583d186 100644 --- a/tools/gmake_scripts/os_chibios.mk +++ b/tools/gmake_scripts/os_chibios.mk @@ -12,6 +12,7 @@ # CHIBIOS: The location of the ChibiOS code eg CHIBIOS=../chibios # CHIBIOS_PLATFORM The name of the ChibiOS platform eg CHIBIOS_PLATFORM=AT91SAM7 # CHIBIOS_PORT The name of the ChibiOS port eg CHIBIOS_PORT=GCC/ARM/AT91SAM7 +# CHIBIOS_CPUCLASS The class of the CPU. Only required for ChibiOS v3 eg CHIBIOS_CPUCLASS=ARMCMx # # Optional: @@ -20,6 +21,8 @@ # CHIBIOS_BOARD The name of the ChibiOS board eg CHIBIOS_BOARD=OLIMEX_SAM7_EX256 - if not specified you must include equivalent code yourself # CHIBIOS_STM32LIB Use the STM32 library source for drivers instead of native drivers (yes or no) - default no # CHIBIOS_VERSION Which version of ChibiOS is this (2 or 3) - default is 2 +# CHIBIOS_PROCESS_STACKSIZE Size of the ChibiOS process stack. Only useful if the link script supports it - default is 0x400 +# CHIBIOS_EXCEPTIONS_STACKSIZE Size of the ChibiOS exceptopms stack. Only useful if the link script supports it - default is 0x400 # PATHLIST += CHIBIOS @@ -29,23 +32,40 @@ ifeq ($(CHIBIOS_VERSION),3) include $(CHIBIOS)/os/hal/osal/rt/osal.mk include $(CHIBIOS)/os/hal/ports/$(CHIBIOS_PLATFORM)/platform.mk include $(CHIBIOS)/os/rt/rt.mk - include $(CHIBIOS)/os/rt/ports/$(CHIBIOS_PORT).mk + include $(CHIBIOS)/os/rt/ports/$(CHIBIOS_CPUCLASS)/compilers/GCC/mk/port_$(CHIBIOS_PORT).mk + ifneq ($(CHIBIOS_BOARD),) + include $(CHIBIOS)/os/hal/boards/$(CHIBIOS_BOARD)/board.mk + endif + LIBPATH += $(CHIBIOS)/os/common/ports/$(CHIBIOS_CPUCLASS)/compilers/GCC else include $(CHIBIOS)/os/hal/hal.mk include $(CHIBIOS)/os/hal/platforms/$(CHIBIOS_PLATFORM)/platform.mk include $(CHIBIOS)/os/kernel/kernel.mk include $(CHIBIOS)/os/ports/$(CHIBIOS_PORT)/port.mk + ifneq ($(CHIBIOS_BOARD),) + include $(CHIBIOS)/boards/$(CHIBIOS_BOARD)/board.mk + endif endif -ifneq ($(CHIBIOS_BOARD),) - include $(CHIBIOS)/boards/$(CHIBIOS_BOARD)/board.mk -endif ifeq ($(LDSCRIPT),) ifneq ($(CHIBIOS_LDSCRIPT),) LDSCRIPT= $(PORTLD)/$(CHIBIOS_LDSCRIPT) endif endif +ifneq ($(LDSCRIPT),) + ifeq ($(CHIBIOS_PROCESS_STACKSIZE),) + LDFLAGS += -Wl,--defsym=__process_stack_size__=0x400 + else + LDFLAGS += -Wl,--defsym=__process_stack_size__=$(CHIBIOS_PROCESS_STACKSIZE) + endif + ifeq ($(CHIBIOS_EXCEPTIONS_STACKSIZE),) + LDFLAGS += -Wl,--defsym=__main_stack_size__=0x400 + else + LDFLAGS += -Wl,--defsym=__main_stack_size__=$(CHIBIOS_EXCEPTIONS_STACKSIZE) + endif +endif + ifeq ($(CHIBIOS_STM32LIB),yes) include $(CHIBIOS)/ext/stm32lib/stm32lib.mk SRC += $(STM32SRC) @@ -53,7 +73,7 @@ ifeq ($(CHIBIOS_STM32LIB),yes) INCPATH += $(STM32INC) endif -INCPATH += $(PORTINC) $(KERNINC) $(TESTINC) \ +INCPATH += $(PORTINC) $(KERNINC) $(TESTINC) $(OSALINC) \ $(HALINC) $(PLATFORMINC) $(BOARDINC) SRC += $(PORTSRC) \ $(KERNSRC) \ @@ -61,4 +81,5 @@ SRC += $(PORTSRC) \ $(HALSRC) \ $(PLATFORMSRC) \ $(BOARDSRC) \ + $(OSALSRC) \ $(PORTASM) diff --git a/tools/gmake_scripts/readme.txt b/tools/gmake_scripts/readme.txt index 48ac2c9e..eec7dd95 100644 --- a/tools/gmake_scripts/readme.txt +++ b/tools/gmake_scripts/readme.txt @@ -8,6 +8,7 @@ All make script files in this directory apply the following rules and assumption Input Variables (all optional unless otherwise specified) ---------------------------- +OPT_MAKE_LIB=no|yes - Make a library instead of an program = default no OPT_VERBOSE_COMPILE=no|yes - Turn on full compile messages - default no OPT_GENERATE_LISTINGS=no|yes - Generate listing files - default no OPT_GENERATE_MAP=no|yes - Generate a map file - default no @@ -29,6 +30,7 @@ XLD - Linker - default is "$(ARCH)gcc" XOC - Object Copy - default is "$(ARCH)objcopy" XOD - Object Dump - default is "$(ARCH)objdump" XSZ - Report binary dump details - default is "$(ARCH)size" +XAR - Library archiver - default is "$(ARCH)ar" SRCFLAGS - Compiler defines for c, c++ and assembler files - default is "" CFLAGS - C specific compiler defines - default is "" @@ -61,6 +63,8 @@ Targets ---------------------------- all +lib +exe clean Debug cleanDebug