CC = ../../../bin/sdcc


srcdir = .

#VERBOSE = --verbose

OBJECTS = tinibios.rel memcpyx.rel ds400rom.rel

SOURCES = $(patsubst %.rel,%.c,$(OBJECTS))

CPPFLAGS = -I$(srcdir)/../../include
CFLAGS = -mds400 $(CPPFLAGS) $(VERBOSE) --std-c89

all: $(OBJECTS) libds400.lib

clean:
	rm -f *.lst *.rel *.sym *.cdb *.asm \#* *~ *.rst *.hex 
	rm -f *.ihx temp.lnk *.map *.lib

distclean: clean
	rm -f Makefile Makefile.dep

libds400.lib: $(OBJECTS)
	rm -f $@; \
	for libfile in $(OBJECTS); do \
		echo $$libfile >>$@; \
	done;

%.rel: %.c
	$(CC) -c $(CFLAGS) $<

# Creating dependencies
# ---------------------
depend: Makefile.dep

Makefile.dep: $(SOURCES)
	rm -f Makefile.dep
	for i in $^; do \
	  $(CC) -M $(CPPFLAGS) $$i >$${i}.dep; \
	  cat $${i}.dep >>Makefile.dep; \
	  rm $${i}.dep; \
	done

ifeq "$(findstring $(MAKECMDGOALS),clean distclean)" ""
  -include Makefile.dep
endif
