PGM = lcdhex

OBJ=main.o

all: $(PGM).hex

# gas supports macros, no need for Gasp/Masp
# Assemble
%.o: %.asm
	avr-as -o $@ -mmcu=attiny48 --warn -aln $< > $(basename $<).lst

# Link
$(PGM).out: $(OBJ)
	avr-ld -o $(PGM).out -Map $(PGM).map $(OBJ)

# Generate Hex file
$(PGM).hex: $(PGM).out
	avr-objcopy -O ihex $(PGM).out $(PGM).hex

$(PGM).bin: $(PGM).hex
	hex2bin $(PGM).hex

# chip must be erased before loading the program.
# load (program) the software into flash
load: $(PGM).hex
	echo erasing
	uisp -dprog=stk200 -dlpt=/dev/parport0 --erase
	echo programming
	uisp -dprog=stk200 -dlpt=/dev/parport0 --upload if=$(PGM).hex




