Makefile
author Tero Marttila <terom@paivola.fi>
Sun, 06 Apr 2014 18:25:55 +0300
changeset 62 2d68a76322cb
parent 58 a445e08b63e0
child 64 f9221fa50c75
permissions -rw-r--r--
hello-dmx: working basic dmx output using DmxSimple's frame-timing inline assembler code
62
2d68a76322cb hello-dmx: working basic dmx output using DmxSimple's frame-timing inline assembler code
Tero Marttila <terom@paivola.fi>
parents: 58
diff changeset
     1
PROG = hello-dmx
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
     2
51
ec6271f0637b make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents: 50
diff changeset
     3
ELF = build/src/$(PROG).elf
50
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
     4
HEX = build/src/$(PROG).hex
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
     5
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
     6
all: $(HEX)
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
     7
48
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
     8
build:
50
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
     9
	mkdir -p build/src
48
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
    10
62
2d68a76322cb hello-dmx: working basic dmx output using DmxSimple's frame-timing inline assembler code
Tero Marttila <terom@paivola.fi>
parents: 58
diff changeset
    11
dmx: dmx.hex
2d68a76322cb hello-dmx: working basic dmx output using DmxSimple's frame-timing inline assembler code
Tero Marttila <terom@paivola.fi>
parents: 58
diff changeset
    12
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    13
## Compiler
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    14
MCU = atmega328p
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    15
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    16
# CPU clock frequency
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    17
CPU = 16000000
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    18
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    19
CC = avr-gcc
48
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
    20
CPPFLAGS = -DF_CPU=$(CPU)UL
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
    21
CFLAGS = -g -mmcu=$(MCU) -Os
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    22
50
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
    23
build/%.elf: %.c
48
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
    24
	$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
    25
	$(CC) -MM $(CPPFLAGS) -MT $@ -MF build/$*.d $*.c
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
    26
50dc2f4d90fd Makefile: .d build deps
Tero Marttila <terom@paivola.fi>
parents: 47
diff changeset
    27
# existing .d files for rebuilding existing .o's
51
ec6271f0637b make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents: 50
diff changeset
    28
-include $(wildcard build/*/*.d)
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    29
50
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
    30
build/%.hex: build/%.elf
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    31
	avr-objcopy -O ihex -R .eeprom $< $@
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    32
50
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
    33
.PRECIOUS: build/%.elf
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    34
51
ec6271f0637b make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents: 50
diff changeset
    35
dump: $(ELF)
ec6271f0637b make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents: 50
diff changeset
    36
	avr-objdump -d $(ELF)
ec6271f0637b make: fix build-deps, and avr-objdump -d build/src/hello.elf
Tero Marttila <terom@paivola.fi>
parents: 50
diff changeset
    37
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    38
## Assembler
5
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    39
AS = avra
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    40
ASFLAGS = 
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    41
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    42
matrix.hex: spi.inc matrix.inc timer.inc delay.inc macros.inc font.inc font.def
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    43
led7seg.hex: spi.inc led7seg.inc adc.inc timer.inc delay.inc macros.inc
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    44
timer.hex: timer.inc macros.inc
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    45
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    46
%.hex: %.s
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    47
	$(AS) $(ASFLAGS) $<
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    48
	mv $<.hex $@
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    49
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    50
# fonts
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    51
font.inc: font.def
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    52
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    53
font.def: font.txt font-compile.py
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    54
	python font-compile.py $< $@ > /dev/null
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    55
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    56
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    57
## Flashing
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    58
# Arduino Duemilanove
5
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    59
AD_PART = m328p
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    60
AD_PROG = arduino
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    61
AD_BAUD = 57600
43
a0a003083d4c use /dev/arduino for avrdude
Tero Marttila <terom@fixme.fi>
parents: 39
diff changeset
    62
AD_PORT = /dev/arduino
5
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    63
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    64
AD = avrdude
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    65
ADFLAGS = -p $(AD_PART) -c $(AD_PROG) -b $(AD_BAUD) -P $(AD_PORT)
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    66
50
e4ac5a591dcd src/ layout
Tero Marttila <terom@paivola.fi>
parents: 48
diff changeset
    67
upload: $(HEX)
17
a7c668003a19 split led7seg.s into .inc modules, and update Makefile to use .s -> .hex, and above .inc's for led7seg
Tero Marttila <terom@fixme.fi>
parents: 10
diff changeset
    68
	$(AD) $(ADFLAGS) -U flash:w:$<
5
7feeaeb473b5 Makefile
Tero Marttila <terom@fixme.fi>
parents:
diff changeset
    69
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    70
## Console
10
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    71
SERIAL_BAUD = 9600
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    72
SERIAL_FLOW = n
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    73
SERIAL_PARITY = n
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    74
SERIAL_BITS = 8
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    75
SERIAL_PORT = $(AD_PORT)
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    76
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    77
SERIAL_TERM = picocom
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    78
SERIAL_FLAGS = -b $(SERIAL_BAUD) -f $(SERIAL_FLOW) -p $(SERIAL_PARITY) -d $(SERIAL_BITS)
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    79
47
7f930a94ee1e bravely step into the modern world of C-programming, using avr-gcc for a hello world...
Tero Marttila <terom@paivola.fi>
parents: 45
diff changeset
    80
console:
10
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    81
	$(SERIAL_TERM) $(SERIAL_FLAGS) $(SERIAL_PORT)
faca61cf204c add a 'make chat' util
Tero Marttila <terom@fixme.fi>
parents: 9
diff changeset
    82