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
116
Marlin/Makefile
116
Marlin/Makefile
@ -32,19 +32,24 @@
|
||||
#
|
||||
# $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
|
||||
#MCU = atmega1280
|
||||
MCU = atmega1280
|
||||
#For Arduino Mega2560
|
||||
#MCU = atmega2560
|
||||
#For Sanguinololu
|
||||
#MCU = atmega644p
|
||||
|
||||
#Arduino install directory
|
||||
INSTALL_DIR = ../../arduino-0022/
|
||||
|
||||
F_CPU = 16000000
|
||||
|
||||
UPLOAD_RATE = 115200
|
||||
AVRDUDE_PROGRAMMER = arduino
|
||||
PORT = /dev/arduino
|
||||
|
||||
TARGET = $(notdir $(CURDIR))
|
||||
|
||||
|
||||
############################################################################
|
||||
# Below here nothing should be changed...
|
||||
@ -52,11 +57,11 @@ F_CPU = 16000000
|
||||
ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
|
||||
AVR_TOOLS_PATH =
|
||||
SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
||||
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
||||
$(ARDUINO)/wiring_pulse.c \
|
||||
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
||||
$(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
||||
$(ARDUINO)/wiring_pulse.c \
|
||||
$(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
||||
CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
|
||||
$(ARDUINO)/Print.cpp Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
|
||||
$(ARDUINO)/Print.cpp Marlin.cpp MarlinSerial.cpp Sd2Card.cpp SdBaseFile.cpp SdFatUtil.cpp SdFile.cpp SdVolume.cpp motion_control.cpp planner.cpp stepper.cpp temperature.cpp cardreader.cpp
|
||||
FORMAT = ihex
|
||||
|
||||
|
||||
@ -99,8 +104,8 @@ LDFLAGS = -lm
|
||||
AVRDUDE_PORT = $(PORT)
|
||||
AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
|
||||
AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
|
||||
-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
||||
-b $(UPLOAD_RATE)
|
||||
-p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
||||
-b $(UPLOAD_RATE)
|
||||
|
||||
# Program settings
|
||||
CC = $(AVR_TOOLS_PATH)avr-gcc
|
||||
@ -128,22 +133,23 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
||||
|
||||
|
||||
# Default target.
|
||||
all: applet_files build sizeafter
|
||||
all: build sizeafter
|
||||
|
||||
build: elf hex
|
||||
|
||||
applet_files: $(TARGET).pde
|
||||
# Here is the "preprocessing".
|
||||
# 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.
|
||||
# At the end there is a generic main() function attached.
|
||||
# Then the .cpp file will be compiled. Errors during compile will
|
||||
# refer to this new, automatically generated, file.
|
||||
# Not the original .pde file you actually edit...
|
||||
test -d applet || mkdir applet
|
||||
echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
||||
cat $(TARGET).pde >> applet/$(TARGET).cpp
|
||||
cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
||||
applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
|
||||
# Here is the "preprocessing".
|
||||
# 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.
|
||||
# At the end there is a generic main() function attached.
|
||||
# Then the .cpp file will be compiled. Errors during compile will
|
||||
# refer to this new, automatically generated, file.
|
||||
# Not the original .pde file you actually edit...
|
||||
@echo " WR applet/$(TARGET).cpp"
|
||||
@test -d applet || mkdir applet
|
||||
@echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
||||
@cat $(TARGET).pde >> applet/$(TARGET).cpp
|
||||
@cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
||||
|
||||
elf: applet/$(TARGET).elf
|
||||
hex: applet/$(TARGET).hex
|
||||
@ -165,15 +171,15 @@ sizebefore:
|
||||
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
||||
|
||||
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.
|
||||
COFFCONVERT=$(OBJCOPY) --debugging \
|
||||
--change-section-address .data-0x800000 \
|
||||
--change-section-address .bss-0x800000 \
|
||||
--change-section-address .noinit-0x800000 \
|
||||
--change-section-address .eeprom-0x810000
|
||||
--change-section-address .data-0x800000 \
|
||||
--change-section-address .bss-0x800000 \
|
||||
--change-section-address .noinit-0x800000 \
|
||||
--change-section-address .eeprom-0x810000
|
||||
|
||||
|
||||
coff: applet/$(TARGET).elf
|
||||
@ -185,9 +191,11 @@ extcoff: $(TARGET).elf
|
||||
|
||||
|
||||
.SUFFIXES: .elf .hex .eep .lss .sym
|
||||
.PRECIOUS: .o
|
||||
|
||||
.elf.hex:
|
||||
$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
@echo " COPY $@"
|
||||
@$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
||||
|
||||
.elf.eep:
|
||||
-$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
||||
@ -202,39 +210,29 @@ extcoff: $(TARGET).elf
|
||||
$(NM) -n $< > $@
|
||||
|
||||
# Link: create ELF output file from library.
|
||||
applet/$(TARGET).elf: $(TARGET).pde applet/core.a
|
||||
$(CC) $(ALL_CFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
|
||||
@echo " CXX $@"
|
||||
@$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
||||
|
||||
applet/core.a: $(OBJ)
|
||||
@for i in $(OBJ); do echo $(AR) rcs applet/core.a $$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 $@
|
||||
applet/core.a: $(OBJ) Configuration.h
|
||||
@for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
|
||||
|
||||
%.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.
|
||||
clean:
|
||||
$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
||||
applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
|
||||
@echo " RM applet/*"
|
||||
@$(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)
|
||||
@echo " RMDIR applet/"
|
||||
@rmdir applet
|
||||
|
||||
depend:
|
||||
if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
||||
|
Loading…
Reference in New Issue
Block a user