bladeRF/fx3_firmware/make/toolchain.mk.sample

144 lines
4.6 KiB
Text

#
# This file has been written for compatibility with FX3 SDK v1.3.3.
# Earlier versions are not supported due to differences in file hierarchies.
#
# However, FX3 SDK 1.3.3 ships with libraries from earlier releases. If you
# require earlier versions, point to a different entry under the fw_lib
# directory. (This can be done by changing the FX3_SDK_VERSION variable.)
#
# Copy this file to toolchain.mk and ensure the following are filled in
# correctly for your system:
#
# FX3_ROOT - Path to FX3 SDK
# ARMGCC_INSTALL_PATH - Path to ARM GCC toolchain within the FX3 SDK
# ARMGCC_VERSION - Version number of GCC toolchain included in SDK
# FX3_FW_DIR - "firmware" directory in FX3 SDK
#
# If you edit this file, be wary of potential path-related issues.
# (Specifically, be careful will paths with spaces. These will likely appear
# in Windows-based builds if default install paths are used.
################################################################################
# Hack to check if we're in windows, otherwise assume *nix
ifdef SystemRoot
HOST_IS_WINDOWS := y
endif
# Running into some issues with Windows paths, as back-escaped spaces in paths
# are needed for make, but this doesn't fly when executing external programs
# (e.g., gcc, ld)
#
# This is a little hack to replace a paths with escaped spaces
# with a quoted, space-containing path.
#
# If anyone has any suggestions or advice on cleaning this up,
# please feel free to create an issue at:
#
# https://github.com/nuand/bladerf/issues
#
pathfixup = $(if $(HOST_IS_WINDOWS),"$(subst /,\,$(subst \ , ,$(1)))",$(1))
# These are the items that will likely vary system to system
FX3_SDK_VERSION ?= 1.3.3
ARMGCC_VERSION ?= 4.8.1
FX3_VERPATH ?= $(subst .,_,$(FX3_SDK_VERSION))
################################
# Paths
################################
ifdef HOST_IS_WINDOWS
FX3_ROOT ?= C:/Program\ Files\ (x86)/Cypress/EZ-USB\ FX3\ SDK/1.3
ARMGCC_INSTALL_PATH ?= $(FX3_ROOT)/ARM\ GCC
FX3_FW_DIR := $(FX3_ROOT)/fw_lib/$(FX3_VERPATH)
ELF2IMG_DIR := $(FX3_ROOT)/util/elf2img
else
FX3_ROOT ?= /opt/cypress/fx3_sdk
ARMGCC_INSTALL_PATH ?= $(FX3_ROOT)/arm-2013.11
FX3_FW_DIR := $(FX3_ROOT)/cyfx3sdk/fw_lib/$(FX3_VERPATH)
ELF2IMG_DIR := $(FX3_ROOT)/cyfx3sdk/util/elf2img
endif
# Header files for our target device
FX3_INC_DIR := $(FX3_FW_DIR)/inc
# Library directory
ifdef DEBUG
FX3_LIB_DIR := $(FX3_FW_DIR)/fx3_debug
else
FX3_LIB_DIR := $(FX3_FW_DIR)/fx3_release
endif
# Path to some build depdencies - we'll need to compile/assemble a few items
# from this directory and link against them
TOOLCHAIN_DEPS_DIR := $(FX3_FW_DIR)/../../firmware/common
################################
# Libraries
################################
FX3_LIBGCC := $(ARMGCC_INSTALL_PATH)/lib/gcc/arm-none-eabi/$(ARMGCC_VERSION)/libgcc.a
FX3_LIBC := $(ARMGCC_INSTALL_PATH)/arm-none-eabi/lib/libc.a
# Careful if you're making changes here - remember that order matters.
FX3_LIBS := $(call pathfixup,$(FX3_LIB_DIR)/libcyfxapi.a) \
$(call pathfixup,$(FX3_LIB_DIR)/libcyu3lpp.a) \
$(call pathfixup,$(FX3_LIB_DIR)/libcyu3threadx.a)\
$(call pathfixup,$(FX3_LIBC)) \
$(call pathfixup,$(FX3_LIBGCC))
################################
# Tools
################################
# Setup host and cross tools
CROSS_COMPILE ?= $(ARMGCC_INSTALL_PATH)/bin/arm-none-eabi-
HOST_CC := $(CC)
CC := $(call pathfixup,$(CROSS_COMPILE)gcc)
LD := $(call pathfixup,$(CROSS_COMPILE)ld)
FW_INC := -I$(call pathfixup,$(FX3_INC_DIR))
LINKER_FILE := $(call pathfixup,$(TOOLCHAIN_DEPS_DIR)/fx3.ld)
ifdef HOST_IS_WINDOWS
RM := cs-rm
else
RM := rm
endif
# Set up toolchain specific compiler and linker flags
TOOLCHAIN_CFLAGS := -DCYU3P_FX3=1 -D__CYU3P_TX__=1 \
-mcpu=arm926ej-s -mthumb-interwork \
$(FW_INC)
ifdef DEBUG
TOOLCHAIN_CFLAGS += -DTX_ENABLE_EVENT_TRACE
endif
TOOLCHAIN_LDFLAGS := --entry CyU3PFirmwareEntry \
$(FX3_LIBS) \
-T $(LINKER_FILE) -d --gc-sections \
--no-wchar-size-warning
################################
# Dependencies
################################
TOOLCHAIN_DEPS_SRC_C := $(TOOLCHAIN_DEPS_DIR)/cyfxtx.c
TOOLCHAIN_DEPS_SRC_A := $(TOOLCHAIN_DEPS_DIR)/cyfx_gcc_startup.S
TOOLCHAIN_DEPS_OBJ_C := $(strip $(notdir $(TOOLCHAIN_DEPS_SRC_C:.c=.o)))
TOOLCHAIN_DEPS_OBJ_A := $(strip $(notdir $(TOOLCHAIN_DEPS_SRC_A:.S=.o)))
TOOLCHAIN_DEPS_OBJ := $(TOOLCHAIN_DEPS_OBJ_C) $(TOOLCHAIN_DEPS_OBJ_A)
ifdef HOST_IS_WINDOWS
ELF2IMG_SRC :=
ELF2IMG := $(ELF2IMG_DIR)/elf2img.exe
else
ELF2IMG_SRC := $(call pathfixup,$(ELF2IMG_DIR)/elf2img.c)
ELF2IMG := $(OUTPUT_DIR)/elf2img
endif
build_toolchain_dep = $(CC) $(call pathfixup,$(1)) $(CFLAGS) -c -o $(2)