aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPerry Hung <iperry@alum.mit.edu>2010-07-08 22:27:37 -0400
committerPerry Hung <iperry@alum.mit.edu>2010-07-08 22:27:37 -0400
commit3aa755870aa45004edc848475e361db8b639284a (patch)
tree5edea0724a7a30520e1424c53b676708a1145b86
parente20771d28264125586c6cff7cc4a6b4d51e69110 (diff)
downloadlibrambutan-3aa755870aa45004edc848475e361db8b639284a.tar.gz
librambutan-3aa755870aa45004edc848475e361db8b639284a.zip
makefile: fix install target
The makefile 'install' target should upload to whatever the last build target was, regardless of the environment's value of MAPLE_TARGET.
-rw-r--r--Makefile46
-rw-r--r--support/make/build-rules.mk5
2 files changed, 27 insertions, 24 deletions
diff --git a/Makefile b/Makefile
index 64fcd20..b1858c7 100644
--- a/Makefile
+++ b/Makefile
@@ -9,9 +9,8 @@ BUILD_PATH = build
LIBMAPLE_PATH := libmaple
# Useful variables
-GLOBAL_CFLAGS = -Os -g -mcpu=cortex-m3 -mthumb -march=armv7-m -nostdlib \
- -ffunction-sections -fdata-sections -Wl,--gc-sections
-
+GLOBAL_CFLAGS := -Os -g -mcpu=cortex-m3 -mthumb -march=armv7-m -nostdlib \
+ -ffunction-sections -fdata-sections -Wl,--gc-sections
GLOBAL_CXXFLAGS := -fno-rtti -fno-exceptions -Wall
@@ -24,33 +23,22 @@ LDFLAGS = -T$(LDDIR)/$(LDSCRIPT) -L$(LDDIR) \
include support/make/build-rules.mk
include support/make/build-templates.mk
-VENDOR_ID = 1EAF
-PRODUCT_ID = 0003
-
-# Force a rebuild if the maple target changed
-PREV_BUILD_TYPE = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null)
+# Maple USB id
+VENDOR_ID := 1EAF
+PRODUCT_ID := 0003
# Some target specific things
ifeq ($(MAPLE_TARGET), ram)
VECT_BASE_ADDR := VECT_TAB_RAM
LDSCRIPT := ram.ld
- UPLOAD := support/scripts/reset.py && \
- sleep 1 && \
- $(DFU) -a0 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
-
endif
ifeq ($(MAPLE_TARGET), flash)
LDSCRIPT := flash.ld
VECT_BASE_ADDR := VECT_TAB_FLASH
- UPLOAD := support/scripts/reset.py && \
- sleep 1 && \
- $(DFU) -a1 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
endif
ifeq ($(MAPLE_TARGET), jtag)
LDSCRIPT := jtag.ld
VECT_BASE_ADDR := VECT_TAB_BASE
- UPLOAD := \
- openocd -f support/openocd/flash.cfg
endif
# Set all submodules here
@@ -65,9 +53,23 @@ include support/make/build-targets.mk
.PHONY: install sketch clean help debug cscope tags ctags ram flash jtag
-install: sketch
- $(UPLOAD)
+# Target upload commands
+UPLOAD_ram := support/scripts/reset.py && \
+ sleep 1 && \
+ $(DFU) -a0 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
+UPLOAD_flash := support/scripts/reset.py && \
+ sleep 1 && \
+ $(DFU) -a1 -d $(VENDOR_ID):$(PRODUCT_ID) -D $(BUILD_PATH)/$(BOARD).bin -R
+UPLOAD_jtag := $(OPENOCD) -f support/openocd/flash.cfg
+
+# 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 maple target changed
+PREV_BUILD_TYPE = $(shell cat $(BUILD_PATH)/build-type 2>/dev/null)
build-check:
ifneq ($(PREV_BUILD_TYPE), $(MAPLE_TARGET))
$(shell rm -rf $(BUILD_PATH))
@@ -113,10 +115,10 @@ ctags:
@echo "Made tags file for VIM code browsing"
ram:
- $(MAKE) MAPLE_TARGET=ram --no-print-directory
+ @$(MAKE) MAPLE_TARGET=ram --no-print-directory sketch
flash:
- $(MAKE) MAPLE_TARGET=flash --no-print-directory
+ @$(MAKE) MAPLE_TARGET=flash --no-print-directory sketch
jtag:
- $(MAKE) MAPLE_TARGET=jtag --no-print-directory
+ @$(MAKE) MAPLE_TARGET=jtag --no-print-directory sketch
diff --git a/support/make/build-rules.mk b/support/make/build-rules.mk
index 52ede32..274152c 100644
--- a/support/make/build-rules.mk
+++ b/support/make/build-rules.mk
@@ -21,10 +21,11 @@ ifndef V
SILENT_OBJCOPY = @echo ' [OBJCOPY] ' $(@F);
SILENT_DISAS = @echo ' [DISAS] ' $(@:$(BUILD_PATH)/%.bin=%).disas;
SILENT_OBJDUMP = @echo ' [OBJDUMP] ' $(OBJDUMP);
- DFU := dfu-util
- OPENOCD := openocd
endif
+DFU := dfu-util
+OPENOCD := openocd
+
BUILDDIRS :=
TGT_BIN :=