-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ninja
61 lines (45 loc) · 1.35 KB
/
build.ninja
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
# Defaults
mcu = atmega328p
programmer = usbasp
baud = 9600
cpu_clock = 8000000UL
target = build
# Fuse settings
l_fuse = 0xE2
h_fuse = 0xD9
e_fuse = 0xFF
# Directorys
builddir = build
sourcedir = src
headerdir = include
lib_header = /home/jonas/Projekte/librarys/include
lib_source = /home/jonas/Projekte/librarys/src
# Compiler flags
cc = avr-gcc
cpflags = -DF_CPU=$cpu_clock -DBAUD=$baud -mmcu=$mcu -I$headerdir -I$lib_header
cflags = -Os -g -std=gnu99 -Wall -ffunction-sections
avrdude_flags = -c $programmer -p $mcu
ldflags = -Wl,-Map,$builddir/$target.map -Wl,--gc-sections -mmcu=$mcu
rule c
command = $cc $cflags $cpflags -c $in -o $out
description = c $out
rule link
command = $cc $ldflags -o $out $in $libs
description = linking $out
rule hex
command = avr-objcopy -j .text -j .data -O ihex $in $out
description = generating hex $out
rule flash
command = avrdude $avrdude_flags -U flash:w:$in
description = flashing $in
rule size
command = avr-size -C --mcu=$mcu $in
rule fuse
command = avrdude $avrdude_flags -U lfuse:w:$l_fuse:m -U hfuse:w:$h_fuse:m -U efuse:w:$e_fuse:m
build $builddir/main.o: c $sourcedir/main.c
build $builddir/$target.elf: link $builddir/main.o
build $builddir/$target.hex: hex $builddir/$target.elf
build program: flash $builddir/$target.hex
build size: size $builddir/$target.elf
build fuse: fuse
default program