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