2013-02-21 00:43:25 -04:00
|
|
|
TOOLCHAIN = NATIVE
|
|
|
|
|
|
|
|
include $(MK_DIR)/find_tools.mk
|
|
|
|
|
|
|
|
#
|
|
|
|
# Tool options
|
|
|
|
#
|
|
|
|
DEFINES = -DF_CPU=$(F_CPU)
|
2014-03-25 22:15:31 -03:00
|
|
|
DEFINES += -DSKETCH=\"$(SKETCH)\" -DSKETCHNAME="\"$(SKETCH)\"" -DAPM_BUILD_DIRECTORY=APM_BUILD_$(SKETCH)
|
2013-02-21 00:43:25 -04:00
|
|
|
DEFINES += $(EXTRAFLAGS) # from user config.mk
|
2014-07-06 23:04:54 -03:00
|
|
|
DEFINES += -DCONFIG_HAL_BOARD=$(HAL_BOARD) -DCONFIG_HAL_BOARD_SUBTYPE=$(HAL_BOARD_SUBTYPE)
|
2014-05-07 22:11:35 -03:00
|
|
|
WARNFLAGS = -Wformat -Wall -Wshadow -Wpointer-arith -Wcast-align -Wno-unused-parameter -Wno-missing-field-initializers
|
2013-02-21 00:43:25 -04:00
|
|
|
WARNFLAGS += -Wwrite-strings -Wformat=2
|
|
|
|
WARNFLAGSCXX = -Wno-reorder
|
|
|
|
DEPFLAGS = -MD -MT $@
|
|
|
|
|
|
|
|
CXXOPTS = -ffunction-sections -fdata-sections -fno-exceptions -fsigned-char
|
|
|
|
COPTS = -ffunction-sections -fdata-sections -fsigned-char
|
|
|
|
|
|
|
|
ASOPTS = -x assembler-with-cpp
|
2013-07-04 13:01:16 -03:00
|
|
|
|
2014-07-06 21:27:04 -03:00
|
|
|
# disable as this breaks distcc
|
|
|
|
#ifneq ($(SYSTYPE),Darwin)
|
|
|
|
#LISTOPTS = -adhlns=$(@:.o=.lst)
|
|
|
|
#endif
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2013-03-29 03:25:36 -03:00
|
|
|
CPUFLAGS = -D_GNU_SOURCE
|
|
|
|
CPULDFLAGS = -g
|
2013-09-28 05:39:14 -03:00
|
|
|
OPTFLAGS ?= -O0 -g
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2014-07-06 23:04:54 -03:00
|
|
|
CXXFLAGS = -g $(CPUFLAGS) $(DEFINES) $(OPTFLAGS)
|
2013-02-21 00:43:25 -04:00
|
|
|
CXXFLAGS += $(WARNFLAGS) $(WARNFLAGSCXX) $(DEPFLAGS) $(CXXOPTS)
|
|
|
|
CFLAGS = -g $(CPUFLAGS) $(DEFINES) -Wa,$(LISTOPTS) $(OPTFLAGS)
|
|
|
|
CFLAGS += $(WARNFLAGS) $(DEPFLAGS) $(COPTS)
|
|
|
|
ASFLAGS = -g $(CPUFLAGS) $(DEFINES) -Wa,$(LISTOPTS) $(DEPFLAGS)
|
|
|
|
ASFLAGS += $(ASOPTS)
|
|
|
|
LDFLAGS = -g $(CPUFLAGS) $(OPTFLAGS) $(WARNFLAGS)
|
2013-07-04 13:01:16 -03:00
|
|
|
|
|
|
|
ifneq ($(SYSTYPE),Darwin)
|
2013-02-21 00:43:25 -04:00
|
|
|
LDFLAGS += -Wl,--gc-sections -Wl,-Map -Wl,$(SKETCHMAP)
|
2013-07-04 13:01:16 -03:00
|
|
|
endif
|
2013-02-21 00:43:25 -04:00
|
|
|
|
2013-10-07 21:49:07 -03:00
|
|
|
LIBS ?= -lm -lpthread
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
ifeq ($(VERBOSE),)
|
|
|
|
v = @
|
|
|
|
else
|
|
|
|
v =
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Library object files
|
|
|
|
LIBOBJS := $(SKETCHLIBOBJS)
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Built products
|
|
|
|
#
|
|
|
|
|
|
|
|
# The ELF file
|
|
|
|
SKETCHELF = $(BUILDROOT)/$(SKETCH).elf
|
2014-11-13 02:27:53 -04:00
|
|
|
BUILDELF = $(notdir $(SKETCHELF))
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
# HEX file
|
|
|
|
SKETCHHEX = $(BUILDROOT)/$(SKETCH).hex
|
|
|
|
|
|
|
|
# EEP file
|
|
|
|
SKETCHEEP = $(BUILDROOT)/$(SKETCH).eep
|
|
|
|
|
|
|
|
# Map file
|
|
|
|
SKETCHMAP = $(BUILDROOT)/$(SKETCH).map
|
|
|
|
|
|
|
|
# All of the objects that may be built
|
|
|
|
ALLOBJS = $(SKETCHOBJS) $(LIBOBJS)
|
|
|
|
|
|
|
|
# All of the dependency files that may be generated
|
|
|
|
ALLDEPS = $(ALLOBJS:%.o=%.d)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Targets
|
|
|
|
#
|
|
|
|
|
|
|
|
all: $(SKETCHELF)
|
|
|
|
|
|
|
|
print-%:
|
|
|
|
echo "$*=$($*)"
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
# Rules
|
|
|
|
#
|
|
|
|
|
|
|
|
# fetch dependency info from a previous build if any of it exists
|
|
|
|
-include $(ALLDEPS)
|
|
|
|
|
|
|
|
# Link the final object
|
|
|
|
$(SKETCHELF): $(SKETCHOBJS) $(LIBOBJS)
|
2013-04-02 00:18:42 -03:00
|
|
|
@echo "Building $(SKETCHELF)"
|
2013-02-21 00:43:25 -04:00
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
2014-11-13 02:27:53 -04:00
|
|
|
$(v)cp $(SKETCHELF) .
|
|
|
|
@echo "Firmware is in $(BUILDELF)"
|
2013-02-21 00:43:25 -04:00
|
|
|
|
|
|
|
#
|
|
|
|
# Build sketch objects
|
|
|
|
#
|
|
|
|
SKETCH_INCLUDES = $(SKETCHLIBINCLUDES)
|
|
|
|
|
|
|
|
$(BUILDROOT)/%.o: $(BUILDROOT)/%.cpp
|
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(CXX) $(CXXFLAGS) -c -o $@ $< -I$(SRCROOT) $(SKETCH_INCLUDES)
|
|
|
|
|
|
|
|
$(BUILDROOT)/%.o: $(SRCROOT)/%.cpp
|
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SKETCH_INCLUDES)
|
|
|
|
|
|
|
|
$(BUILDROOT)/%.o: $(SRCROOT)/%.c
|
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(CC) $(CFLAGS) -c -o $@ $< $(SKETCH_INCLUDES)
|
|
|
|
|
|
|
|
$(BUILDROOT)/%.o: $(SRCROOT)/%.S
|
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(AS) $(ASFLAGS) -c -o $@ $< $(SKETCH_INCLUDES)
|
|
|
|
|
|
|
|
#
|
|
|
|
# Build library objects from sources in the sketchbook
|
|
|
|
#
|
|
|
|
SLIB_INCLUDES = -I$(dir $<)/utility $(SKETCHLIBINCLUDES)
|
|
|
|
|
|
|
|
$(BUILDROOT)/libraries/%.o: $(SKETCHBOOK)/libraries/%.cpp
|
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(CXX) $(CXXFLAGS) -c -o $@ $< $(SLIB_INCLUDES)
|
|
|
|
|
|
|
|
$(BUILDROOT)/libraries/%.o: $(SKETCHBOOK)/libraries/%.c
|
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(CC) $(CFLAGS) -c -o $@ $< $(SLIB_INCLUDES)
|
|
|
|
|
|
|
|
$(BUILDROOT)/libraries/%.o: $(SKETCHBOOK)/libraries/%.S
|
|
|
|
$(RULEHDR)
|
|
|
|
$(v)$(AS) $(ASFLAGS) -c -o $@ $< $(SLIB_INCLUDES)
|