#
# Makefile - Makefile of the M8C programmer
#
# Written 2006 by Werner Almesberger
# Copyright 2006 Werner Almesberger
#

include ../Common.make


DRIVERS=waspic watsp
FILES=README Makefile \
      m8cprog.h m8cprog.c cy8c2regs.h vectors.h chips.h chips.c \
      tty.h tty.c prog.h prog.c \
      ref/Makefile ref/main.c \
      ref/vectorconv.pl ref/vdecode.pl ref/mapconv.pl \
      ref/an2026a.txt ref/an2026a.map ref/an2026b.txt ref/an2026b.map \
      $(DRIVERS:%=drv/%.c)
OBJS=m8cprog.o chips.o tty.o prog.o $(DRIVERS:%=drv/%.o)

CFLAGS += -I$(shell pwd) \
          -DPROGRAMMERS_DECL="$(DRIVERS:%=extern struct prog_ops %_ops;)" \
          -DPROGRAMMERS_OPS="$(DRIVERS:%=&%_ops,)"


.PHONY:		all dep depend tests filelist clean spotless


all:		m8cprog

m8cprog:	$(OBJS) $(LIBDEP)

# ----- Dependencies ----------------------------------------------------------

$(OBJS):	.depend

dep depend .depend:
		$(CPP) $(CFLAGS) -MM -MG *.c >.depend || \
		  { rm -f .depend; exit 1; }

ifeq (.depend,$(wildcard .depend))
include .depend
endif

# ----- Tests -----------------------------------------------------------------

tests:

# ----- Distribution ----------------------------------------------------------

filelist:
		@echo $(FILES)

# ----- Cleanup ---------------------------------------------------------------

clean:
		$(MAKE) -C ref clean
		rm -f $(OBJS)

spotless:	clean
		$(MAKE) -C ref spotless
		rm -f m8cprog .depend
