more work on Makefile - actually rebuilds if Makefile or Configuration.h are altered, also much cleaner output

2.0.x
Michael Moon 13 years ago
parent ab01658fd2
commit 9c918a497b

@ -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...
@ -128,11 +133,11 @@ 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
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.
@ -140,10 +145,11 @@ applet_files: $(TARGET).pde
# 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
@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,7 +171,7 @@ 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.
@ -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/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 $@
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)
# 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…
Cancel
Save