3
# Instead of using a Makefile, since most of the firmwares here build in the
4
# same exact way, here's a script to do the same thing
7
echo "Usage: build.sh MCU myprogram"
8
echo "MCU is a number, like '13' for attiny13 or '841' for attiny841"
12
export ATTINY=$1 ; shift
13
export PROGRAM=$1 ; shift
14
export MCU=attiny$ATTINY
16
export OBJCOPY=avr-objcopy
17
export CFLAGS="-Wall -g -Os -mmcu=$MCU -c -std=gnu99 -DATTINY=$ATTINY -I.. -I../.. -I../../.. -fshort-enums"
18
export OFLAGS="-Wall -g -Os -mmcu=$MCU"
20
export OBJCOPYFLAGS='--set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0 --no-change-warnings -O ihex'
21
export OBJS=$PROGRAM.o
24
OTHERFLAGS="$OTHERFLAGS $arg"
30
if [ x"$?" != x0 ]; then exit 1 ; fi
33
run $CC $OTHERFLAGS $CFLAGS -o $PROGRAM.o -c $PROGRAM.c
34
run $CC $OFLAGS $LDFLAGS -o $PROGRAM.elf $PROGRAM.o
35
run $OBJCOPY $OBJCOPYFLAGS $PROGRAM.elf $PROGRAM.hex
36
run avr-size -C --mcu=$MCU $PROGRAM.elf | grep Full