##############################
# 80c51 Makefile for use with SDCC
# 02.04.21 polrog
# Released on 3-clause BSD licence
##############################

BINARY  = program
CC      = sdcc
PACKIHX = packihx

CFILES  = $(wildcard *.c)
HFILES  = $(wildcard *.h)
OBJS    = $(CFILES:%.c=%.o)

CFLAGS  =
CFLAGS  += -mmcs51


all: $(BINARY).hex

%.ihx: $(CFILES)
       $(CC) $(CFLAGS) $(CFILES) -o $(*).ihx
%.hex: %.ihx
       $(PACKIHX) $< > $@

write: $(BINARY).hex
       minipro -p AT89C52 -c code -w $<


PHONY: clean

clean:
       rm -rf *.asm *.ihx *.map *.rel *.rst *.sym *.lk *.lst *.mem *.o