summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 46c8062240b48cae7f5b435e349bc92ad8b29efd (plain)
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
CSRCS= lib_ws2812.c blinky.c util.c uart.c stdio.c
SSRCS=
CC=avr-gcc -mmcu=atmega328p 
PROJECT=blinky
HEX=${PROJECT}.hex

AVRDUDE=avrdude

CPPFLAGS=
CPP=${CC} -E

CFLAGS=-O2 -MP -MD -Wall -Werror #-Wno-unused

OBJS=${CSRCS:%.c=%.o} ${SSRCS:%.S=%.o}

default: ${HEX}

clean:

${PROJECT}:${OBJS}
	${CC} -o $@ ${OBJS}

${HEX}: ${PROJECT}
	avr-objcopy -O ihex -R .eeprom $< $@

program: ${HEX}
	${AVRDUDE} -F -V -c usbasp -p ATMEGA328P -P usb -U flash:w:$<
	#${AVRDUDE} -F -V -c avrispmkII -p ATMEGA328P -P usb -U flash:w:$<


protos:
	echo -n > prototypes.h
	cproto -E "${CPP}" ${CPPFLAGS} -DPROTOTYPING ${CSRCS} > prototypes.h.tmp
	mv prototypes.h.tmp prototypes.h

clean:
	/bin/rm -f ${PROJECT} ${HEX} ${OBJS} *~ *.d


-include ${CSRCS:%.c=%.d}