2012-03-29 10:42:38 +02:00
|
|
|
#
|
|
|
|
# Copyright (c) 2012 Google, Inc. All right reserved.
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This library is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-04-28 09:51:54 +02:00
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
2012-03-29 10:42:38 +02:00
|
|
|
# See the GNU Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public
|
|
|
|
# License along with this library; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
#
|
|
|
|
|
|
|
|
# Makefile for compiling libArduino
|
|
|
|
.SUFFIXES: .o .a .c .s
|
|
|
|
|
|
|
|
CHIP=__SAM3X8E__
|
|
|
|
VARIANT=adk2
|
|
|
|
LIBNAME=libvariant_$(VARIANT)
|
|
|
|
TOOLCHAIN=gcc
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Path
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
# Output directories
|
|
|
|
OUTPUT_BIN = ../../../cores/sam
|
|
|
|
|
|
|
|
# Libraries
|
|
|
|
PROJECT_BASE_PATH = ..
|
|
|
|
SYSTEM_PATH = ../../../system
|
2012-04-28 09:51:54 +02:00
|
|
|
CMSIS_ROOT_PATH = $(SYSTEM_PATH)/CMSIS
|
|
|
|
CMSIS_ARM_PATH=$(CMSIS_ROOT_PATH)/CMSIS/Include
|
|
|
|
CMSIS_ATMEL_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL
|
|
|
|
#CMSIS_CHIP_PATH=$(CMSIS_ROOT_PATH)/Device/ATMEL/$(CHIP_SERIE)
|
|
|
|
|
2012-03-29 10:42:38 +02:00
|
|
|
ARDUINO_PATH = ../../../cores/sam
|
|
|
|
VARIANT_BASE_PATH = ../../../variants
|
|
|
|
VARIANT_PATH = ../../../variants/$(VARIANT)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Files
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
2012-04-28 09:51:54 +02:00
|
|
|
vpath %.h $(PROJECT_BASE_PATH) $(SYSTEM_PATH) $(VARIANT_PATH)
|
|
|
|
vpath %.cpp $(PROJECT_BASE_PATH) $(PROJECT_BASE_PATH)
|
2012-03-29 10:42:38 +02:00
|
|
|
|
|
|
|
VPATH+=$(PROJECT_BASE_PATH)
|
|
|
|
|
2012-04-28 09:51:54 +02:00
|
|
|
INCLUDES =
|
2012-03-29 10:42:38 +02:00
|
|
|
#INCLUDES += -I$(PROJECT_BASE_PATH)
|
|
|
|
INCLUDES += -I$(ARDUINO_PATH)
|
|
|
|
INCLUDES += -I$(SYSTEM_PATH)
|
|
|
|
INCLUDES += -I$(SYSTEM_PATH)/libsam
|
|
|
|
INCLUDES += -I$(VARIANT_BASE_PATH)
|
|
|
|
INCLUDES += -I$(VARIANT_PATH)
|
2012-04-28 09:51:54 +02:00
|
|
|
INCLUDES += -I$(CMSIS_ARM_PATH)
|
|
|
|
INCLUDES += -I$(CMSIS_ATMEL_PATH)
|
2012-03-29 10:42:38 +02:00
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
ifdef DEBUG
|
|
|
|
include debug.mk
|
|
|
|
else
|
|
|
|
include release.mk
|
|
|
|
endif
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Tools
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
include $(TOOLCHAIN).mk
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
ifdef DEBUG
|
|
|
|
OUTPUT_OBJ=debug
|
|
|
|
OUTPUT_LIB_POSTFIX=dbg
|
|
|
|
else
|
|
|
|
OUTPUT_OBJ=release
|
|
|
|
OUTPUT_LIB_POSTFIX=rel
|
|
|
|
endif
|
|
|
|
|
|
|
|
OUTPUT_LIB=$(LIBNAME)_$(TOOLCHAIN)_$(OUTPUT_LIB_POSTFIX).a
|
|
|
|
OUTPUT_PATH=$(OUTPUT_OBJ)_$(VARIANT)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# C source files and objects
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
C_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.c)
|
|
|
|
|
|
|
|
C_OBJ_TEMP = $(patsubst %.c, %.o, $(notdir $(C_SRC)))
|
|
|
|
|
|
|
|
# during development, remove some files
|
|
|
|
C_OBJ_FILTER=
|
|
|
|
|
|
|
|
C_OBJ=$(filter-out $(C_OBJ_FILTER), $(C_OBJ_TEMP))
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# CPP source files and objects
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
CPP_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.cpp)
|
|
|
|
|
|
|
|
CPP_OBJ_TEMP = $(patsubst %.cpp, %.o, $(notdir $(CPP_SRC)))
|
|
|
|
|
|
|
|
# during development, remove some files
|
|
|
|
CPP_OBJ_FILTER=
|
|
|
|
|
|
|
|
CPP_OBJ=$(filter-out $(CPP_OBJ_FILTER), $(CPP_OBJ_TEMP))
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Assembler source files and objects
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
A_SRC=$(wildcard $(PROJECT_BASE_PATH)/*.s)
|
|
|
|
|
|
|
|
A_OBJ_TEMP=$(patsubst %.s, %.o, $(notdir $(A_SRC)))
|
|
|
|
|
|
|
|
# during development, remove some files
|
|
|
|
A_OBJ_FILTER=
|
|
|
|
|
|
|
|
A_OBJ=$(filter-out $(A_OBJ_FILTER), $(A_OBJ_TEMP))
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# Rules
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
all: $(VARIANT)
|
|
|
|
|
|
|
|
$(VARIANT): create_output $(OUTPUT_LIB)
|
|
|
|
|
|
|
|
.PHONY: create_output
|
|
|
|
create_output:
|
|
|
|
@echo -------------------------
|
2012-04-28 09:51:54 +02:00
|
|
|
@echo --- Preparing $(VARIANT) files in $(OUTPUT_PATH) $(OUTPUT_BIN)
|
2012-03-29 10:42:38 +02:00
|
|
|
@echo -------------------------
|
2012-04-28 09:51:54 +02:00
|
|
|
# @echo *$(INCLUDES)
|
|
|
|
# @echo -------------------------
|
|
|
|
# @echo *$(C_SRC)
|
|
|
|
# @echo -------------------------
|
|
|
|
# @echo *$(C_OBJ)
|
|
|
|
# @echo -------------------------
|
|
|
|
# @echo *$(addprefix $(OUTPUT_PATH)/, $(C_OBJ))
|
|
|
|
# @echo -------------------------
|
|
|
|
# @echo *$(CPP_SRC)
|
|
|
|
# @echo -------------------------
|
|
|
|
# @echo *$(CPP_OBJ)
|
|
|
|
# @echo -------------------------
|
|
|
|
# @echo *$(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ))
|
|
|
|
# @echo -------------------------
|
|
|
|
# @echo *$(A_SRC)
|
|
|
|
# @echo -------------------------
|
2012-03-29 10:42:38 +02:00
|
|
|
|
|
|
|
-@mkdir $(OUTPUT_PATH) 1>NUL 2>&1
|
|
|
|
|
|
|
|
$(addprefix $(OUTPUT_PATH)/,$(C_OBJ)): $(OUTPUT_PATH)/%.o: %.c
|
2012-04-28 09:51:54 +02:00
|
|
|
# @"$(CC)" -v -c $(CFLAGS) $< -o $@
|
|
|
|
@"$(CC)" -c $(CFLAGS) $< -o $@
|
2012-03-29 10:42:38 +02:00
|
|
|
|
|
|
|
$(addprefix $(OUTPUT_PATH)/,$(CPP_OBJ)): $(OUTPUT_PATH)/%.o: %.cpp
|
2012-04-28 09:51:54 +02:00
|
|
|
# @"$(CC)" -c $(CPPFLAGS) $< -o $@
|
|
|
|
@"$(CC)" -xc++ -c $(CPPFLAGS) $< -o $@
|
2012-03-29 10:42:38 +02:00
|
|
|
|
|
|
|
$(addprefix $(OUTPUT_PATH)/,$(A_OBJ)): $(OUTPUT_PATH)/%.o: %.s
|
2012-04-28 09:51:54 +02:00
|
|
|
@"$(AS)" -c $(ASFLAGS) $< -o $@
|
2012-03-29 10:42:38 +02:00
|
|
|
|
|
|
|
$(OUTPUT_LIB): $(addprefix $(OUTPUT_PATH)/, $(C_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(CPP_OBJ)) $(addprefix $(OUTPUT_PATH)/, $(A_OBJ))
|
2012-04-28 09:51:54 +02:00
|
|
|
@"$(AR)" -v -r "$(OUTPUT_BIN)/$@" $^
|
|
|
|
@"$(NM)" "$(OUTPUT_BIN)/$@" > "$(OUTPUT_BIN)/$@.txt"
|
2012-03-29 10:42:38 +02:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
|
|
@echo --- Cleaning $(VARIANT) files [$(OUTPUT_PATH)$(SEP)*.o]
|
|
|
|
-@$(RM) $(OUTPUT_PATH) 1>NUL 2>&1
|
|
|
|
-@$(RM) $(OUTPUT_BIN)/$(OUTPUT_LIB) 1>NUL 2>&1
|