Makefile

Sat, 07 Nov 2015 13:23:07 +0100

author
mbayer
date
Sat, 07 Nov 2015 13:23:07 +0100
changeset 0
2c8ba1964db7
permissions
-rw-r--r--

Initial code from reprappro Marlin repository

0
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
1 # Sprinter Arduino Project Makefile
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
2 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
3 # Makefile Based on:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
4 # Arduino 0011 Makefile
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
5 # Arduino adaptation by mellis, eighthave, oli.keller
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
6 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
7 # This has been tested with Arduino 0022.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
8 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
9 # This makefile allows you to build sketches from the command line
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
10 # without the Arduino environment (or Java).
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
11 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
12 # Detailed instructions for using the makefile:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
13 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
14 # 1. Modify the line containg "INSTALL_DIR" to point to the directory that
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
15 # contains the Arduino installation (for example, under Mac OS X, this
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
16 # might be /Applications/arduino-0012).
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
17 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
18 # 2. Modify the line containing "PORT" to refer to the filename
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
19 # representing the USB or serial connection to your Arduino board
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
20 # (e.g. PORT = /dev/tty.USB0). If the exact name of this file
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
21 # changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
22 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
23 # 3. Set the line containing "MCU" to match your board's processor.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
24 # Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
25 # or Diecimila have the atmega168. If you're using a LilyPad Arduino,
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
26 # change F_CPU to 8000000. If you are using Gen7 electronics, you
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
27 # probably need to use 20000000. Either way, you must regenerate
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
28 # the speed lookup table with create_speed_lookuptable.py.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
29 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
30 # 4. Type "make" and press enter to compile/verify your program.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
31 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
32 # 5. Type "make upload", reset your Arduino board, and press enter to
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
33 # upload your program to the Arduino board.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
34 #
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
35 # $Id$
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
36
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
37 #For "old" Arduino Mega
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
38 #MCU = atmega1280
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
39 #For Arduino Mega2560
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
40 #MCU = atmega2560
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
41 #For Sanguinololu
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
42 #MCU = atmega644p
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
43 MCU = atmega1284p
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
44 #For Printrboard
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
45 #MCU = at90usb1286
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
46
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
47
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
48 #Arduino install directory
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
49 INSTALL_DIR = ../../arduino-0022/
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
50
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
51 # Be sure to regenerate speed_lookuptable.h with create_speed_lookuptable.py
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
52 # if you are setting this to something other than 16MHz
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
53 F_CPU = 16000000
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
54
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
55 UPLOAD_RATE = 115200
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
56 AVRDUDE_PROGRAMMER = arduino
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
57 PORT = /dev/arduino
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
58
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
59 TARGET = $(notdir $(CURDIR))
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
60
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
61
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
62 ############################################################################
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
63 # Below here nothing should be changed...
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
64
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
65 ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
66 AVR_TOOLS_PATH =
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
67 SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
68 $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
69 $(ARDUINO)/wiring_pulse.c \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
70 $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
71 CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
72 $(ARDUINO)/Print.cpp applet/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 MatrixMath.cpp FPUTransform.cpp z_probe.cpp
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
73
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
74 FORMAT = ihex
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
75
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
76
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
77 # Name of this Makefile (used for "make depend").
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
78 MAKEFILE = Makefile
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
79
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
80 # Debugging format.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
81 # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
82 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
83 DEBUG = stabs
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
84
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
85 OPT = s
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
86
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
87 # Place -D or -U options here
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
88 CDEFS = -DF_CPU=$(F_CPU)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
89 CXXDEFS = -DF_CPU=$(F_CPU)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
90
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
91 # Place -I options here
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
92 CINCS = -I$(ARDUINO)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
93 CXXINCS = -I$(ARDUINO)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
94
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
95 # Compiler flag to set the C Standard level.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
96 # c89 - "ANSI" C
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
97 # gnu89 - c89 plus GCC extensions
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
98 # c99 - ISO C99 standard (not yet fully implemented)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
99 # gnu99 - c99 plus GCC extensions
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
100 #CSTANDARD = -std=gnu99
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
101 CDEBUG = -g$(DEBUG)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
102 CWARN = -Wall -Wstrict-prototypes
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
103 CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
104 #CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
105
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
106 CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
107 CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
108 #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
109 LDFLAGS = -lm
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
110
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
111
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
112 # Programming support using avrdude. Settings and variables.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
113 AVRDUDE_PORT = $(PORT)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
114 AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
115 AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
116 -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
117 -b $(UPLOAD_RATE)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
118
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
119 # Program settings
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
120 CC = $(AVR_TOOLS_PATH)avr-gcc
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
121 CXX = $(AVR_TOOLS_PATH)avr-g++
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
122 OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
123 OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
124 AR = $(AVR_TOOLS_PATH)avr-ar
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
125 SIZE = $(AVR_TOOLS_PATH)avr-size
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
126 NM = $(AVR_TOOLS_PATH)avr-nm
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
127 AVRDUDE = avrdude
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
128 REMOVE = rm -f
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
129 MV = mv -f
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
130
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
131 # Define all object files.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
132 OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
133
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
134 # Define all listing files.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
135 LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
136
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
137 # Combine all necessary flags and optional flags.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
138 # Add target processor to flags.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
139 ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
140 ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
141 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
142
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
143
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
144 # Default target.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
145 all: build sizeafter
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
146
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
147 build: elf hex
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
148
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
149 applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
150
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
151 applet/%.cpp: %.pde
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
152 # Here is the "preprocessing".
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
153 # It creates a .cpp file based with the same name as the .pde file.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
154 # On top of the new .cpp file comes the WProgram.h header.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
155 # At the end there is a generic main() function attached.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
156 # Then the .cpp file will be compiled. Errors during compile will
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
157 # refer to this new, automatically generated, file.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
158 # Not the original .pde file you actually edit...
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
159 @echo " WR $@"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
160 @test -d $(dir $@) || mkdir $(dir $@)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
161 @echo '#include "WProgram.h"' > $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
162 @cat $< >> $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
163 @cat $(ARDUINO)/main.cpp >> $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
164
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
165 elf: applet/$(TARGET).elf
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
166 hex: applet/$(TARGET).hex
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
167 eep: applet/$(TARGET).eep
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
168 lss: applet/$(TARGET).lss
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
169 sym: applet/$(TARGET).sym
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
170
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
171 # Program the device.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
172 upload: applet/$(TARGET).hex
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
173 stty hup < $(PORT); true
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
174 $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
175 stty -hup < $(PORT); true
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
176
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
177
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
178 # Display size of file.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
179 HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
180 ELFSIZE = $(SIZE) applet/$(TARGET).elf
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
181 sizebefore:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
182 @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
183
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
184 sizeafter:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
185 @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
186
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
187
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
188 # Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
189 COFFCONVERT=$(OBJCOPY) --debugging \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
190 --change-section-address .data-0x800000 \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
191 --change-section-address .bss-0x800000 \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
192 --change-section-address .noinit-0x800000 \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
193 --change-section-address .eeprom-0x810000
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
194
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
195
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
196 coff: applet/$(TARGET).elf
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
197 $(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
198
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
199
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
200 extcoff: $(TARGET).elf
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
201 $(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
202
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
203
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
204 .SUFFIXES: .elf .hex .eep .lss .sym
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
205 .PRECIOUS: .o
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
206
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
207 .elf.hex:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
208 @echo " COPY $@"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
209 @$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
210
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
211 .elf.eep:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
212 -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
213 --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
214
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
215 # Create extended listing file from ELF output file.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
216 .elf.lss:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
217 $(OBJDUMP) -h -S $< > $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
218
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
219 # Create a symbol table from ELF output file.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
220 .elf.sym:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
221 $(NM) -n $< > $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
222
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
223 # Link: create ELF output file from library.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
224 applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
225 @echo " CXX $@"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
226 @$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
227
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
228 applet/core.a: $(OBJ) Configuration.h
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
229 @for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
230
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
231 %.o: %.c Configuration.h $(MAKEFILE)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
232 @echo " CC $@"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
233 @$(CC) -c $(ALL_CFLAGS) $< -o $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
234
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
235 %.o: %.cpp Configuration.h $(MAKEFILE)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
236 @echo " CXX $@"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
237 @$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
238
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
239 # Target: clean project.
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
240 clean:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
241 @echo " RM applet/*"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
242 @$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
243 applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
244 $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
245 @echo " RMDIR applet/"
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
246 @rmdir applet
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
247
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
248 depend:
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
249 if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
250 then \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
251 sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
252 $(MAKEFILE).$$$$ && \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
253 $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
254 fi
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
255 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
256 >> $(MAKEFILE); \
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
257 $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
258
2c8ba1964db7 Initial code from reprappro Marlin repository
mbayer
parents:
diff changeset
259 .PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter

mercurial