libmaple/wirish/rules.mk

63 lines
2 KiB
Makefile
Raw Permalink Normal View History

# Standard things
sp := $(sp).x
dirstack_$(sp) := $(d)
d := $(dir)
BUILDDIRS += $(BUILD_PATH)/$(d)
# 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
# Safe includes for Wirish.
WIRISH_INCLUDES := -I$(d)/include -I$(d)/$(WIRISH_BOARD_PATH)/include
# Local flags. Add -I$(d) to allow for private includes.
CFLAGS_$(d) := $(LIBMAPLE_INCLUDES) $(WIRISH_INCLUDES) -I$(d)
# Local rules and targets
Remove CS3-style initialization. Remove libcs3-related bits from support/ld. Break them out into libmaple proper and Wirish as appropriate: vector table definition and ISR declarations go into libmaple proper, and startup code goes into Wirish. Vector table symbols are included into common.inc from an STM32 family-specific directory under support/ld/stm32. This is a combination of 5 commits. Individual commit messages follow: libcs3_stm32_src: Don't depend on cs3.h. So we can use the existing toolchain. Move ISR decls/vector table into libmaple proper. This allows us to configure the vector table on a per-family basis. - Move support/ld/libcs3_stm32_src/stm32_isrs.S stm32_vector_table.S to libmaple/stm32f1/isrs_performance.S vector_table_performance.S, respectively. The directory libmaple/stm32f1/ is intended to hold all STM32F1-specific code within libmaple. Obviously, there's a lot of work to do before this becomes true. - support/ld/libcs3_stm32_src/Makefile: Don't try to compile stm32_isrs.S and stm32_vector_table.S anymore. - Add libmaple/stm32f1/rules.mk to include these new files in the standard libmaple build. - support/make/target-config.mk: Add LIBMAPLE_MODULE_FAMILY, which selects a directory to use as a family-specific libmaple submodule. - Makefile: Add LIBMAPLE_MODULE_FAMILY to LIBMAPLE_MODULES. Remove support/ld/libcs3_stm32_src and derived object files. From support/ld/libcs3_stm32_src, move start.S and start_c.c into Wirish. Modify wirish/rules.mk accordingly. Delete support/ld/libcs3_stm32_*_density.a. These are no longer necessary, as the relevant objects are included in the standard Wirish build. Remove the GROUP statements from the board linker scripts accordingly. Remove SEARCH_DIR(.) from common.inc; it's no longer necessary. Also fix up some comments that are now out of date. wirish/start_c.c: Don't use CS3-style memory initialization. Switch memory initialization to a simpler style of initializing .data if necessary, then zeroing .bss. Initializing .data is only necessary during Flash builds, since during RAM builds, LOADADDR(.data) == ADDR(.data). This makes libmaple completely incompatible with the CS3 startup sequence. Subsequent commits will clean up the namespace to reflect that fact. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-11-15 09:10:04 +01:00
sSRCS_$(d) := start.S
cSRCS_$(d) := start_c.c
cSRCS_$(d) += syscalls.c
cSRCS_$(d) += $(MCU_SERIES)/util_hooks.c
cppSRCS_$(d) := boards.cpp
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
cppSRCS_$(d) += HardwareSerial.cpp
cppSRCS_$(d) += HardwareTimer.cpp
cppSRCS_$(d) += Print.cpp
cppSRCS_$(d) += pwm.cpp
ifeq ($(MCU_SERIES), stm32f1)
cppSRCS_$(d) += usb_serial.cpp # HACK: this is currently STM32F1 only.
cppSRCS_$(d) += HardwareSPI.cpp # FIXME: port to F2 and fix wirish.h
endif
cppSRCS_$(d) += wirish_analog.cpp
cppSRCS_$(d) += wirish_digital.cpp
cppSRCS_$(d) += wirish_math.cpp
cppSRCS_$(d) += wirish_shift.cpp
cppSRCS_$(d) += wirish_time.cpp
cppSRCS_$(d) += $(MCU_SERIES)/boards_setup.cpp
cppSRCS_$(d) += $(MCU_SERIES)/wirish_digital.cpp
cppSRCS_$(d) += $(MCU_SERIES)/wirish_debug.cpp
cppSRCS_$(d) += $(WIRISH_BOARD_PATH)/board.cpp
Remove CS3-style initialization. Remove libcs3-related bits from support/ld. Break them out into libmaple proper and Wirish as appropriate: vector table definition and ISR declarations go into libmaple proper, and startup code goes into Wirish. Vector table symbols are included into common.inc from an STM32 family-specific directory under support/ld/stm32. This is a combination of 5 commits. Individual commit messages follow: libcs3_stm32_src: Don't depend on cs3.h. So we can use the existing toolchain. Move ISR decls/vector table into libmaple proper. This allows us to configure the vector table on a per-family basis. - Move support/ld/libcs3_stm32_src/stm32_isrs.S stm32_vector_table.S to libmaple/stm32f1/isrs_performance.S vector_table_performance.S, respectively. The directory libmaple/stm32f1/ is intended to hold all STM32F1-specific code within libmaple. Obviously, there's a lot of work to do before this becomes true. - support/ld/libcs3_stm32_src/Makefile: Don't try to compile stm32_isrs.S and stm32_vector_table.S anymore. - Add libmaple/stm32f1/rules.mk to include these new files in the standard libmaple build. - support/make/target-config.mk: Add LIBMAPLE_MODULE_FAMILY, which selects a directory to use as a family-specific libmaple submodule. - Makefile: Add LIBMAPLE_MODULE_FAMILY to LIBMAPLE_MODULES. Remove support/ld/libcs3_stm32_src and derived object files. From support/ld/libcs3_stm32_src, move start.S and start_c.c into Wirish. Modify wirish/rules.mk accordingly. Delete support/ld/libcs3_stm32_*_density.a. These are no longer necessary, as the relevant objects are included in the standard Wirish build. Remove the GROUP statements from the board linker scripts accordingly. Remove SEARCH_DIR(.) from common.inc; it's no longer necessary. Also fix up some comments that are now out of date. wirish/start_c.c: Don't use CS3-style memory initialization. Switch memory initialization to a simpler style of initializing .data if necessary, then zeroing .bss. Initializing .data is only necessary during Flash builds, since during RAM builds, LOADADDR(.data) == ADDR(.data). This makes libmaple completely incompatible with the CS3 startup sequence. Subsequent commits will clean up the namespace to reflect that fact. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-11-15 09:10:04 +01:00
sFILES_$(d) := $(sSRCS_$(d):%=$(d)/%)
cFILES_$(d) := $(cSRCS_$(d):%=$(d)/%)
cppFILES_$(d) := $(cppSRCS_$(d):%=$(d)/%)
Remove CS3-style initialization. Remove libcs3-related bits from support/ld. Break them out into libmaple proper and Wirish as appropriate: vector table definition and ISR declarations go into libmaple proper, and startup code goes into Wirish. Vector table symbols are included into common.inc from an STM32 family-specific directory under support/ld/stm32. This is a combination of 5 commits. Individual commit messages follow: libcs3_stm32_src: Don't depend on cs3.h. So we can use the existing toolchain. Move ISR decls/vector table into libmaple proper. This allows us to configure the vector table on a per-family basis. - Move support/ld/libcs3_stm32_src/stm32_isrs.S stm32_vector_table.S to libmaple/stm32f1/isrs_performance.S vector_table_performance.S, respectively. The directory libmaple/stm32f1/ is intended to hold all STM32F1-specific code within libmaple. Obviously, there's a lot of work to do before this becomes true. - support/ld/libcs3_stm32_src/Makefile: Don't try to compile stm32_isrs.S and stm32_vector_table.S anymore. - Add libmaple/stm32f1/rules.mk to include these new files in the standard libmaple build. - support/make/target-config.mk: Add LIBMAPLE_MODULE_FAMILY, which selects a directory to use as a family-specific libmaple submodule. - Makefile: Add LIBMAPLE_MODULE_FAMILY to LIBMAPLE_MODULES. Remove support/ld/libcs3_stm32_src and derived object files. From support/ld/libcs3_stm32_src, move start.S and start_c.c into Wirish. Modify wirish/rules.mk accordingly. Delete support/ld/libcs3_stm32_*_density.a. These are no longer necessary, as the relevant objects are included in the standard Wirish build. Remove the GROUP statements from the board linker scripts accordingly. Remove SEARCH_DIR(.) from common.inc; it's no longer necessary. Also fix up some comments that are now out of date. wirish/start_c.c: Don't use CS3-style memory initialization. Switch memory initialization to a simpler style of initializing .data if necessary, then zeroing .bss. Initializing .data is only necessary during Flash builds, since during RAM builds, LOADADDR(.data) == ADDR(.data). This makes libmaple completely incompatible with the CS3 startup sequence. Subsequent commits will clean up the namespace to reflect that fact. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-11-15 09:10:04 +01:00
OBJS_$(d) := $(sFILES_$(d):%.S=$(BUILD_PATH)/%.o) \
$(cFILES_$(d):%.c=$(BUILD_PATH)/%.o) \
$(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))