Makefile 1.85 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
PROJECT=current_control
CHIP=atmega16

ARCH=avr
AVRSOURCE=
AVRAUTO=compiled/$(ARCH)/
AVRARCH=compiled/$(ARCH)/
LIB_TARGET=$(AVRARCH)lib$(TARGET).a

CC=$(ARCH)-gcc
CXX=$(ARCH)-gcc
CCFLAGS=-mmcu=$(CHIP) -O5 -I. -I$(AVRAUTO) 
AS=$(ARCH)-as
ASFLAGS=-mmcu=$(CHIP)
AR=$(ARCH)-ar
LD=$(ARCH)-ld
OBJDUMP=$(ARCH)-objdump
LDFLAGS= -T $(CHIP).link

all: $(AVRARCH)$(PROJECT)

$(LIB_TARGET)(%.o):     $(AVRSOURCE)%.c Makefile
	$(CC) $(CCFLAGS) -c -o $(AVRARCH)$(%) -I$(AVRSOURCE) -I$(AVRAUTO) $(<) 
	$(AR) r $(@) $(AVRARCH)$(%)
	rm $(AVRARCH)$(%)

$(LIB_TARGET)(%.o):     $(AVRSOURCE)%.cc Makefile
	$(CXX) $(CCFLAGS) -c -o $(AVRARCH)$(%) -I$(AVRSOURCE) -I$(AVRAUTO) $(<) 
	$(AR) r $(@) $(AVRARCH)$(%)
	rm $(AVRARCH)$(%)

$(LIB_TARGET)(%.o):     $(AVRSOURCE)%.s Makefile
	$(AS) $(ASFLAGS) -o $(AVRARCH)$(%) $(AVRSOURCE)$(*).s
	$(AR) r $(@) $(AVRARCH)$(%)
	rm $(AVRARCH)$(%)

$(AVRARCH)%.o:           $(AVRSOURCE)%.s Makefile
	$(AS) $(ASFLAGS) -o $@ $(AVRSOURCE)$(*).s

$(AVRARCH)%.o:           $(AVRSOURCE)%.c Makefile
	$(CC) $(CCFLAGS) -c -o $@ -I. -I$(AVRAUTO) $< 


$(AVRARCH)%:           $(AVRARCH)%.o Makefile
	$(CC) $(CCFLAGS) -o $@ $<  -lm

$(AVRARCH)%.sr:	all $(AVRARCH)%
	avr-objcopy -O srec $(AVRARCH)/$(*) $@ 

%.sr:	$(AVRARCH)%.sr
	@/bin/true

%.load:	compiled/avr/%.sr
#	/work/andersb/atmel/uisp/uisp-0.2b/src/uisp \
#	 	-dno-poll -dstk200 --erase --upload if=$(AVRARCH)/$(*).sr
	uisp \
		-dprog=stk200 \
		--erase \
		--upload if=compiled/avr/$*.sr

%.load.stk500:	compiled/avr/%.sr
	uisp \
		-dprog=stk500 \
		--erase \
		--upload if=compiled/avr/$*.sr

%.dump:	all $(AVRARCH)/%
	$(OBJDUMP) -D $(AVRARCH)/$(*)

$(AVRARCH)fuse.sr:	fuse.s
	avr-gcc -o $(AVRARCH)fuse.o -c fuse.s 
	avr-objcopy -O srec $(AVRARCH)fuse.o $(AVRARCH)fuse.sr

fuse.load:	$(AVRARCH)fuse.sr
	uisp \
		-dprog=stk200 \
		--erase \
		--segment=fuse \
		--upload if=compiled/avr/fuse.sr

load.stk500:	$(PROJECT).load.stk500