Update to makefiles to support ChibiOS v3, making ARM thumb targets, CPU specific flags etc

Also put license in the gmake master scripts.
ugfx_release_2.6
inmarket 2014-10-04 17:12:33 +10:00
parent e6882aa5f4
commit bbc7b6e039
17 changed files with 377 additions and 545 deletions

View File

@ -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 =

View File

@ -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 =

View File

@ -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 ***

View File

@ -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

View File

@ -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 =

View File

@ -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

View File

@ -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.

View File

@ -43,6 +43,7 @@ ASFLAGS =
LDFLAGS =
SRC =
OBJS =
DEFS =
LIBS =
INCPATH =

View File

@ -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.

View File

@ -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 $@ .

View File

@ -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:

View File

@ -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) \

View File

@ -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:

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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
----------------------------