mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-23 12:04:19 +00:00
more work on Makefile - actually rebuilds if Makefile or Configuration.h are altered, also much cleaner output
This commit is contained in:
parent
ab01658fd2
commit
9c918a497b
@ -32,19 +32,24 @@
|
|||||||
#
|
#
|
||||||
# $Id$
|
# $Id$
|
||||||
|
|
||||||
TARGET = $(notdir $(CURDIR))
|
|
||||||
INSTALL_DIR = ../../arduino-0022/
|
|
||||||
UPLOAD_RATE = 115200
|
|
||||||
AVRDUDE_PROGRAMMER = arduino
|
|
||||||
# PORT = /dev/arduino_A900G2I3
|
|
||||||
PORT = /dev/arduino
|
|
||||||
MCU = atmega1280
|
|
||||||
#For "old" Arduino Mega
|
#For "old" Arduino Mega
|
||||||
#MCU = atmega1280
|
MCU = atmega1280
|
||||||
|
#For Arduino Mega2560
|
||||||
|
#MCU = atmega2560
|
||||||
#For Sanguinololu
|
#For Sanguinololu
|
||||||
#MCU = atmega644p
|
#MCU = atmega644p
|
||||||
|
|
||||||
|
#Arduino install directory
|
||||||
|
INSTALL_DIR = ../../arduino-0022/
|
||||||
|
|
||||||
F_CPU = 16000000
|
F_CPU = 16000000
|
||||||
|
|
||||||
|
UPLOAD_RATE = 115200
|
||||||
|
AVRDUDE_PROGRAMMER = arduino
|
||||||
|
PORT = /dev/arduino
|
||||||
|
|
||||||
|
TARGET = $(notdir $(CURDIR))
|
||||||
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
# Below here nothing should be changed...
|
# Below here nothing should be changed...
|
||||||
@ -128,11 +133,11 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
|||||||
|
|
||||||
|
|
||||||
# Default target.
|
# Default target.
|
||||||
all: applet_files build sizeafter
|
all: build sizeafter
|
||||||
|
|
||||||
build: elf hex
|
build: elf hex
|
||||||
|
|
||||||
applet_files: $(TARGET).pde
|
applet/$(TARGET).cpp: $(TARGET).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.
|
||||||
@ -140,10 +145,11 @@ applet_files: $(TARGET).pde
|
|||||||
# Then the .cpp file will be compiled. Errors during compile will
|
# Then the .cpp file will be compiled. Errors during compile will
|
||||||
# refer to this new, automatically generated, file.
|
# refer to this new, automatically generated, file.
|
||||||
# Not the original .pde file you actually edit...
|
# Not the original .pde file you actually edit...
|
||||||
test -d applet || mkdir applet
|
@echo " WR applet/$(TARGET).cpp"
|
||||||
echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
@test -d applet || mkdir applet
|
||||||
cat $(TARGET).pde >> applet/$(TARGET).cpp
|
@echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
||||||
cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
@cat $(TARGET).pde >> applet/$(TARGET).cpp
|
||||||
|
@cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
||||||
|
|
||||||
elf: applet/$(TARGET).elf
|
elf: applet/$(TARGET).elf
|
||||||
hex: applet/$(TARGET).hex
|
hex: applet/$(TARGET).hex
|
||||||
@ -165,7 +171,7 @@ sizebefore:
|
|||||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
||||||
|
|
||||||
sizeafter:
|
sizeafter:
|
||||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
|
@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.
|
||||||
@ -185,9 +191,11 @@ extcoff: $(TARGET).elf
|
|||||||
|
|
||||||
|
|
||||||
.SUFFIXES: .elf .hex .eep .lss .sym
|
.SUFFIXES: .elf .hex .eep .lss .sym
|
||||||
|
.PRECIOUS: .o
|
||||||
|
|
||||||
.elf.hex:
|
.elf.hex:
|
||||||
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
@echo " COPY $@"
|
||||||
|
@$(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" \
|
||||||
@ -202,39 +210,29 @@ extcoff: $(TARGET).elf
|
|||||||
$(NM) -n $< > $@
|
$(NM) -n $< > $@
|
||||||
|
|
||||||
# Link: create ELF output file from library.
|
# Link: create ELF output file from library.
|
||||||
applet/$(TARGET).elf: $(TARGET).pde applet/core.a
|
applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
|
||||||
$(CC) $(ALL_CFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
@echo " CXX $@"
|
||||||
|
@$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||||
|
|
||||||
applet/core.a: $(OBJ)
|
applet/core.a: $(OBJ) Configuration.h
|
||||||
@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
@for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
|
||||||
.cpp.o:
|
|
||||||
$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
|
||||||
|
|
||||||
# Compile: create object files from C source files.
|
|
||||||
.c.o:
|
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
|
||||||
.c.s:
|
|
||||||
$(CC) -S $(ALL_CFLAGS) $< -o $@
|
|
||||||
|
|
||||||
|
|
||||||
# Assemble: create object files from assembler source files.
|
|
||||||
.S.o:
|
|
||||||
$(CC) -c $(ALL_ASFLAGS) $< -o $@
|
|
||||||
|
|
||||||
|
%.o: %.c Configuration.h $(MAKEFILE)
|
||||||
|
@echo " CC $@"
|
||||||
|
@$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp Configuration.h $(MAKEFILE)
|
||||||
|
@echo " CXX $@"
|
||||||
|
@$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
clean:
|
clean:
|
||||||
$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
@echo " RM applet/*"
|
||||||
applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
|
@$(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 \
|
||||||
$(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/"
|
||||||
|
@rmdir applet
|
||||||
|
|
||||||
depend:
|
depend:
|
||||||
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
||||||
|
Loading…
Reference in New Issue
Block a user