From 68a784d67e7ff1ce1c922819e5e8f1d6865c69da Mon Sep 17 00:00:00 2001 From: inmarket Date: Wed, 1 Oct 2014 00:44:40 +1000 Subject: First ARM build to use the new makefile plus makefile updates --- 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 +++---- 7 files changed, 152 insertions(+), 16 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 (limited to 'tools') 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 ---------------------------- -- cgit v1.2.3