aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-10-06 15:50:19 +1000
committerinmarket <andrewh@inmarket.com.au>2014-10-06 15:50:19 +1000
commit18c4a9f8703b8a6ddcea050d74d31b194005dae1 (patch)
tree6101b238aeccc91ccb5331b3108e832bfbc0ff70 /tools
parent2151935b3a89fdf357181f6f1161c1c0c1dde1f0 (diff)
downloaduGFX-18c4a9f8703b8a6ddcea050d74d31b194005dae1.tar.gz
uGFX-18c4a9f8703b8a6ddcea050d74d31b194005dae1.tar.bz2
uGFX-18c4a9f8703b8a6ddcea050d74d31b194005dae1.zip
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
Diffstat (limited to 'tools')
-rw-r--r--tools/gmake_scripts/compiler_gcc.mk78
-rw-r--r--tools/gmake_scripts/cpu_at91sam7.mk20
-rw-r--r--tools/gmake_scripts/cpu_stm32m4.mk19
-rw-r--r--tools/gmake_scripts/cpu_x64.mk18
-rw-r--r--tools/gmake_scripts/cpu_x86.mk18
-rw-r--r--tools/gmake_scripts/os_chibios.mk31
-rw-r--r--tools/gmake_scripts/readme.txt4
7 files changed, 152 insertions, 36 deletions
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