make: Modularize makefiles, add dependency tracking, build-type tracking
Major build system rewrite. New and exciting:
1. Proper dependency tracking. All source files including header files
should be properly tracked and recompiled as necessary when they are
changed.
2. Build-type tracking. If the target changes from 'ram' to 'flash,'
for example, the build system will force a rebuild rather than
incorrectly link modules to a different address.
3. New targets:
The old 'ram,' 'flash,' and 'jtag' targets have been replaced with
the environment variable MAPLE_TARGET, which controls the link address.
Users can either export it to their environment, or pass MAPLE_TARGET on
the command-line. Once this is set, sketches can be compiled with 'make
sketch,' or simply 'make.'
Note: the default is MAPLE_TARGET='flash.'
The target 'install' now automagically uploads the sketch to the board
using the appropriate method.
The 'run' target has been renamed to 'debug.' It starts an openocd gdb
server.
4. Odds and ends:
-Verbose and 'quiet' modes. Set V=1 for verbose compilation, the default
is quiet.
-Object file sizes and disassembly information is generated and placed
in build/$(BOARD).sizes and build/$(BOARD).disas, respectively.
-Parallel make with -j should speed things up if you have multiple
cores.
2010-06-24 11:16:26 -04:00
|
|
|
# Useful tools
|
2013-05-27 15:19:59 +02:00
|
|
|
CROSS_COMPILE ?= arm-none-eabi-
|
|
|
|
|
|
|
|
CC := $(CROSS_COMPILE)gcc
|
|
|
|
CXX := $(CROSS_COMPILE)g++
|
|
|
|
LD := $(CROSS_COMPILE)ld -v
|
|
|
|
AR := $(CROSS_COMPILE)ar
|
|
|
|
AS := $(CROSS_COMPILE)gcc
|
|
|
|
OBJCOPY := $(CROSS_COMPILE)objcopy
|
|
|
|
DISAS := $(CROSS_COMPILE)objdump
|
|
|
|
OBJDUMP := $(CROSS_COMPILE)objdump
|
|
|
|
SIZE := $(CROSS_COMPILE)size
|
make: Modularize makefiles, add dependency tracking, build-type tracking
Major build system rewrite. New and exciting:
1. Proper dependency tracking. All source files including header files
should be properly tracked and recompiled as necessary when they are
changed.
2. Build-type tracking. If the target changes from 'ram' to 'flash,'
for example, the build system will force a rebuild rather than
incorrectly link modules to a different address.
3. New targets:
The old 'ram,' 'flash,' and 'jtag' targets have been replaced with
the environment variable MAPLE_TARGET, which controls the link address.
Users can either export it to their environment, or pass MAPLE_TARGET on
the command-line. Once this is set, sketches can be compiled with 'make
sketch,' or simply 'make.'
Note: the default is MAPLE_TARGET='flash.'
The target 'install' now automagically uploads the sketch to the board
using the appropriate method.
The 'run' target has been renamed to 'debug.' It starts an openocd gdb
server.
4. Odds and ends:
-Verbose and 'quiet' modes. Set V=1 for verbose compilation, the default
is quiet.
-Object file sizes and disassembly information is generated and placed
in build/$(BOARD).sizes and build/$(BOARD).disas, respectively.
-Parallel make with -j should speed things up if you have multiple
cores.
2010-06-24 11:16:26 -04:00
|
|
|
DFU := dfu-util
|
|
|
|
|
|
|
|
# Suppress annoying output unless V is set
|
|
|
|
ifndef V
|
|
|
|
SILENT_CC = @echo ' [CC] ' $(@:$(BUILD_PATH)/%.o=%.c);
|
2010-09-17 03:49:14 -04:00
|
|
|
SILENT_AS = @echo ' [AS] ' $(@:$(BUILD_PATH)/%.o=%.S);
|
make: Modularize makefiles, add dependency tracking, build-type tracking
Major build system rewrite. New and exciting:
1. Proper dependency tracking. All source files including header files
should be properly tracked and recompiled as necessary when they are
changed.
2. Build-type tracking. If the target changes from 'ram' to 'flash,'
for example, the build system will force a rebuild rather than
incorrectly link modules to a different address.
3. New targets:
The old 'ram,' 'flash,' and 'jtag' targets have been replaced with
the environment variable MAPLE_TARGET, which controls the link address.
Users can either export it to their environment, or pass MAPLE_TARGET on
the command-line. Once this is set, sketches can be compiled with 'make
sketch,' or simply 'make.'
Note: the default is MAPLE_TARGET='flash.'
The target 'install' now automagically uploads the sketch to the board
using the appropriate method.
The 'run' target has been renamed to 'debug.' It starts an openocd gdb
server.
4. Odds and ends:
-Verbose and 'quiet' modes. Set V=1 for verbose compilation, the default
is quiet.
-Object file sizes and disassembly information is generated and placed
in build/$(BOARD).sizes and build/$(BOARD).disas, respectively.
-Parallel make with -j should speed things up if you have multiple
cores.
2010-06-24 11:16:26 -04:00
|
|
|
SILENT_CXX = @echo ' [CXX] ' $(@:$(BUILD_PATH)/%.o=%.cpp);
|
|
|
|
SILENT_LD = @echo ' [LD] ' $(@F);
|
|
|
|
SILENT_AR = @echo ' [AR] '
|
|
|
|
SILENT_OBJCOPY = @echo ' [OBJCOPY] ' $(@F);
|
|
|
|
SILENT_DISAS = @echo ' [DISAS] ' $(@:$(BUILD_PATH)/%.bin=%).disas;
|
|
|
|
SILENT_OBJDUMP = @echo ' [OBJDUMP] ' $(OBJDUMP);
|
|
|
|
endif
|
|
|
|
|
2012-08-05 13:27:13 -04:00
|
|
|
# Extra build configuration
|
|
|
|
|
make: Modularize makefiles, add dependency tracking, build-type tracking
Major build system rewrite. New and exciting:
1. Proper dependency tracking. All source files including header files
should be properly tracked and recompiled as necessary when they are
changed.
2. Build-type tracking. If the target changes from 'ram' to 'flash,'
for example, the build system will force a rebuild rather than
incorrectly link modules to a different address.
3. New targets:
The old 'ram,' 'flash,' and 'jtag' targets have been replaced with
the environment variable MAPLE_TARGET, which controls the link address.
Users can either export it to their environment, or pass MAPLE_TARGET on
the command-line. Once this is set, sketches can be compiled with 'make
sketch,' or simply 'make.'
Note: the default is MAPLE_TARGET='flash.'
The target 'install' now automagically uploads the sketch to the board
using the appropriate method.
The 'run' target has been renamed to 'debug.' It starts an openocd gdb
server.
4. Odds and ends:
-Verbose and 'quiet' modes. Set V=1 for verbose compilation, the default
is quiet.
-Object file sizes and disassembly information is generated and placed
in build/$(BOARD).sizes and build/$(BOARD).disas, respectively.
-Parallel make with -j should speed things up if you have multiple
cores.
2010-06-24 11:16:26 -04:00
|
|
|
BUILDDIRS :=
|
|
|
|
TGT_BIN :=
|
|
|
|
|
|
|
|
CFLAGS = $(GLOBAL_CFLAGS) $(TGT_CFLAGS)
|
|
|
|
CXXFLAGS = $(GLOBAL_CXXFLAGS) $(TGT_CXXFLAGS)
|
2010-09-17 03:49:14 -04:00
|
|
|
ASFLAGS = $(GLOBAL_ASFLAGS) $(TGT_ASFLAGS)
|
make: Modularize makefiles, add dependency tracking, build-type tracking
Major build system rewrite. New and exciting:
1. Proper dependency tracking. All source files including header files
should be properly tracked and recompiled as necessary when they are
changed.
2. Build-type tracking. If the target changes from 'ram' to 'flash,'
for example, the build system will force a rebuild rather than
incorrectly link modules to a different address.
3. New targets:
The old 'ram,' 'flash,' and 'jtag' targets have been replaced with
the environment variable MAPLE_TARGET, which controls the link address.
Users can either export it to their environment, or pass MAPLE_TARGET on
the command-line. Once this is set, sketches can be compiled with 'make
sketch,' or simply 'make.'
Note: the default is MAPLE_TARGET='flash.'
The target 'install' now automagically uploads the sketch to the board
using the appropriate method.
The 'run' target has been renamed to 'debug.' It starts an openocd gdb
server.
4. Odds and ends:
-Verbose and 'quiet' modes. Set V=1 for verbose compilation, the default
is quiet.
-Object file sizes and disassembly information is generated and placed
in build/$(BOARD).sizes and build/$(BOARD).disas, respectively.
-Parallel make with -j should speed things up if you have multiple
cores.
2010-06-24 11:16:26 -04:00
|
|
|
|
2012-08-05 13:27:13 -04:00
|
|
|
# Hacks to determine extra libraries we need to link against based on
|
|
|
|
# the toolchain. The default specifies no extra libraries, but it can
|
|
|
|
# be overridden.
|
|
|
|
LD_TOOLCHAIN_PATH := $(LDDIR)/toolchains/generic
|
|
|
|
ifneq ($(findstring ARM/embedded,$(shell $(CC) --version)),)
|
|
|
|
# GCC ARM Embedded, https://launchpad.net/gcc-arm-embedded/
|
|
|
|
LD_TOOLCHAIN_PATH := $(LDDIR)/toolchains/gcc-arm-embedded
|
|
|
|
endif
|
2013-01-05 19:23:30 +04:00
|
|
|
ifneq ($(findstring Linaro GCC,$(shell $(CC) --version)),)
|
|
|
|
# Summon/Linaro GCC ARM Embedded, https://github.com/esden/summon-arm-toolchain
|
|
|
|
LD_TOOLCHAIN_PATH := $(LDDIR)/toolchains/gcc-arm-embedded
|
|
|
|
endif
|
2012-08-05 13:27:13 -04:00
|
|
|
# Add toolchain directory to LD search path
|
|
|
|
TOOLCHAIN_LDFLAGS := -L $(LD_TOOLCHAIN_PATH)
|
|
|
|
|
make: Modularize makefiles, add dependency tracking, build-type tracking
Major build system rewrite. New and exciting:
1. Proper dependency tracking. All source files including header files
should be properly tracked and recompiled as necessary when they are
changed.
2. Build-type tracking. If the target changes from 'ram' to 'flash,'
for example, the build system will force a rebuild rather than
incorrectly link modules to a different address.
3. New targets:
The old 'ram,' 'flash,' and 'jtag' targets have been replaced with
the environment variable MAPLE_TARGET, which controls the link address.
Users can either export it to their environment, or pass MAPLE_TARGET on
the command-line. Once this is set, sketches can be compiled with 'make
sketch,' or simply 'make.'
Note: the default is MAPLE_TARGET='flash.'
The target 'install' now automagically uploads the sketch to the board
using the appropriate method.
The 'run' target has been renamed to 'debug.' It starts an openocd gdb
server.
4. Odds and ends:
-Verbose and 'quiet' modes. Set V=1 for verbose compilation, the default
is quiet.
-Object file sizes and disassembly information is generated and placed
in build/$(BOARD).sizes and build/$(BOARD).disas, respectively.
-Parallel make with -j should speed things up if you have multiple
cores.
2010-06-24 11:16:26 -04:00
|
|
|
# General directory independent build rules, generate dependency information
|
|
|
|
$(BUILD_PATH)/%.o: %.c
|
|
|
|
$(SILENT_CC) $(CC) $(CFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $<
|
|
|
|
|
|
|
|
$(BUILD_PATH)/%.o: %.cpp
|
|
|
|
$(SILENT_CXX) $(CXX) $(CFLAGS) $(CXXFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $<
|
|
|
|
|
2010-09-17 03:49:14 -04:00
|
|
|
$(BUILD_PATH)/%.o: %.S
|
|
|
|
$(SILENT_AS) $(AS) $(ASFLAGS) -MMD -MP -MF $(@:%.o=%.d) -MT $@ -o $@ -c $<
|