From 902d9552c551a14821fbf9a801eb2174fcd04dbb Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Mon, 7 Apr 2014 01:35:45 +0100 Subject: [PATCH] Replace some Makefile commands with variables in py/mkenv.mk --- py/mkenv.mk | 5 +++++ py/mkrules.mk | 12 ++++++------ py/py.mk | 2 +- stm/Makefile | 4 ++-- stmhal/Makefile | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/py/mkenv.mk b/py/mkenv.mk index ed4e22096d..8ae54f06bb 100644 --- a/py/mkenv.mk +++ b/py/mkenv.mk @@ -39,12 +39,17 @@ BUILD ?= build RM = rm ECHO = @echo +CP = cp +MKDIR = mkdir +SED = sed +PYTHON = python AS = $(CROSS_COMPILE)as CC = $(CROSS_COMPILE)gcc LD = $(CROSS_COMPILE)ld OBJCOPY = $(CROSS_COMPILE)objcopy SIZE = $(CROSS_COMPILE)size +STRIP = $(CROSS_COMPILE)strip all: .PHONY: all diff --git a/py/mkrules.mk b/py/mkrules.mk index 2730eff415..452be8cff9 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -35,10 +35,10 @@ $(ECHO) "CC $<" $(Q)$(CC) $(CFLAGS) -c -MD -o $@ $< @# The following fixes the dependency file. @# See http://make.paulandlesley.org/autodep.html for details. -@cp $(@:.o=.d) $(@:.o=.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ +@$(CP) $(@:.o=.d) $(@:.o=.P); \ + $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ -e '/^$$/ d' -e 's/$$/ :/' < $(@:.o=.d) >> $(@:.o=.P); \ - rm -f $(@:.o=.d) + $(RM) -f $(@:.o=.d) endef vpath %.c . $(TOP) @@ -61,7 +61,7 @@ $(BUILD)/%.pp: %.c OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) $(OBJ_DIRS): - mkdir -p $@ + $(MKDIR) -p $@ ifneq ($(PROG),) # Build a standalone executable (unix and unix-cpy do this) @@ -72,9 +72,9 @@ $(PROG): $(OBJ) $(ECHO) "LINK $@" $(Q)$(CC) -o $@ $(OBJ) $(LIB) $(LDFLAGS) ifndef DEBUG - $(Q)strip $(PROG) + $(Q)$(STRIP) $(PROG) endif - $(Q)size $(PROG) + $(Q)$(SIZE) $(PROG) clean: clean-prog clean-prog: diff --git a/py/py.mk b/py/py.mk index 08cfc189ad..0d097ef57c 100644 --- a/py/py.mk +++ b/py/py.mk @@ -105,7 +105,7 @@ $(PY_BUILD)/py-version.h: FORCE $(PY_BUILD)/qstrdefs.generated.h: | $(PY_BUILD)/ $(PY_BUILD)/qstrdefs.generated.h: $(PY_QSTR_DEFS) $(QSTR_DEFS) $(PY_SRC)/makeqstrdata.py $(ECHO) "makeqstrdata $(PY_QSTR_DEFS) $(QSTR_DEFS)" - $(Q)python $(PY_SRC)/makeqstrdata.py $(PY_QSTR_DEFS) $(QSTR_DEFS) > $@ + $(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(PY_QSTR_DEFS) $(QSTR_DEFS) > $@ # We don't know which source files actually need the generated.h (since # it is #included from str.h). The compiler generated dependencies will cause diff --git a/stm/Makefile b/stm/Makefile index 024d6d12eb..25c79a27b2 100644 --- a/stm/Makefile +++ b/stm/Makefile @@ -174,7 +174,7 @@ all: $(BUILD)/flash.dfu $(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin $(ECHO) "Create $@" - $(Q)python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@ + $(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@ $(BUILD)/flash0.bin: $(BUILD)/flash.elf $(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $@ @@ -205,7 +205,7 @@ $(OBJ): | $(BUILD)/pins.h # both pins_$(BOARD).c and pins.h $(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) $(ECHO) "Create $@" - $(Q)python $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC) + $(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC) $(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c $(call compile_c) diff --git a/stmhal/Makefile b/stmhal/Makefile index fff966934a..064db23c35 100644 --- a/stmhal/Makefile +++ b/stmhal/Makefile @@ -189,7 +189,7 @@ all: $(BUILD)/flash.dfu $(BUILD)/flash.dfu: $(BUILD)/flash0.bin $(BUILD)/flash1.bin $(ECHO) "Create $@" - $(Q)python $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@ + $(Q)$(PYTHON) $(DFU) -b 0x08000000:$(BUILD)/flash0.bin -b 0x08020000:$(BUILD)/flash1.bin $@ $(BUILD)/flash0.bin: $(BUILD)/flash.elf $(Q)$(OBJCOPY) -O binary -j .isr_vector $^ $@ @@ -220,7 +220,7 @@ $(OBJ): | $(BUILD)/pins.h # both pins_$(BOARD).c and pins.h $(BUILD)/%_$(BOARD).c $(BUILD)/%.h: boards/$(BOARD)/%.csv $(MAKE_PINS) $(AF_FILE) $(PREFIX_FILE) $(ECHO) "Create $@" - $(Q)python $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC) + $(Q)$(PYTHON) $(MAKE_PINS) --board $(BOARD_PINS) --af $(AF_FILE) --prefix $(PREFIX_FILE) --hdr $(GEN_PINS_HDR) > $(GEN_PINS_SRC) $(BUILD)/pins_$(BOARD).o: $(BUILD)/pins_$(BOARD).c $(call compile_c)