Commits

Trammell Hudson  committed d3fd87f

Build into $O, default to ../build

  • Participants
  • Parent commits 3d557ab

Comments (0)

Files changed (5)

 *.elf
 *.pbw
 *.o
+.*.o.d
 resource_ids.auto.h
 app_resources.pbpack*
 *.log

File Makefile.pebble

 
 BUILD_TIME := $(shell date "+%s")
 
+#
+# If no output directory is specified, put things into ../build/
+#
+O ?= ../build
+$(eval $(shell mkdir -p $O/src))
+
 ARCH_FLAGS += \
 	-mcpu=cortex-m3 \
 	-mthumb \
 	-fPIE \
 	-I$(PEBBLE_HOME)/include \
 	-I. \
-	-I.. \
+	-I$O \
 	-DNDEBUG \
 	-Wp,-MMD,$(dir $@).$(notdir $@).d \
         -Wp,-MT,$@ \
 	$(ARCH_FLAGS) \
 	-Wl,--warn-common \
 	-fPIE \
-	-Wl,-Map,$(TARGET).map,--emit-relocs \
+	-Wl,-Map,$@.map,--emit-relocs \
 	-T$(PEBBLE_HOME)/pebble_app.ld \
 
 LDLIBS += \
 	-L$(PEBBLE_HOME)/lib \
 	-lpebble \
 
+
+#
+# Convert the elf file to a binary file, with
+# the appended Pebble metadata.
+#
 %.bin: %.elf
 	$(OBJCOPY) -O binary $< $@
 	$(PYTHON) $(PEBBLE_HOME)/waftools/inject_metadata.py \
 		$@
 
+$O/%.o: %.c
+	$(CC) $(CFLAGS) -c -o $@ $<
+
+# 
+# Bundle the binary (with pebble meta data) into an application.
+#
 %.pbw: %.bin
 	$(PYTHON) $(PEBBLE_HOME)/tools/mkbundle.py \
 		--watchapp $< \
 		--watchapp-timestamp $(BUILD_TIME) \
 		--req-fw 1 \
-		--resources app_resources.pbpack \
-		--resource-map resource_map.json \
+		--resources $O/app_resources.pbpack \
+		--resource-map $O/resource_map.json \
 		--resources-timestamp $(BUILD_TIME) \
 		-o $@ \
 		-v \
 
-all: $(TARGET).pbw
-$(TARGET).elf: $(OBJS)
+all: $O/$(TARGET).pbw
+$O/$(TARGET).pbw: $O/app_resources.pbpack
+$O/$(TARGET).elf: $(addprefix $O/,$(OBJS))
 	$(LD) \
 		$(LDFLAGS) \
 		-o $@ \
 		$^ \
 		$(LDLIBS) \
 
-$(TARGET).pbw: app_resources.pbpack
+# Generate a fake resource_map.json file
+$O/resource_map.json:
+	echo > $@ \
+		'{"friendlyVersion":"'$VERSION'","versionDefName":"RESOURCES"}'
+
 
 #
 # Every object requires that the resource_ids.auto.h be up to date
 #
-$(OBJS): resource_ids.auto.h
+$(addprefix $O/,$(OBJS)): $O/src/resource_ids.auto.h
 
 clean:
 	$(RM) \
-		*.{o,a,pbw,pfo,elf,bin,map} \
+		$O/*.{o,a,pbw,pfo,elf,bin,map} \
 		a.out \
 		core \
-		*.pbpack \
-		*.pbpack.* \
-		resource_ids.auto.h \
+		$O/*.pbpack \
+		$O/*.pbpack.* \
+		$O/src/resource_ids.auto.h \
 
 #
 # Generate a font resource from a given ttf.
 #
-%.pfo:
+$O/%.pfo:
 	$(PYTHON) $(PEBBLE_HOME)/tools/font/fontgen.py \
 		pfo \
 		$(subst .,,$(suffix $(basename $@))) \
 #
 # Generate a resource binary from all of the fonts
 #
-app_resources.pbpack: \
-	app_resources.pbpack.manifest \
-	app_resources.pbpack.table \
-	app_resources.pbpack.data \
+$O/app_resources.pbpack: \
+	$O/app_resources.pbpack.manifest \
+	$O/app_resources.pbpack.table \
+	$O/app_resources.pbpack.data \
 
 	cat > $@ $^
 
 
-RESOURCES := $(FONTS) resource_map.json
+RESOURCES := $(addprefix $O/,$(FONTS)) $O/resource_map.json
 
-app_resources.pbpack.data: $(RESOURCES)
+$O/app_resources.pbpack.data: $(RESOURCES)
 	cat > $@ $^
 
-app_resources.pbpack.table: $(RESOURCES)
+$O/app_resources.pbpack.table: $(RESOURCES)
 	$(PYTHON) $(PEBBLE_HOME)/tools/pbpack_meta_data.py \
 		table \
 		$@ \
 		$^ \
 
-%.manifest: %.data
+$O/%.manifest: $O/%.data
 	$(PYTHON) $(PEBBLE_HOME)/tools/pbpack_meta_data.py \
 		manifest \
 		$@ \
 		$< \
 
 # This header file name is forced by <pebble_app.h>
-resource_ids.auto.h: app_resources.pbpack.data $(FONTS)
+$O/src/resource_ids.auto.h: \
+	$O/app_resources.pbpack.data \
+	$(addprefix $O/,$(FONTS)) \
+
 	$(PYTHON) $(PEBBLE_HOME)/tools/generate_resource_code.py \
 		resource_header \
 		$@ \
 		pebble_os.h \
 		$< \
 		$(RESOURCE_LIST) \
-		resource_map.json DUMMY \
+		$O/resource_map.json DUMMY \
 
 # Bring in all of the generated dependency files
--include .*.o.d
+-include $O/.*.o.d

File auth/src/resource_map.json

-{
-	"friendlyVersion": "0.1",
-	"versionDefName": "TWOFACTOR",
-	"media": [
-		{
-			"type":"raw",
-			"defName":"DUMMY",
-			"file":"resource_map.json"
-		}
-	]
-}

File hoelaat/src/Makefile

 	Arial-Black.30.pfo \
 
 RESOURCE_LIST := \
-	Arial.28.pfo FONT_ARIAL_28 \
-	Arial-Black.30.pfo FONT_ARIAL_BLACK_30 \
+	../build/Arial.28.pfo FONT_ARIAL_28 \
+	../build/Arial-Black.30.pfo FONT_ARIAL_BLACK_30 \
 
 include ../../Makefile.pebble
 
-Arial.30.pfo: fonts/Arial.ttf
-Arial.28.pfo: fonts/Arial.ttf
-Arial-Black.30.pfo: fonts/Arial-Black.ttf
+$O/Arial.30.pfo: fonts/Arial.ttf
+$O/Arial.28.pfo: fonts/Arial.ttf
+$O/Arial-Black.30.pfo: fonts/Arial-Black.ttf
 

File hoelaat/src/resource_map.json

-{
-	"friendlyVersion": "0.1",
-	"versionDefName": "RESOURCES"
-}