From f90ea57bff091832c7b52b3825057ac20ded1f01 Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 1 Oct 2014 00:44:40 +1000 Subject: [PATCH] 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 ----------------------------