|
@@ -1,76 +1,70 @@
|
|
1
|
+# Sprinter Arduino Project Makefile
|
|
2
|
+#
|
|
3
|
+# Makefile Based on:
|
|
4
|
+# Arduino 0011 Makefile
|
|
5
|
+# Arduino adaptation by mellis, eighthave, oli.keller
|
|
6
|
+#
|
|
7
|
+# This has been tested with Arduino 0022.
|
|
8
|
+#
|
|
9
|
+# This makefile allows you to build sketches from the command line
|
|
10
|
+# without the Arduino environment (or Java).
|
|
11
|
+#
|
|
12
|
+# Detailed instructions for using the makefile:
|
|
13
|
+#
|
|
14
|
+# 1. Modify the line containg "INSTALL_DIR" to point to the directory that
|
|
15
|
+# contains the Arduino installation (for example, under Mac OS X, this
|
|
16
|
+# might be /Applications/arduino-0012).
|
|
17
|
+#
|
|
18
|
+# 2. Modify the line containing "PORT" to refer to the filename
|
|
19
|
+# representing the USB or serial connection to your Arduino board
|
|
20
|
+# (e.g. PORT = /dev/tty.USB0). If the exact name of this file
|
|
21
|
+# changes, you can use * as a wildcard (e.g. PORT = /dev/tty.usb*).
|
|
22
|
+#
|
|
23
|
+# 3. Set the line containing "MCU" to match your board's processor.
|
|
24
|
+# Older one's are atmega8 based, newer ones like Arduino Mini, Bluetooth
|
|
25
|
+# or Diecimila have the atmega168. If you're using a LilyPad Arduino,
|
|
26
|
+# change F_CPU to 8000000.
|
|
27
|
+#
|
|
28
|
+# 4. Type "make" and press enter to compile/verify your program.
|
|
29
|
+#
|
|
30
|
+# 5. Type "make upload", reset your Arduino board, and press enter to
|
|
31
|
+# upload your program to the Arduino board.
|
|
32
|
+#
|
|
33
|
+# $Id$
|
|
34
|
+
|
|
35
|
+#For "old" Arduino Mega
|
|
36
|
+MCU = atmega1280
|
|
37
|
+#For Arduino Mega2560
|
|
38
|
+#MCU = atmega2560
|
|
39
|
+#For Sanguinololu
|
|
40
|
+#MCU = atmega644p
|
|
41
|
+
|
|
42
|
+#Arduino install directory
|
|
43
|
+INSTALL_DIR = ../../arduino-0022/
|
|
44
|
+
|
|
45
|
+F_CPU = 16000000
|
|
46
|
+
|
|
47
|
+UPLOAD_RATE = 115200
|
|
48
|
+AVRDUDE_PROGRAMMER = arduino
|
|
49
|
+PORT = /dev/arduino
|
|
50
|
+
|
1
|
51
|
TARGET = $(notdir $(CURDIR))
|
2
|
|
-# CHANGE BELOW:
|
3
|
|
-#~ INSTALL_DIR = /Applications/Arduino.app/Contents/Resources/Java
|
4
|
|
-INSTALL_DIR = /home/bkubicek/software/arduino-0023
|
5
|
|
-#~ PORT = /dev/cu.usbserial*
|
6
|
|
-PORT = /dev/ttyACM0
|
7
|
|
-
|
8
|
|
-# Get these values from:
|
9
|
|
-# $(INSTALL_DIR)/hardware/boards.txt
|
10
|
|
-# (arduino-0022/hardware/arduino/boards.txt)
|
11
|
|
-# The values below are for the "Arduino Duemilanove or Nano w/ ATmega328"
|
12
|
|
-# now for "Arduino Mega 2560"
|
13
|
|
-UPLOAD_SPEED = 115200
|
14
|
|
-UPLOAD_PROTOCOL = stk500v2
|
15
|
|
-BUILD_MCU = atmega2560
|
16
|
|
-BUILD_F_CPU = 16000000L
|
17
|
|
-TERM=bash
|
18
|
|
-
|
19
|
|
-# getting undefined reference to `__cxa_pure_virtual'
|
20
|
|
-#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
|
21
|
|
-#~ http://www.arduino.cc/playground/OpenBSD/CLI
|
22
|
|
-#~ [http://arduino.cc/forum/index.php?topic=52041.0 A "simple" makefile for Arduino]
|
23
|
|
-#~ [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1275488191 Arduino Forum - Configuring avr-gcc options in arduino IDE]
|
24
|
|
-# found in /usr/lib/gcc/avr/4.3.5/cc1plus; fixed with -Wl,--gc-section
|
|
52
|
+
|
25
|
53
|
|
26
|
54
|
############################################################################
|
27
|
55
|
# Below here nothing should be changed...
|
28
|
56
|
|
29
|
|
-LINKORDER=\
|
30
|
|
-applet/Marlin.cpp.o \
|
31
|
|
-applet/EEPROM.o \
|
32
|
|
-applet/main.o \
|
33
|
|
-applet/MarlinSerial.o \
|
34
|
|
-applet/motion_control.o\
|
35
|
|
-applet/pins_arduino.o\
|
36
|
|
-applet/planner.o\
|
37
|
|
-applet/Print.o\
|
38
|
|
-applet/Sd2Card.o\
|
39
|
|
-applet/SdBaseFile.o\
|
40
|
|
-applet/SdFatUtil.o\
|
41
|
|
-applet/SdFile.o\
|
42
|
|
-applet/SdVolume.o\
|
43
|
|
-applet/stepper.o\
|
44
|
|
-applet/temperature.o\
|
45
|
|
-applet/WInterrupts.o\
|
46
|
|
-applet/wiring_analog.o\
|
47
|
|
-applet/wiring_digital.o\
|
48
|
|
-applet/wiring.o\
|
49
|
|
-applet/wiring_pulse.o\
|
50
|
|
-applet/wiring_shift.o\
|
51
|
|
-applet/WMath.o
|
52
|
|
-
|
53
|
|
-PDES=Marlin.pde ultralcd.pde watchdog.pde cardreader.pde
|
54
|
57
|
ARDUINO = $(INSTALL_DIR)/hardware/arduino/cores/arduino
|
55
|
|
-#
|
56
|
|
-#~ AVR_TOOLS_PATH = $(INSTALL_DIR)/hardware/tools/avr/bin
|
57
|
|
-# in Ubuntu, avr-gcc is installed separate;
|
58
|
|
-# only avrdude comes with the IDE
|
59
|
|
-AVR_TOOLS_PATH = /usr/bin
|
60
|
|
-AVR_DUDE_PATH = $(INSTALL_DIR)/hardware/tools
|
61
|
|
-#
|
62
|
|
-SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
63
|
|
- $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
64
|
|
- $(ARDUINO)/wiring_pulse.c \
|
65
|
|
- $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
66
|
|
-# added applet/$(TARGET).cpp as in IDE 0022
|
67
|
|
-CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp \
|
68
|
|
- $(ARDUINO)/Print.cpp \
|
69
|
|
- $(ARDUINO)/main.cpp
|
70
|
|
-# applet/$(TARGET).cpp # no need, having a rule now for applet/$(TARGET).cpp.o
|
71
|
|
-# added main.cpp, as in 0022
|
|
58
|
+AVR_TOOLS_PATH =
|
|
59
|
+SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \
|
|
60
|
+ $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \
|
|
61
|
+ $(ARDUINO)/wiring_pulse.c \
|
|
62
|
+ $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c
|
|
63
|
+CXXSRC = $(ARDUINO)/WMath.cpp $(ARDUINO)/WString.cpp\
|
|
64
|
+ $(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
|
72
|
65
|
FORMAT = ihex
|
73
|
66
|
|
|
67
|
+
|
74
|
68
|
# Name of this Makefile (used for "make depend").
|
75
|
69
|
MAKEFILE = Makefile
|
76
|
70
|
|
|
@@ -79,192 +73,133 @@ MAKEFILE = Makefile
|
79
|
73
|
# AVR (extended) COFF requires stabs, plus an avr-objcopy run.
|
80
|
74
|
DEBUG = stabs
|
81
|
75
|
|
82
|
|
-OPT = 2
|
|
76
|
+OPT = s
|
83
|
77
|
|
84
|
78
|
# Place -D or -U options here
|
85
|
|
-#~ CDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
|
86
|
|
-#~ CXXDEFS = -DBUILD_F_CPU=$(BUILD_F_CPU)
|
87
|
|
-# now called DF_CPU
|
88
|
|
-CDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=23
|
89
|
|
-CXXDEFS = -DF_CPU=$(BUILD_F_CPU) -DARDUINO=23
|
|
79
|
+CDEFS = -DF_CPU=$(F_CPU)
|
|
80
|
+CXXDEFS = -DF_CPU=$(F_CPU)
|
90
|
81
|
|
91
|
82
|
# Place -I options here
|
92
|
|
-CINCS = -I$(ARDUINO) -I$(INSTALL_DIR)/libraries/LiquidCrystal/ -I$(INSTALL_DIR)/libraries/EEPROM/
|
|
83
|
+CINCS = -I$(ARDUINO)
|
93
|
84
|
CXXINCS = -I$(ARDUINO)
|
94
|
85
|
|
95
|
86
|
# Compiler flag to set the C Standard level.
|
96
|
|
-# c89 - "ANSI" C
|
|
87
|
+# c89 - "ANSI" C
|
97
|
88
|
# gnu89 - c89 plus GCC extensions
|
98
|
|
-# c99 - ISO C99 standard (not yet fully implemented)
|
|
89
|
+# c99 - ISO C99 standard (not yet fully implemented)
|
99
|
90
|
# gnu99 - c99 plus GCC extensions
|
100
|
|
-CSTANDARD = -std=gnu99
|
|
91
|
+#CSTANDARD = -std=gnu99
|
101
|
92
|
CDEBUG = -g$(DEBUG)
|
102
|
|
-# note that typically, IDE 0022 uses -w to suppress warnings (both in cpp and c)!
|
103
|
|
-CWARN = -Wall
|
104
|
|
-#~ CWARN = -w
|
105
|
|
-# "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++:
|
106
|
|
-CCWARN = -Wstrict-prototypes
|
107
|
|
-CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums
|
|
93
|
+CWARN = -Wall -Wstrict-prototypes
|
|
94
|
+CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -w -ffunction-sections -fdata-sections -DARDUINO=22
|
108
|
95
|
#CEXTRA = -Wa,-adhlns=$(<:.c=.lst)
|
109
|
96
|
|
110
|
|
-# to eliminate pins_ardiuno warnings:
|
111
|
|
-# http://arduino.cc/pipermail/developers_arduino.cc/2010-December/004005.html
|
112
|
|
-
|
113
|
|
-# [http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1254180518 Arduino Forum - Makefile]
|
114
|
|
-#~ For building the objects files "-ffunction-sections -fdata-sections" was missing
|
115
|
|
-#~ and the final avr-gcc call needs "-Wl,--gc-section".
|
116
|
|
-CXSECTF = -fno-exceptions -ffunction-sections -fdata-sections
|
117
|
|
-CFINALF = -Wl,--gc-section
|
118
|
|
-
|
119
|
|
-CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CCWARN) $(CSTANDARD) $(CEXTRA)
|
120
|
|
-# added CWARN also to .cpp
|
121
|
|
-CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CXSECTF)
|
122
|
|
-#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
|
97
|
+CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING)
|
|
98
|
+CXXFLAGS = $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING)
|
|
99
|
+#ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
|
123
|
100
|
LDFLAGS = -lm
|
124
|
101
|
|
|
102
|
+
|
125
|
103
|
# Programming support using avrdude. Settings and variables.
|
126
|
104
|
AVRDUDE_PORT = $(PORT)
|
127
|
|
-AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex
|
128
|
|
-AVRDUDE_FLAGS = -V -F \
|
129
|
|
- -p $(BUILD_MCU) -P $(AVRDUDE_PORT) -c $(UPLOAD_PROTOCOL) \
|
130
|
|
- -b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avrdude.conf
|
131
|
|
-# -b $(UPLOAD_SPEED) -C $(INSTALL_DIR)/hardware/tools/avr/etc/avrdude.conf
|
|
105
|
+AVRDUDE_WRITE_FLASH = -U flash:w:applet/$(TARGET).hex:i
|
|
106
|
+AVRDUDE_FLAGS = -D -C $(INSTALL_DIR)/hardware/tools/avrdude.conf \
|
|
107
|
+ -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \
|
|
108
|
+ -b $(UPLOAD_RATE)
|
132
|
109
|
|
133
|
110
|
# Program settings
|
134
|
|
-CC = $(AVR_TOOLS_PATH)/avr-gcc
|
135
|
|
-CXX = $(AVR_TOOLS_PATH)/avr-g++
|
136
|
|
-OBJCOPY = $(AVR_TOOLS_PATH)/avr-objcopy
|
137
|
|
-OBJDUMP = $(AVR_TOOLS_PATH)/avr-objdump
|
138
|
|
-AR = $(AVR_TOOLS_PATH)/avr-ar
|
139
|
|
-SIZE = $(AVR_TOOLS_PATH)/avr-size
|
140
|
|
-NM = $(AVR_TOOLS_PATH)/avr-nm
|
141
|
|
-#~ AVRDUDE = $(AVR_TOOLS_PATH)/avrdude
|
142
|
|
-AVRDUDE = $(AVR_DUDE_PATH)/avrdude
|
|
111
|
+CC = $(AVR_TOOLS_PATH)avr-gcc
|
|
112
|
+CXX = $(AVR_TOOLS_PATH)avr-g++
|
|
113
|
+OBJCOPY = $(AVR_TOOLS_PATH)avr-objcopy
|
|
114
|
+OBJDUMP = $(AVR_TOOLS_PATH)avr-objdump
|
|
115
|
+AR = $(AVR_TOOLS_PATH)avr-ar
|
|
116
|
+SIZE = $(AVR_TOOLS_PATH)avr-size
|
|
117
|
+NM = $(AVR_TOOLS_PATH)avr-nm
|
|
118
|
+AVRDUDE = avrdude
|
143
|
119
|
REMOVE = rm -f
|
144
|
120
|
MV = mv -f
|
145
|
121
|
|
146
|
122
|
# Define all object files.
|
147
|
|
-# NOTE: obj files will be created in respective src directories (libraries or $(INSTALL_DIR));
|
148
|
|
-# make clean deletes them fine
|
149
|
|
-# note that srcs are in libraries or other directories;
|
150
|
|
-# $(CXXSRC:.cpp=.o) will cause obj files to be in same loc as src files
|
151
|
|
-#~ OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
152
|
|
-# to change the output directory for object files;
|
153
|
|
-# must change the obj list here!
|
154
|
|
-# and then, match to corresponding rule somehow?
|
155
|
|
-# or leave this - and parse in rule (auth automatic variable $(@F))?
|
156
|
|
-# "Suffix Replacement"
|
157
|
|
-CXXSRC+=MarlinSerial.cpp SdBaseFile.cpp stepper.cpp motion_control.cpp SdFatUtil.cpp temperature.cpp planner.cpp SdFile.cpp Sd2Card.cpp SdVolume.cpp
|
158
|
|
-OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
159
|
|
-
|
160
|
|
-# added - OBJ list, transformed into applet/
|
161
|
|
-OBJT = $(addprefix applet/,$(notdir $(OBJ)))
|
162
|
|
-ALLSRC = $(SRC) $(CXXSRC) $(ASRC)
|
|
123
|
+OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
|
163
|
124
|
|
164
|
125
|
# Define all listing files.
|
165
|
126
|
LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
|
166
|
127
|
|
167
|
128
|
# Combine all necessary flags and optional flags.
|
168
|
129
|
# Add target processor to flags.
|
169
|
|
-ALL_CFLAGS = -mmcu=$(BUILD_MCU) -I. $(CFLAGS)
|
170
|
|
-ALL_CXXFLAGS = -mmcu=$(BUILD_MCU) -I. $(CXXFLAGS)
|
171
|
|
-ALL_ASFLAGS = -mmcu=$(BUILD_MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
172
|
|
-
|
173
|
|
-# depended libraries of .pde need to be added from
|
174
|
|
-# $(INSTALL_DIR)/libraries (TODO: and/or ~/sketchbook/libraries)
|
175
|
|
-# grep for 'include', test if exists, add...
|
176
|
|
-# note: prefix "a real tab character" http://www.delorie.com/djgpp/doc/ug/larger/makefiles.html
|
177
|
|
-# $$ to escape $ for shell;
|
178
|
|
-# note: must NOT put comments # inside bash execution;
|
179
|
|
-# those would get removed by make; making shell see "EOF in backquote substitution"
|
180
|
|
-# echo $$ix ; \
|
181
|
|
-# 'shell' twice - for each subprocess! Backtick doesn't get expanded?
|
182
|
|
-GREPRES:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
|
183
|
|
- if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
|
184
|
|
- LINCS="$$LINCS -I$(INSTALL_DIR)/libraries/$$ix" ;\
|
185
|
|
- fi; \
|
186
|
|
- done; \
|
187
|
|
- echo $$LINCS)
|
188
|
|
-# append includes:
|
189
|
|
-CINCS += $(GREPRES)
|
190
|
|
-CXXINCS += $(GREPRES)
|
191
|
|
-# append library source .cpp files too (CXXSRC)
|
192
|
|
-GREPRESB:=$(shell for ix in $(shell grep include $(TARGET).pde | sed 's/.*[<"]\(.*\).h[>"].*/\1/'); do \
|
193
|
|
- if [ -d $(INSTALL_DIR)/libraries/$$ix ] ; then \
|
194
|
|
- CPPSRCS="$$CPPSRCS $(INSTALL_DIR)/libraries/$$ix/*.cpp" ;\
|
195
|
|
- fi; \
|
196
|
|
- done; \
|
197
|
|
- echo $$CPPSRCS)
|
198
|
|
-CXXSRC += $(GREPRESB)
|
199
|
|
-# added - only CXX obj from libraries:
|
200
|
|
-CXXLIBOBJ = $(GREPRESB:.cpp=.o)
|
|
130
|
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
|
|
131
|
+ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS)
|
|
132
|
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
|
201
|
133
|
|
202
|
|
-# Default target.
|
203
|
|
-all: applet_files build sizeafter
|
204
|
|
-
|
205
|
|
-build: elf hex
|
206
|
|
-
|
207
|
|
-applet_files: $(TARGET).pde
|
208
|
|
- # Here is the "preprocessing".
|
209
|
|
- # It creates a .cpp file based with the same name as the .pde file.
|
210
|
|
- # On top of the new .cpp file comes the WProgram.h header.
|
211
|
|
- # At the end there is a generic main() function attached.
|
212
|
|
- # Then the .cpp file will be compiled. Errors during compile will
|
213
|
|
- # refer to this new, automatically generated, file.
|
214
|
|
- # Not the original .pde file you actually edit...
|
215
|
|
- test -d applet || mkdir applet
|
216
|
|
- # @ supresses printout of the cmdline itself; so only the out of echo is printed
|
217
|
|
- @echo ALL OBJT: $(OBJT)
|
218
|
|
- @echo ALL CXXLIBOBJ: $(CXXLIBOBJ)
|
219
|
|
-# echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
220
|
|
- @echo "#include \"WProgram.h\"\nvoid setup();\nvoid loop();\n" > applet/$(TARGET).cpp
|
221
|
|
- ##cat $(TARGET).pde >> applet/$(TARGET).cpp
|
222
|
|
- cat ${PDES}>> applet/$(TARGET).cpp
|
223
|
|
- cp *.cpp applet/
|
224
|
|
- # no more need to cat main.cpp (v0022) - now it is compiled in
|
225
|
|
-# cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
226
|
134
|
|
|
135
|
+# Default target.
|
|
136
|
+all: build sizeafter
|
|
137
|
+
|
|
138
|
+build: elf hex
|
|
139
|
+
|
|
140
|
+applet/$(TARGET).cpp: $(TARGET).pde $(MAKEFILE)
|
|
141
|
+# Here is the "preprocessing".
|
|
142
|
+# It creates a .cpp file based with the same name as the .pde file.
|
|
143
|
+# On top of the new .cpp file comes the WProgram.h header.
|
|
144
|
+# At the end there is a generic main() function attached.
|
|
145
|
+# Then the .cpp file will be compiled. Errors during compile will
|
|
146
|
+# refer to this new, automatically generated, file.
|
|
147
|
+# Not the original .pde file you actually edit...
|
|
148
|
+ @echo " WR applet/$(TARGET).cpp"
|
|
149
|
+ @test -d applet || mkdir applet
|
|
150
|
+ @echo '#include "WProgram.h"' > applet/$(TARGET).cpp
|
|
151
|
+ @cat $(TARGET).pde >> applet/$(TARGET).cpp
|
|
152
|
+ @cat $(ARDUINO)/main.cpp >> applet/$(TARGET).cpp
|
227
|
153
|
|
228
|
154
|
elf: applet/$(TARGET).elf
|
229
|
155
|
hex: applet/$(TARGET).hex
|
230
|
156
|
eep: applet/$(TARGET).eep
|
231
|
|
-lss: applet/$(TARGET).lss
|
|
157
|
+lss: applet/$(TARGET).lss
|
232
|
158
|
sym: applet/$(TARGET).sym
|
233
|
159
|
|
234
|
|
-# Program the device.
|
|
160
|
+# Program the device.
|
235
|
161
|
upload: applet/$(TARGET).hex
|
|
162
|
+ stty hup < $(PORT); true
|
236
|
163
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
|
|
164
|
+ stty -hup < $(PORT); true
|
237
|
165
|
|
238
|
|
-# Display size of file.
|
|
166
|
+
|
|
167
|
+ # Display size of file.
|
239
|
168
|
HEXSIZE = $(SIZE) --target=$(FORMAT) applet/$(TARGET).hex
|
240
|
|
-ELFSIZE = $(SIZE) applet/$(TARGET).elf
|
|
169
|
+ELFSIZE = $(SIZE) applet/$(TARGET).elf
|
241
|
170
|
sizebefore:
|
242
|
171
|
@if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
|
243
|
172
|
|
244
|
173
|
sizeafter:
|
245
|
|
- @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
|
|
174
|
+ @if [ -f applet/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
|
|
175
|
+
|
246
|
176
|
|
247
|
177
|
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB.
|
248
|
178
|
COFFCONVERT=$(OBJCOPY) --debugging \
|
249
|
|
- --change-section-address .data-0x800000 \
|
250
|
|
- --change-section-address .bss-0x800000 \
|
251
|
|
- --change-section-address .noinit-0x800000 \
|
252
|
|
- --change-section-address .eeprom-0x810000
|
|
179
|
+ --change-section-address .data-0x800000 \
|
|
180
|
+ --change-section-address .bss-0x800000 \
|
|
181
|
+ --change-section-address .noinit-0x800000 \
|
|
182
|
+ --change-section-address .eeprom-0x810000
|
|
183
|
+
|
253
|
184
|
|
254
|
185
|
coff: applet/$(TARGET).elf
|
255
|
186
|
$(COFFCONVERT) -O coff-avr applet/$(TARGET).elf $(TARGET).cof
|
256
|
187
|
|
|
188
|
+
|
257
|
189
|
extcoff: $(TARGET).elf
|
258
|
190
|
$(COFFCONVERT) -O coff-ext-avr applet/$(TARGET).elf $(TARGET).cof
|
259
|
191
|
|
|
192
|
+
|
260
|
193
|
.SUFFIXES: .elf .hex .eep .lss .sym
|
|
194
|
+.PRECIOUS: .o
|
261
|
195
|
|
262
|
196
|
.elf.hex:
|
263
|
|
- $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
|
197
|
+ @echo " COPY $@"
|
|
198
|
+ @$(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
|
264
|
199
|
|
265
|
200
|
.elf.eep:
|
266
|
|
- -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
267
|
|
- --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
|
201
|
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
|
|
202
|
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
|
268
|
203
|
|
269
|
204
|
# Create extended listing file from ELF output file.
|
270
|
205
|
.elf.lss:
|
|
@@ -274,79 +209,40 @@ extcoff: $(TARGET).elf
|
274
|
209
|
.elf.sym:
|
275
|
210
|
$(NM) -n $< > $@
|
276
|
211
|
|
277
|
|
-# Link: create ELF output file from library.
|
278
|
|
-# NOTE: applet/$(TARGET).cpp.o MUST BE BEFORE applet/core.a
|
279
|
|
-# in the dependency list, so its rule runs first!
|
280
|
|
-applet/$(TARGET).elf: $(TARGET).pde applet/$(TARGET).cpp.o applet/core.a
|
281
|
|
-# $(CC) $(ALL_CFLAGS) -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
282
|
|
-# changed as in IDE v0022: link cpp obj files
|
283
|
|
- @echo $$(tput bold)$$(tput setaf 2) $(CC) $$(tput sgr0) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
|
284
|
|
- echo ${OBJT}
|
285
|
|
- #$(CC) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/$(TARGET).cpp.o -L. applet/core.a $(LDFLAGS)
|
286
|
|
- $(CC) $(ALL_CFLAGS) $(CFINALF) -o $@ ${LINKORDER} $(LDFLAGS)
|
287
|
|
- #@$(CC) $(ALL_CFLAGS) $(CFINALF) -o $@ applet/*.o applet/$(TARGET).cpp.o $(CXXOBJ) -L. applet/core.a $(LDFLAGS)
|
288
|
|
-
|
289
|
|
-# added: cpp.o depends on cpp (and .pde which generates it)
|
290
|
|
-# $< "first item in the dependencies list"; $@ "left side of the :"; $^ "right side of the :"
|
291
|
|
-# http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
|
292
|
|
-applet/$(TARGET).cpp.o: applet/$(TARGET).cpp
|
293
|
|
- @echo $$(tput bold) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $< -o $@
|
294
|
|
- @$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
|
212
|
+ # Link: create ELF output file from library.
|
|
213
|
+applet/$(TARGET).elf: applet/$(TARGET).cpp applet/core.a Configuration.h
|
|
214
|
+ @echo " CXX $@"
|
|
215
|
+ @$(CC) $(ALL_CXXFLAGS) -Wl,--gc-sections -o $@ applet/$(TARGET).cpp -L. applet/core.a $(LDFLAGS)
|
295
|
216
|
|
296
|
|
-#~ applet/core.a: $(OBJ)
|
297
|
|
-#~ @for i in $(OBJ); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
298
|
|
-
|
299
|
|
-applet/core.a: $(OBJT)
|
300
|
|
- @for i in $(OBJT); do echo $(AR) rcs applet/core.a $$i; $(AR) rcs applet/core.a $$i; done
|
301
|
|
-
|
302
|
|
-# iterate through OBJ to find the original location; then build depending on source extension
|
303
|
|
-# TODO: add handling of assembler files
|
304
|
|
-applet/%.o:
|
305
|
|
- @for iob in $(OBJ); do \
|
306
|
|
- if [ "`basename $$iob`" = "`basename $@`" ]; then \
|
307
|
|
- for ios in $(ALLSRC); do \
|
308
|
|
- if [ "$${iob%%.*}" = "$${ios%%.*}" ]; then \
|
309
|
|
- case $${ios##*.} in \
|
310
|
|
- "cpp") \
|
311
|
|
- echo "$$(tput bold)$$(tput setaf 1) $(CXX) $$(tput sgr0) -c $(ALL_CXXFLAGS) $$ios -o $@"; \
|
312
|
|
- $(CXX) -c $(ALL_CXXFLAGS) $$ios -o $@;; \
|
313
|
|
- "c") \
|
314
|
|
- echo "$$(tput bold)$$(tput setaf 1) $(CC) $$(tput sgr0) -c $(ALL_CFLAGS) $$ios -o $@"; \
|
315
|
|
- $(CC) -c $(ALL_CFLAGS) $$ios -o $@;; \
|
316
|
|
- esac; \
|
317
|
|
- fi; \
|
318
|
|
- done; \
|
319
|
|
- fi; \
|
320
|
|
- done;
|
321
|
|
-
|
322
|
|
-#~ # Compile: create object files from C++ source files.
|
323
|
|
-#~ .cpp.o:
|
324
|
|
-#~ $(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
325
|
|
-
|
326
|
|
-#~ # Compile: create object files from C source files.
|
327
|
|
-#~ .c.o:
|
328
|
|
-#~ $(CC) -c $(ALL_CFLAGS) $< -o $@
|
329
|
|
-
|
330
|
|
-#~ # Compile: create assembler files from C source files.
|
331
|
|
-#~ .c.s:
|
332
|
|
-#~ $(CC) -S $(ALL_CFLAGS) $< -o $@
|
333
|
|
-
|
334
|
|
-#~ # Assemble: create object files from assembler source files.
|
335
|
|
-#~ .S.o:
|
336
|
|
-#~ $(CC) -c $(ALL_ASFLAGS) $< -o $@
|
337
|
|
-
|
338
|
|
-#~ # Automatic dependencies
|
339
|
|
-#~ %.d: %.c
|
340
|
|
-#~ $(CC) -M $(ALL_CFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
|
341
|
|
-
|
342
|
|
-#~ %.d: %.cpp
|
343
|
|
-#~ $(CXX) -M $(ALL_CXXFLAGS) $< | sed "s;$(notdir $*).o:;$*.o $*.d:;" > $@
|
|
217
|
+applet/core.a: $(OBJ) Configuration.h
|
|
218
|
+ @for i in $(OBJ); do echo " AR $$i"; $(AR) rcs applet/core.a $$i; done
|
|
219
|
+
|
|
220
|
+%.o: %.c Configuration.h $(MAKEFILE)
|
|
221
|
+ @echo " CC $@"
|
|
222
|
+ @$(CC) -c $(ALL_CFLAGS) $< -o $@
|
|
223
|
+
|
|
224
|
+%.o: %.cpp Configuration.h $(MAKEFILE)
|
|
225
|
+ @echo " CXX $@"
|
|
226
|
+ @$(CXX) -c $(ALL_CXXFLAGS) $< -o $@
|
344
|
227
|
|
345
|
228
|
# Target: clean project.
|
346
|
229
|
clean:
|
347
|
|
- $(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
348
|
|
- applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/core.a \
|
349
|
|
- $(OBJT) applet/$(TARGET).cpp.o \
|
350
|
|
- $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
351
|
|
-
|
352
|
|
-.PHONY: all build elf hex eep lss sym program coff extcoff clean applet_files sizebefore sizeafter
|
|
230
|
+ @echo " RM applet/*"
|
|
231
|
+ @$(REMOVE) applet/$(TARGET).hex applet/$(TARGET).eep applet/$(TARGET).cof applet/$(TARGET).elf \
|
|
232
|
+ applet/$(TARGET).map applet/$(TARGET).sym applet/$(TARGET).lss applet/$(TARGET).cpp applet/core.a \
|
|
233
|
+ $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
|
|
234
|
+ @echo " RMDIR applet/"
|
|
235
|
+ @rmdir applet
|
|
236
|
+
|
|
237
|
+depend:
|
|
238
|
+ if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \
|
|
239
|
+ then \
|
|
240
|
+ sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \
|
|
241
|
+ $(MAKEFILE).$$$$ && \
|
|
242
|
+ $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \
|
|
243
|
+ fi
|
|
244
|
+ echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \
|
|
245
|
+ >> $(MAKEFILE); \
|
|
246
|
+ $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
|
|
247
|
+
|
|
248
|
+.PHONY: all build elf hex eep lss sym program coff extcoff clean depend applet_files sizebefore sizeafter
|