pebble / Makefile.pebble

#
# Makefile for Pebble watch projects.
#
# The makefile should define:
# 	SRCS with a list of source files.
#	TARGET := project to build
#
PEBBLE_HOME := $(HOME)/build/pebble/sdk
PYTHON := python

GCC_PREFIX := $(HOME)/arm-cs-tools/bin/arm-none-eabi-

CC := $(GCC_PREFIX)gcc
LD := $(CC)
OBJCOPY := $(GCC_PREFIX)objcopy

# If no version is specified, use a default one
VERSION ?= 0.1

BUILD_TIME := $(shell date "+%s")


CFLAGS += \
	-std=c99 \
	-g \
	-O0 \
	-Wall \
	-Wextra \
	-Wno-error=unused-function \
	-Wno-error=unused-variable \
	-Wno-error=unused-parameter \
	-fPIE \
	-I$(PEBBLE_HOME)/include \
	-I. \
	-I.. \
	-DNDEBUG \

LDFLAGS += \
	-mcpu=cortex-m3	\
	-mthumb	\
	-Wl,--warn-common \
	-fPIE \
	-Wl,-Map,$(PEBBLE_HOME)/pebble-app.map,--emit-relocs \
	-T$(PEBBLE_HOME)/pebble_app.ld \
	-L$(PEBBLE_HOME)/lib \
	-lpebble \

%.bin: %.elf
	$(OBJCOPY) -O binary $< $@

%.pbw: %.bin
	$(PYTHON) $(PEBBLE_HOME)/tools/mkbundle.py \
		--watchapp $< \
		--watchapp-timestamp $(BUILD_TIME) \
		--req-fw 1 \
		--resources resources.pbpack \
		--resource-map resource_map.json \
		--resources-timestamp $(BUILD_TIME) \
		-o $@ \

all: $(TARGET).pbw
$(TARGET).elf: $(OBJS)
	$(LD) -o $@ $^ $(LDFLAGS)
$(TARGET).pbw: $(TARGET).bin resources.pbpack

#
# Every object requires that the resource_ids.auto.h be up to date
#
$(OBJS): resource_ids.auto.h

clean:
	$(RM) \
		*.pbw \
		*.pfo \
		*.elf \
		*.bin \
		*.o \
		*.a \
		a.out \
		core \
		*.pbpack \
		*.pbpack.* \
		resource_ids.auto.h \

#
# Generate a font resource from a given ttf.
#
%.pfo:
	$(PYTHON) $(PEBBLE_HOME)/tools/font/fontgen.py \
		pfo \
		$(subst .,,$(suffix $(basename $@))) \
		$< \
		$@ \

#
# Generate a resource binary from all of the fonts
#
resources.pbpack: \
	resources.pbpack.manifest \
	resources.pbpack.table \
	resources.pbpack.data \

	cat > $@ $^


RESOURCES := $(FONTS) resource_map.json

resources.pbpack.data: $(RESOURCES)
	cat > $@ $^

resources.pbpack.table: $(RESOURCES)
	$(PYTHON) $(PEBBLE_HOME)/tools/pbpack_meta_data.py \
		table \
		$@ \
		$^ \

%.manifest: %.data
	$(PYTHON) $(PEBBLE_HOME)/tools/pbpack_meta_data.py \
		manifest \
		$@ \
		$(words $(RESOURCES)) \
		$(BUILD_TIME) \
		$(VERSION) \
		$< \

# This header file name is forced by <pebble_app.h>
resource_ids.auto.h: resources.pbpack.data $(FONTS)
	$(PYTHON) $(PEBBLE_HOME)/tools/generate_resource_code.py \
		resource_header \
		$@ \
		RESOURCES \
		$(VERSION) \
		$(BUILD_TIME) \
		pebble_os.h \
		$< \
		$(RESOURCE_LIST) \
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.