Makefile: support V=1
Often it can be useful to see the actual commands being run by make. Other projects (eg, the Linux kernel) support this with a "V=1" make parameter. Do the same here. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
This commit is contained in:
		| @@ -170,6 +170,14 @@ ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) | |||||||
| ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS) | ALL_CXXFLAGS = -mmcu=$(MCU) $(CXXFLAGS) | ||||||
| ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) | ALL_ASFLAGS = -mmcu=$(MCU) -x assembler-with-cpp $(ASFLAGS) | ||||||
|  |  | ||||||
|  | # set V=1 (eg, "make V=1") to print the full commands etc. | ||||||
|  | ifneq ($V,1) | ||||||
|  |  Pecho=@echo | ||||||
|  |  P=@ | ||||||
|  | else | ||||||
|  |  Pecho=@: | ||||||
|  |  P= | ||||||
|  | endif | ||||||
|  |  | ||||||
| # Default target. | # Default target. | ||||||
| all: sizeafter | all: sizeafter | ||||||
| @@ -178,7 +186,7 @@ build: applet elf hex | |||||||
|  |  | ||||||
| # Creates the object directory | # Creates the object directory | ||||||
| applet:  | applet:  | ||||||
| 	@mkdir -p applet | 	$P mkdir -p applet | ||||||
|  |  | ||||||
| # the .cpp for Marlin depends on the .pde | # the .cpp for Marlin depends on the .pde | ||||||
| #applet/$(TARGET).cpp: $(TARGET).pde | #applet/$(TARGET).cpp: $(TARGET).pde | ||||||
| @@ -189,10 +197,10 @@ applet/%.cpp: %.pde $(MAKEFILE) | |||||||
| # Here is the "preprocessing". | # Here is the "preprocessing". | ||||||
| # It creates a .cpp file based with the same name as the .pde file. | # It creates a .cpp file based with the same name as the .pde file. | ||||||
| # On top of the new .cpp file comes the WProgram.h header. | # On top of the new .cpp file comes the WProgram.h header. | ||||||
| 	@echo "  WR    $@" | 	$(Pecho) "  WR    $@" | ||||||
| 	@echo '#include "WProgram.h"' > $@ | 	$P echo '#include "WProgram.h"' > $@ | ||||||
| 	@echo '#include "$<"' >>$@ | 	$P echo '#include "$<"' >>$@ | ||||||
| 	@echo '#include "$(ARDUINO)/main.cpp"' >> $@ | 	$P echo '#include "$(ARDUINO)/main.cpp"' >> $@ | ||||||
|  |  | ||||||
| elf: applet/$(TARGET).elf | elf: applet/$(TARGET).elf | ||||||
| hex: applet/$(TARGET).hex | hex: applet/$(TARGET).hex | ||||||
| @@ -215,10 +223,10 @@ endif | |||||||
| HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex | HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex | ||||||
| ELFSIZE = $(SIZE)  applet/$(TARGET).elf | ELFSIZE = $(SIZE)  applet/$(TARGET).elf | ||||||
| sizebefore: | sizebefore: | ||||||
| 	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi | 	$P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi | ||||||
|  |  | ||||||
| sizeafter: build | sizeafter: build | ||||||
| 	@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi | 	$P if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi | ||||||
|  |  | ||||||
|  |  | ||||||
| # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. | # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. | ||||||
| @@ -241,8 +249,8 @@ extcoff: $(TARGET).elf | |||||||
| .PRECIOUS: .o | .PRECIOUS: .o | ||||||
|  |  | ||||||
| .elf.hex: | .elf.hex: | ||||||
| 	@echo "  COPY  $@" | 	$(Pecho) "  COPY  $@" | ||||||
| 	@$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ | 	$P $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ | ||||||
|  |  | ||||||
| .elf.eep: | .elf.eep: | ||||||
| 	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ | 	-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ | ||||||
| @@ -258,29 +266,29 @@ extcoff: $(TARGET).elf | |||||||
|  |  | ||||||
| 	# Link: create ELF output file from library. | 	# Link: create ELF output file from library. | ||||||
| applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h | applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h | ||||||
| 	@echo "  CXX   $@" | 	$(Pecho) "  CXX   $@" | ||||||
| 	@$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS) | 	$P $(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS) | ||||||
|  |  | ||||||
| applet/core.a: $(OBJ) | applet/core.a: $(OBJ) | ||||||
| 	@for i in $(OBJ); do echo "  AR    $$i"; $(AR) rcs applet/core.a $$i; done | 	$P for i in $(OBJ); do echo "  AR    $$i"; $(AR) rcs applet/core.a $$i; done | ||||||
|  |  | ||||||
| applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE) | applet/%.o: %.c Configuration.h Configuration_adv.h $(MAKEFILE) | ||||||
| 	@echo "  CC    $@" | 	$(Pecho) "  CC    $@" | ||||||
| 	@$(CC) -MMD -c $(ALL_CFLAGS) $< -o $@ | 	$P $(CC) -MMD -c $(ALL_CFLAGS) $< -o $@ | ||||||
|  |  | ||||||
| applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE) | applet/%.o: %.cpp Configuration.h Configuration_adv.h $(MAKEFILE) | ||||||
| 	@echo "  CXX   $@" | 	$(Pecho) "  CXX   $@" | ||||||
| 	@$(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@ | 	$P $(CXX) -MMD -c $(ALL_CXXFLAGS) $< -o $@ | ||||||
|  |  | ||||||
|  |  | ||||||
| # Target: clean project. | # Target: clean project. | ||||||
| clean: | clean: | ||||||
| 	@echo "  RM    applet/*" | 	$(Pecho) "  RM    applet/*" | ||||||
| 	@$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \ | 	$P $(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \ | ||||||
| 		applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \ | 		applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \ | ||||||
| 		$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) | 		$(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d) | ||||||
| 	@echo "  RMDIR applet/" | 	$(Pecho) "  RMDIR applet/" | ||||||
| 	@rm -rf applet | 	$P rm -rf applet | ||||||
|  |  | ||||||
|  |  | ||||||
| .PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter | .PHONY:	all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user