#
# Author: Gaspar Sinai <gaspar@yudit.org>
# Version: 2010-04-27
#

SCRIPT=-s 16f877a.lkr

OBJECTS=util.o i2c.o
FORMAT=inhx32
GPSIM=/home/tibi/Applications/bin/gpsim

all:       main.hex tester.hex

main.hex:  top.o $(OBJECTS) 
	gplink $(SCRIPT) -a $(FORMAT) --map -c -o main.hex $< $(OBJECTS)
	unix2dos main.hex

tester.hex:  test.o $(OBJECTS) 
	gplink $(SCRIPT) -a $(FORMAT) --map -c -o tester.hex $< $(OBJECTS)
	unix2dos tester.hex

#
# The module.c is only to test if we can link c program.
#
c:
	sdcc -mpic14 -p12f683 -c module.c

%.o: %.asm
	gpasm -c $<

#
# break 400
# break 500
# run
test:   tester.hex
	$(GPSIM) tester.cod
    

clean:
	rm -f *.o *.lst *.map *.hex *.cod *.cof

