From 679520b160a61950c5746351ab97632ad48f377b Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 24 Feb 2013 09:36:51 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@5309 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- testhal/testbuild/Makefile | 270 ++++++++++++++++++++++++++++++--------------- testhal/testbuild/main.c | 2 +- 2 files changed, 180 insertions(+), 92 deletions(-) (limited to 'testhal') diff --git a/testhal/testbuild/Makefile b/testhal/testbuild/Makefile index 0a581d7a1..a94cf67ac 100644 --- a/testhal/testbuild/Makefile +++ b/testhal/testbuild/Makefile @@ -1,133 +1,221 @@ -# This makefile expects the following variables to be externally -# defined: -# XOPT - Compiler extra options -# XDEFS - Extra definitions - -############################################################################################## -# Start of default section +############################################################################## +# Build global options +# NOTE: Can be overridden externally. # -TRGT = mingw32- -CC = $(TRGT)gcc -AS = $(TRGT)gcc -x assembler-with-cpp +# Compiler options here. +ifeq ($(USE_OPT),) + USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16 +endif -# List all default C defines here, like -D_DEBUG=1 -DDEFS = -DSIMULATOR +# C specific options here (added to USE_OPT). +ifeq ($(USE_COPT),) + USE_COPT = +endif -# List all default ASM defines here, like -D_DEBUG=1 -DADEFS = +# C++ specific options here (added to USE_OPT). +ifeq ($(USE_CPPOPT),) + USE_CPPOPT = -fno-rtti +endif -# List all default directories to look for include files here -DINCDIR = +# Enable this if you want the linker to remove unused code and data +ifeq ($(USE_LINK_GC),) + USE_LINK_GC = yes +endif -# List the default directory to look for the libraries here -DLIBDIR = +# If enabled, this option allows to compile the application in THUMB mode. +ifeq ($(USE_THUMB),) + USE_THUMB = yes +endif -# List all default libraries here -DLIBS = -lws2_32 +# Enable this if you want to see the full log while compiling. +ifeq ($(USE_VERBOSE_COMPILE),) + USE_VERBOSE_COMPILE = no +endif # -# End of default section -############################################################################################## +# Build global options +############################################################################## -############################################################################################## -# Start of user section +############################################################################## +# Architecture or project specific options # -# Define project name here -PROJECT = ch +# 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 -# Define linker script file here -LDSCRIPT= +# Enable this if you really want to use the STM FWLib. +ifeq ($(USE_FWLIB),) + USE_FWLIB = no +endif -# List all user C define here, like -D_DEBUG=1 -UDEFS = +# +# Architecture or project specific options +############################################################################## -# Define ASM defines here -UADEFS = +############################################################################## +# Project, sources and paths +# -# Imported source files +# Define project name here +PROJECT = ch + +# Imported source files and paths CHIBIOS = ../.. -include $(CHIBIOS)/boards/simulator/board.mk -include ${CHIBIOS}/os/hal/hal.mk -include ${CHIBIOS}/os/hal/platforms/templates/platform.mk -include ${CHIBIOS}/os/ports/GCC/SIMIA32/port.mk -include ${CHIBIOS}/os/kernel/kernel.mk -include ${CHIBIOS}/test/test.mk - -# List C source files here -SRC = ${PORTSRC} \ - ${KERNSRC} \ - ${TESTSRC} \ - ${HALSRC} \ - ${PLATFORMSRC} \ +include $(CHIBIOS)/boards/ST_STM32F4_DISCOVERY/board.mk +include $(CHIBIOS)/os/hal/templates/platform.mk +include $(CHIBIOS)/os/hal/hal.mk +include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk +include $(CHIBIOS)/os/kernel/kernel.mk +#include $(CHIBIOS)/test/test.mk + +# Define linker script file here +LDSCRIPT= $(PORTLD)/STM32F407xG.ld +#LDSCRIPT= $(PORTLD)/STM32F407xG_CCM.ld + +# C sources that can be compiled in ARM or THUMB mode depending on the global +# setting. +CSRC = $(PORTSRC) \ + $(KERNSRC) \ + $(TESTSRC) \ + $(HALSRC) \ + $(PLATFORMSRC) \ $(BOARDSRC) \ main.c -# List ASM source files here -ASRC = +# C++ sources that can be compiled in ARM or THUMB mode depending on the global +# setting. +CPPSRC = -# List all user directories here -UINCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(PLATFORMINC) $(BOARDINC) \ - $(CHIBIOS)/os/various +# 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 = -# List the user directory to look for the libraries here -ULIBDIR = +# 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 = -# List all user libraries here -ULIBS = +# 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) -# Define optimisation level here -OPT = $(XOPT) +INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ + $(HALINC) $(PLATFORMINC) $(BOARDINC) \ + $(CHIBIOS)/os/various # -# End of user defines -############################################################################################## +# Project, sources and paths +############################################################################## + +############################################################################## +# Compiler settings +# +MCU = cortex-m4 -INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) -LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) -DEFS = $(DDEFS) $(UDEFS) $(XDEFS) -ADEFS = $(DADEFS) $(UADEFS) -OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) -LIBS = $(DLIBS) $(ULIBS) +#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 +HEX = $(CP) -O ihex +BIN = $(CP) -O binary -LDFLAGS = -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) -ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) -CPFLAGS = $(OPT) -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ahlms=$(<:.c=.lst) $(DEFS) +# ARM-specific options here +AOPT = -# Generate dependency information -CPFLAGS += -MD -MP -MF .dep/$(@F).d +# 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 # -# makefile rules +# Compiler settings +############################################################################## + +############################################################################## +# Start of default section # -all: $(OBJS) $(PROJECT).exe +# List all default C defines here, like -D_DEBUG=1 +DDEFS = -%o : %c - $(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@ +# List all default ASM defines here, like -D_DEBUG=1 +DADEFS = -%o : %s - $(AS) -c $(ASFLAGS) $< -o $@ +# List all default directories to look for include files here +DINCDIR = -%exe: $(OBJS) - $(CC) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ +# List the default directory to look for the libraries here +DLIBDIR = -clean: - -rm -f $(OBJS) - -rm -f $(PROJECT).exe - -rm -f $(PROJECT).map - -rm -f $(SRC:.c=.c.bak) - -rm -f $(SRC:.c=.lst) - -rm -f $(ASRC:.s=.s.bak) - -rm -f $(ASRC:.s=.lst) - -rm -fR .dep +# List all default libraries here +DLIBS = # -# Include the dependency files, should be the last of the makefile +# End of default section +############################################################################## + +############################################################################## +# Start of user section # --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) -# *** EOF *** +# 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 diff --git a/testhal/testbuild/main.c b/testhal/testbuild/main.c index c10499d38..b6b76b26a 100644 --- a/testhal/testbuild/main.c +++ b/testhal/testbuild/main.c @@ -29,5 +29,5 @@ int main(int argc, char *argv[]) { (void)argc; (void)argv; - exit(0); + return 0; } -- cgit v1.2.3