02bbbca5e5fc4646e95b1a9bb495729bc8aa3ebd
[pub/USBasp.git] / firmware / Makefile
1 SERIAL = `echo /dev/tty.USA19QI*`
2 UISP = uisp -dprog=avr910 -dserial=$(SERIAL) -dpart=auto
3 TARGET = atmega8
4 #TARGET = at90s2313
5 # The two lines above are for "uisp" and the AVR910 serial programmer connected
6 # to a Keyspan USB to serial converter to a Mac running Mac OS X.
7 # Choose your favorite programmer and interface.
8
9 COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=$(TARGET) # -DDEBUG_LEVEL=2
10
11 OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o isp.o clock.o main.o
12
13
14 # symbolic targets:
15 all: main.hex
16
17 .c.o:
18 $(COMPILE) -c $< -o $@
19 #-Wa,-ahlms=$<.lst
20
21 .S.o:
22 $(COMPILE) -x assembler-with-cpp -c $< -o $@
23 # "-x assembler-with-cpp" should not be necessary since this is the default
24 # file type for the .S (with capital S) extension. However, upper case
25 # characters are not always preserved on Windows. To ensure WinAVR
26 # compatibility define the file type manually.
27
28 .c.s:
29 $(COMPILE) -S $< -o $@
30
31 clean:
32 rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o main.s usbdrv.s
33
34 # file targets:
35 main.bin: $(OBJECTS)
36 $(COMPILE) -o main.bin $(OBJECTS) -Wl,-Map,main.map
37
38 main.hex: main.bin
39 rm -f main.hex main.eep.hex
40 avr-objcopy -j .text -j .data -O ihex main.bin main.hex
41 # ./checksize main.bin
42 # do the checksize script as our last action to allow successful compilation
43 # on Windows with WinAVR where the Unix commands will fail.
44
45 disasm: main.bin
46 avr-objdump -d main.bin
47
48 cpp:
49 $(COMPILE) -E main.c
50
51 avrdude:
52 avrdude -c butterfly -p $(TARGET) -U flash:w:main.hex
53
54 uisp: all
55 $(UISP) --erase
56 $(UISP) --upload --verify if=main.hex