libmaple/Makefile

190 lines
5.7 KiB
Makefile
Raw Permalink Normal View History

# Try "make help" first
2010-08-31 21:21:09 +02:00
.DEFAULT_GOAL := sketch
##
## Useful paths, constants, etc.
##
2011-04-01 08:33:53 +02:00
ifeq ($(LIB_MAPLE_HOME),)
2010-09-02 23:39:52 +02:00
SRCROOT := .
else
SRCROOT := $(LIB_MAPLE_HOME)
endif
BUILD_PATH = build
LIBMAPLE_PATH := $(SRCROOT)/libmaple
WIRISH_PATH := $(SRCROOT)/wirish
SUPPORT_PATH := $(SRCROOT)/support
LIBRARIES_PATH := $(SRCROOT)/libraries
# Support files for linker
LDDIR := $(SUPPORT_PATH)/ld
# Support files for this Makefile
MAKEDIR := $(SUPPORT_PATH)/make
BOARD_INCLUDE_DIR := $(MAKEDIR)/board-includes
##
## Target-specific configuration. This determines some compiler and
## linker options/flags.
##
# Try "make help" for more information on BOARD and MEMORY_TARGET;
# these default to a Maple Flash build.
BOARD ?= maple
MEMORY_TARGET ?= flash
# $(BOARD)- and $(MEMORY_TARGET)-specific configuration
include $(MAKEDIR)/target-config.mk
##
## Build rules and useful templates
##
include $(MAKEDIR)/build-rules.mk
include $(MAKEDIR)/build-templates.mk
##
## Compilation flags
##
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
# FIXME: the following allows for deprecated include style, e.g.:
# #include "libmaple.h"
# or
# #include "wirish.h"
# It slows compilation noticeably; remove after 1 release.
TARGET_FLAGS += -I$(LIBMAPLE_PATH)/include/libmaple \
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
-I$(WIRISH_PATH)/include/wirish
TARGET_FLAGS += -I$(LIBRARIES_PATH) # for internal lib. includes, e.g. <Wire/WireBase.h>
GLOBAL_CFLAGS := -Os -g3 -gdwarf-2 -nostdlib \
-ffunction-sections -fdata-sections \
-Wl,--gc-sections $(TARGET_FLAGS)
GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall $(TARGET_FLAGS)
GLOBAL_ASFLAGS := -x assembler-with-cpp $(TARGET_FLAGS)
LDFLAGS = $(TARGET_LDFLAGS) $(TOOLCHAIN_LDFLAGS) -mcpu=cortex-m3 -mthumb \
-Xlinker --gc-sections \
Merge branch 'wip-family-support' Merge the long-lived (too long; future changes like these will need to proceed more incrementally) development branch of libmaple, containing experimental STM32F2 and STM32F1 value line support, into master. This required many changes to the structure of the library. The most important structural reorganizations occurred in: - 954f9e5: moves public headers to include directories - 3efa313: uses "series" instead of "family" - c0d60e3: adds board files to the build system, to make it easier to add new boards - 096d86c: adds build logic for targeting different STM32 series (e.g. STM32F1, STM32F2) This last commit in particular (096d86c) is the basis for the repartitioning of libmaple into portable sections, which work on all supported MCUs, and nonportable sections, which are segregated into separate directories and contain all series-specific code. Moving existing STM32F1-only code into libmaple/stm32f1 and wirish/stm32f1, along with adding equivalents under .../stm32f2 directories, was the principal project of this branch. Important API changes occur in several places. Existing code is still expected to work on STM32F1 targets, but there have been many deprecations. A detailed changelog explaining the situation needs to be prepared. F2 and F1 value line support is not complete; the merge is proceeding prematurely in this respect. We've been getting more libmaple patches from the community lately, and I'm worried that the merge conflicts with the old tree structure will become painful to manage. Conflicts: Makefile Resolved Makefile conflicts manually; this required propagating -Xlinker usage into support/make/target-config.mk. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-27 00:24:49 +02:00
-Xassembler --march=armv7-m -Wall
# -Xlinker --print-gc-sections \
##
## Set all submodules here
##
LIBMAPLE_MODULES += $(SRCROOT)/libmaple
LIBMAPLE_MODULES += $(SRCROOT)/libmaple/usb # The USB module is kept separate
LIBMAPLE_MODULES += $(LIBMAPLE_MODULE_SERIES) # STM32 series submodule in libmaple
LIBMAPLE_MODULES += $(SRCROOT)/wirish
Merge branch 'wip-family-support' Merge the long-lived (too long; future changes like these will need to proceed more incrementally) development branch of libmaple, containing experimental STM32F2 and STM32F1 value line support, into master. This required many changes to the structure of the library. The most important structural reorganizations occurred in: - 954f9e5: moves public headers to include directories - 3efa313: uses "series" instead of "family" - c0d60e3: adds board files to the build system, to make it easier to add new boards - 096d86c: adds build logic for targeting different STM32 series (e.g. STM32F1, STM32F2) This last commit in particular (096d86c) is the basis for the repartitioning of libmaple into portable sections, which work on all supported MCUs, and nonportable sections, which are segregated into separate directories and contain all series-specific code. Moving existing STM32F1-only code into libmaple/stm32f1 and wirish/stm32f1, along with adding equivalents under .../stm32f2 directories, was the principal project of this branch. Important API changes occur in several places. Existing code is still expected to work on STM32F1 targets, but there have been many deprecations. A detailed changelog explaining the situation needs to be prepared. F2 and F1 value line support is not complete; the merge is proceeding prematurely in this respect. We've been getting more libmaple patches from the community lately, and I'm worried that the merge conflicts with the old tree structure will become painful to manage. Conflicts: Makefile Resolved Makefile conflicts manually; this required propagating -Xlinker usage into support/make/target-config.mk. Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-27 00:24:49 +02:00
# Official libraries:
2011-04-01 07:01:22 +02:00
LIBMAPLE_MODULES += $(SRCROOT)/libraries/Servo
LIBMAPLE_MODULES += $(SRCROOT)/libraries/LiquidCrystal
LIBMAPLE_MODULES += $(SRCROOT)/libraries/Wire
# Experimental libraries:
LIBMAPLE_MODULES += $(SRCROOT)/libraries/FreeRTOS
# User modules:
ifneq ($(USER_MODULES),)
LIBMAPLE_MODULES += $(USER_MODULES)
endif
# Call each module's rules.mk:
$(foreach m,$(LIBMAPLE_MODULES),$(eval $(call LIBMAPLE_MODULE_template,$(m))))
##
## Targets
##
# main target
include $(SRCROOT)/build-targets.mk
.PHONY: install sketch clean help cscope tags ctags ram flash jtag doxygen mrproper list-boards
# Target upload commands
# USB ID for DFU upload -- FIXME: do something smarter with this
BOARD_USB_VENDOR_ID := 1EAF
BOARD_USB_PRODUCT_ID := 0003
UPLOAD_ram := $(SUPPORT_PATH)/scripts/reset.py && \
sleep 1 && \
$(DFU) -a0 -d $(BOARD_USB_VENDOR_ID):$(BOARD_USB_PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
UPLOAD_flash := $(SUPPORT_PATH)/scripts/reset.py && \
sleep 1 && \
$(DFU) -a1 -d $(BOARD_USB_VENDOR_ID):$(BOARD_USB_PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
# Conditionally upload to whatever the last build was
install: INSTALL_TARGET = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null)
install: $(BUILD_PATH)/$(BOARD).bin
@echo "Install target:" $(INSTALL_TARGET)
$(UPLOAD_$(INSTALL_TARGET))
# Force a rebuild if the target changed
PREV_BUILD_TYPE = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null)
2010-07-08 07:06:33 +02:00
build-check:
2010-08-26 00:21:51 +02:00
ifneq ($(PREV_BUILD_TYPE), $(MEMORY_TARGET))
2010-07-08 07:06:33 +02:00
$(shell rm -rf $(BUILD_PATH))
endif
sketch: build-check MSG_INFO $(BUILD_PATH)/$(BOARD).bin
clean:
rm -rf build
mrproper: clean
rm -rf doxygen
help:
@echo ""
@echo "Basic usage (BOARD defaults to maple):"
@echo " $$ cp your-main.cpp main.cpp"
@echo " $$ make BOARD=your_board"
@echo " $$ make BOARD=your_board install"
@echo ""
@echo "(Multiple source files? Link with libmaple.a (\`$$ make library')"
@echo "or hack build-targets.mk appropriately.)"
@echo ""
@echo "Important targets:"
@echo " sketch: Compile for BOARD to MEMORY_TARGET (default)."
@echo " install: Compile and upload over USB using Maple bootloader"
@echo ""
@echo "You *must* set BOARD if not compiling for Maple (e.g."
@echo "use BOARD=maple_mini for mini, etc.), and MEMORY_TARGET"
@echo "if not compiling to Flash. Run \`$$ make list-boards' for"
@echo "a list of all boards."
@echo ""
@echo "Valid MEMORY_TARGETs (default=flash):"
@echo " ram: Compile to RAM (doesn't touch Flash)"
@echo " flash: Compile to Flash (for Maple bootloader)"
@echo " jtag: Compile for JTAG/SWD upload (overwrites bootloader)"
@echo ""
@echo "Other targets:"
@echo " clean: Remove all build and object files"
@echo " doxygen: Build Doxygen HTML and XML documentation"
@echo " help: Show this message"
@echo " mrproper: Remove all generated files"
@echo ""
cscope:
rm -rf cscope.*
2011-03-02 06:30:19 +01:00
find . -name '*.[hcS]' -o -name '*.cpp' | xargs cscope -b
tags:
etags `find . -name "*.c" -o -name "*.cpp" -o -name "*.h"`
@echo "Made TAGS file for EMACS code browsing"
2010-06-09 18:27:15 +02:00
ctags:
ctags-exuberant -R .
@echo "Made tags file for VIM code browsing"
ram:
2010-08-26 00:21:51 +02:00
@$(MAKE) MEMORY_TARGET=ram --no-print-directory sketch
flash:
2010-08-26 00:21:51 +02:00
@$(MAKE) MEMORY_TARGET=flash --no-print-directory sketch
jtag:
2010-08-26 00:21:51 +02:00
@$(MAKE) MEMORY_TARGET=jtag --no-print-directory sketch
doxygen:
doxygen $(SUPPORT_PATH)/doxygen/Doxyfile
# This output is kind of ugly, but I don't understand make very well.
list-boards:
@echo " $(addsuffix "\\n",$(basename $(notdir $(wildcard $(BOARD_INCLUDE_DIR)/*.mk))))"