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 17:16:26 +02:00
|
|
|
# Standard things
|
|
|
|
sp := $(sp).x
|
|
|
|
dirstack_$(sp) := $(d)
|
|
|
|
d := $(dir)
|
|
|
|
BUILDDIRS += $(BUILD_PATH)/$(d)
|
|
|
|
|
2012-03-20 22:44:34 +01:00
|
|
|
# Add board directory and MCU-specific directory to BUILDDIRS. These
|
|
|
|
# are in subdirectories, but they're logically part of the Wirish
|
|
|
|
# submodule.
|
|
|
|
WIRISH_BOARD_PATH := boards/$(BOARD)
|
|
|
|
BUILDDIRS += $(BUILD_PATH)/$(d)/$(WIRISH_BOARD_PATH)
|
|
|
|
BUILDDIRS += $(BUILD_PATH)/$(d)/$(MCU_SERIES)
|
Move public headers to include directories; related cleanups.
Move libmaple/*.h to (new) libmaple/include/libmaple/. The new
accepted way to include a libmaple header foo.h is with:
#include <libmaple/foo.h>
This is more polite in terms of the include namespace. It also allows
us to e.g. implement the Arduino SPI library at all (which has header
SPI.h; providing it was previously impossible on case-insensitive
filesystems due to libmaple's spi.h).
Similarly for Wirish.
The old include style (#include "header.h") is now deprecated.
libmaple/*.h:
- Change include guard #defines from _FOO_H_ to _LIBMAPLE_FOO_H_.
- Add license headers where they're missing
- Add conditional extern "C" { ... } blocks where they're missing
(they aren't always necessary, but we might was well do it against
the future, while we're at it.).
- Change includes from #include "foo.h" to #include <libmaple/foo.h>.
- Move includes after extern "C".
- Remove extra trailing newlines
Note that this doesn't include the headers under libmaple/usb/ or
libmaple/usb/usb_lib. These will get fixed later.
libmaple/*.c:
- Change includes from #include "foo.h" to #include <libmaple/foo.h>.
Makefile:
- Add I$(LIBMAPLE_PATH)/include/libmaple to GLOBAL_FLAGS. This allows
for users (including Wirish) to migrate their code, but should go
away ASAP, since it slows down compilation.
Wirish:
- Move wirish/**/*.h to (new) wirish/include/wirish/. This ignores
the USB headers, which, as usual, are getting handled after
everything else.
- Similarly generify wirish/boards/ structure. For each supported
board "foo", move wirish/boards/foo.h and wirish/boards/foo.cpp to
wirish/boards/foo/include/board/board.h and
wirish/boards/foo/board.cpp, respectively. Also remove the #ifdef
hacks around the .cpp files.
- wirish/rules.mk: put wirish/boards/foo/include in the include path
(and add wirish/boards/foo/board.cpp to the list of sources to be
compiled). This allows saying:
#include <board/board.h>
instead of the hack currently in place. We can allow the user to
override this setting later to make adding custom board definitions
easier.
- Disable -Werror in libmaple/rules.mk, as the current USB warnings
don't let the olimex_stm32_h103 board compile. We can re-enable
-Werror once we've moved the board-specific bits out of libmaple
proper.
libraries, examples:
- Update includes accordingly.
- Miscellaneous cosmetic fixups.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-11-15 18:45:43 +01:00
|
|
|
|
2012-03-20 22:44:34 +01:00
|
|
|
# Safe includes for Wirish.
|
|
|
|
WIRISH_INCLUDES := -I$(d)/include -I$(d)/$(WIRISH_BOARD_PATH)/include
|
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 17:16:26 +02:00
|
|
|
|
2012-03-20 22:44:34 +01:00
|
|
|
# Local flags. Add -I$(d) to allow for private includes.
|
|
|
|
CFLAGS_$(d) := $(LIBMAPLE_INCLUDES) $(WIRISH_INCLUDES) -I$(d)
|
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 17:16:26 +02:00
|
|
|
|
|
|
|
# Local rules and targets
|
2011-11-15 09:10:04 +01:00
|
|
|
sSRCS_$(d) := start.S
|
|
|
|
cSRCS_$(d) := start_c.c
|
2012-06-07 11:45:10 +02:00
|
|
|
cSRCS_$(d) += syscalls.c
|
2012-06-27 00:03:40 +02:00
|
|
|
cSRCS_$(d) += $(MCU_SERIES)/util_hooks.c
|
2012-03-20 22:44:34 +01:00
|
|
|
cppSRCS_$(d) := boards.cpp
|
2012-05-31 23:17:06 +02:00
|
|
|
cppSRCS_$(d) += cxxabi-compat.cpp
|
Bring back EXTI on F1, with deprecations for gpio.h on F1.
Tested on Maple Mini with examples/mini-exti-test. Changes to Wirish
are minor: use the new EXTI types exti_num and exti_cfg (see below) in
place of now-deprecated variants in ext_interrupts.cpp.
The way I originally did libmaple/exti.h was stupid, and fixing it
turned out to be a little disruptive.
libmaple/exti.h depends on libmaple/gpio.h (for AFIO), but that's a
classic case of exposed implementation detail. So invert the
dependency: make gpio.h depend on exti.h. Do this by adding exti_num
and exti_cfg to exti.h; these respectively replace afio_exti_num and
afio_exti_port. The afio_* variants are now deprecated. (Throw in a
typedef and some macros at the bottom of the F1 series/gpio.h for
backwards compatibility).
Make exti_attach_interrupt() and exti_detach_interrupt() take
exti_num/exti_cfg arguments instead of the afio_* variants.
Make the EXTI dispatch routines __always_inline to defeat GCC -Os.
Many renames throughout libmaple/stm32f1/ to stop using the deprecated
names. Also move the previously F1-only gpio_exti_port() function into
the public libmaple header. Reimplementing it in terms of rcc_clk_ids
lets us deprecate the gpio_dev->exti_port field, which will save space
in the future.
While we're there, I notice that struct gpio_dev is defined once per
series. That's dumb, as it misses the entire point of having device
structs: they contain what's portable. So put the F1 version (which
has the extra EXTI port field) into libmaple/gpio.h, and add the
necessary exti_ports to libmaple/stm32f2/gpio.c. Sigh. We'll get rid
of it eventually, at least.
Clean up some other mistakes in gpio.h files as well (mostly removing
util.h dependency). Sorry for the messy commit.
For portability, add a new series-specific exti function,
exti_select(). The F1 version in (new) libmaple/stm32f1/exti.c uses
AFIO and some new private functionality in libmaple/exti.c and (new)
libmaple/exti_private.h to make this convenient. We'll be able to do
the SYSCFG equivalent on F2 without any trouble.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-04 02:30:13 +02:00
|
|
|
cppSRCS_$(d) += ext_interrupts.cpp
|
Bring back HardwareSerial.
To make this happen, we need to have <board/board.h> tell us whether
or not it's got each of the USARTs. Do that with BOARD_HAVE_USARTn,
for n = 1,...,6. This lets us define HardwareSerial instances only
when appropriate, and gets rid of some board-specific hacks we'd
accumulated.
The new <libmaple/usart.h> now has a convenience function for
determining the bus rate by using the appropriate STM32_PCLKx macro,
so we can shave a uint32 per instance, which is nice given that
they're all going to be in memory. This changes the constructor
arguments, but the API only specifies the semantics of the predefined
instances, so this is still backwards-compatible. (We should look into
storing the instances in Flash -- they don't change, after all.)
We don't actually need struct usart_dev's definition in
HardwareSerial.h, so replace it with a forward declaration and include
<libmaple/usart.h> it in HardwareSerial.cpp instead.
Assert some copyrights.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-01 07:10:47 +02:00
|
|
|
cppSRCS_$(d) += HardwareSerial.cpp
|
2012-06-01 09:26:19 +02:00
|
|
|
cppSRCS_$(d) += HardwareTimer.cpp
|
2012-06-01 00:57:41 +02:00
|
|
|
cppSRCS_$(d) += Print.cpp
|
2012-06-03 03:15:17 +02:00
|
|
|
cppSRCS_$(d) += pwm.cpp
|
2012-06-03 12:00:41 +02:00
|
|
|
ifeq ($(MCU_SERIES), stm32f1)
|
|
|
|
cppSRCS_$(d) += usb_serial.cpp # HACK: this is currently STM32F1 only.
|
2012-06-27 00:13:12 +02:00
|
|
|
cppSRCS_$(d) += HardwareSPI.cpp # FIXME: port to F2 and fix wirish.h
|
2012-06-03 12:00:41 +02:00
|
|
|
endif
|
2012-06-01 08:04:59 +02:00
|
|
|
cppSRCS_$(d) += wirish_analog.cpp
|
2012-05-31 23:17:06 +02:00
|
|
|
cppSRCS_$(d) += wirish_digital.cpp
|
2012-06-01 01:20:01 +02:00
|
|
|
cppSRCS_$(d) += wirish_math.cpp
|
2012-06-01 00:47:39 +02:00
|
|
|
cppSRCS_$(d) += wirish_shift.cpp
|
2012-06-01 01:15:43 +02:00
|
|
|
cppSRCS_$(d) += wirish_time.cpp
|
2012-05-31 23:17:06 +02:00
|
|
|
cppSRCS_$(d) += $(MCU_SERIES)/boards_setup.cpp
|
|
|
|
cppSRCS_$(d) += $(MCU_SERIES)/wirish_digital.cpp
|
2012-06-09 00:34:33 +02:00
|
|
|
cppSRCS_$(d) += $(MCU_SERIES)/wirish_debug.cpp
|
2012-05-31 23:17:06 +02:00
|
|
|
cppSRCS_$(d) += $(WIRISH_BOARD_PATH)/board.cpp
|
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 17:16:26 +02:00
|
|
|
|
2011-11-15 09:10:04 +01:00
|
|
|
sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%)
|
2011-03-24 22:27:38 +01:00
|
|
|
cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
|
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 17:16:26 +02:00
|
|
|
cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
|
|
|
|
|
2011-11-15 09:10:04 +01:00
|
|
|
OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \
|
|
|
|
$(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
|
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 17:16:26 +02:00
|
|
|
$(cppFILES_$(d):%.cpp=$(BUILD_PATH)/%.o)
|
|
|
|
DEPS_$(d) := $(OBJS_$(d):%.o=%.d)
|
|
|
|
|
|
|
|
$(OBJS_$(d)): TGT_CFLAGS := $(CFLAGS_$(d))
|
|
|
|
|
|
|
|
TGT_BIN += $(OBJS_$(d))
|
|
|
|
|
|
|
|
# Standard things
|
|
|
|
-include $(DEPS_$(d))
|
|
|
|
d := $(dirstack_$(sp))
|
|
|
|
sp := $(basename $(sp))
|