Commits

Trammell Hudson committed 9b31d0a

More readme updates and TARGET renamed to APP

Comments (0)

Files changed (4)

 # Makefile for Pebble watch projects.
 #
 # The makefile should define:
-# 	SRCS with a list of source files.
-#	TARGET := project to build
+# 	OBJS with a list of source files.
+#	APP := project to build
+#	FONTS := list of fonts to bundle
 #
 # Change PEBBLE_HOME to point to the sdk directory
 # and GCC_PREFIX to point to your arm-none-eabi gcc tree.
 
 # If no version is specified, use a default one
 VERSION ?= 0.1
-
-BUILD_TIME := $(shell date "+%s")
+APP ?= pebble-app
 
 #
 # If no output directory is specified, put things into ../build/
 #
 %.bin: %.elf
 	$(OBJCOPY) -O binary $< $@
-	$(PYTHON) $(PEBBLE_HOME)/waftools/inject_metadata.py \
-		$@
-
-$O/%.o: %.c
-	$(CC) $(CFLAGS) -c -o $@ $<
+	$(PYTHON) $(PEBBLE_HOME)/waftools/inject_metadata.py $@
 
 # 
 # Bundle the binary (with pebble meta data) into an application.
 #
+BUILD_TIME := $(shell date "+%s")
+
 %.pbw: %.bin
 	$(PYTHON) $(PEBBLE_HOME)/tools/mkbundle.py \
 		--watchapp $< \
 		-o $@ \
 		-v \
 
-all: $O/$(TARGET).pbw
-$O/$(TARGET).pbw: $O/app_resources.pbpack
-$O/$(TARGET).elf: $(addprefix $O/,$(OBJS))
+all: $O/$(APP).pbw
+
+$O/$(APP).pbw: $O/app_resources.pbpack
+$O/$(APP).elf: $(addprefix $O/,$(OBJS))
 	$(LD) \
 		$(LDFLAGS) \
 		-o $@ \
 		$^ \
 		$(LDLIBS) \
 
+$O/%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+
 # Generate a fake resource_map.json file
 $O/resource_map.json:
 	echo > $@ \
-		'{"friendlyVersion":"'$VERSION'","versionDefName":"RESOURCES"}'
+		'{"friendlyVersion":"'$(VERSION)'","versionDefName":"RESOURCES"}'
 
 
 #
 2. Set GCC_PREFIX
 
 You can also run make in each subdirectory to generate the PBW
-files for that subdirectory.
+files for that subdirectory.  The PBW file will be written to
+the ../build subdirectory by default, but you can direct the artifacts
+anywhere by setting O=path-to-file on the command line.
 
-To create a new pebble project, copy a sample Makefile and
-the resource_map.json file (this file is vestigal now).
+To start a new pebble project, create a Makefile that defines
+OBJS with the .o files that are used in your source, FONTS with the
+list of font files and sizes, optionally define APP to name the output
+program, and include the top level Makefile.pebble.
 
-Fonts and resources need more work; currently they need three lists.
-FONTS, RESOURCE_LIST and the makefile deps for each font.  I plan to
-fix this with some more makefile magic in the Makefile.pebble.
+As a sample Makefile, this is what builds the Nederlands clock:
+
+	APP := hoelaat
+
+	OBJS += nederlands.o
+
+	FONTS := \
+		fonts/Arial.ttf:28 \
+		fonts/Arial-Black.ttf:30 \
+
+	include ../../Makefile.pebble
+
+Fonts resource names are generated from the TTF input file name
+and size.  All applications use the same resource block name, "RESOURCES".
 
 
 Any questions?  Trammell Hudson <hudson@osresearch.net>

auth/src/Makefile

 #
-# Nederlands watch build
+# Google two-factor authentication
 #
 
-OBJS += sha1.o totp.o
+APP := auth
 
-TARGET := auth
+OBJS += sha1.o
+OBJS += totp.o
 
 include ../../Makefile.pebble

hoelaat/src/Makefile

 
 OBJS += nederlands.o
 
-TARGET := hoelaat
+APP := hoelaat
 
 FONTS := \
 	fonts/Arial.ttf:28 \