#
# Makefile to compile the driver as a loadable module
#
LBOOT	= /lib/modules/default/misc
BITFI	= util/dtc3x.bit

CC	= egcs
EFLAGS	= -D__KERNEL__ -I/var/src/linux/include -Wall -O2 -fomit-frame-pointer -mpentiumpro -DCPU=686 -DMODULE -DMODVERSIONS -DDTC3 -include /linux/include/linux/modversions.h

modules:	dtc

dtc:	dtc3.o
	(cd /linux/modules; ln -sf ../drivers/dtc3/dtc3.o dtc3.o)

dtc3.o:	dtcmain.o fpga.o uart401.o
	$(LD) -r -x -o dtc3.o dtcmain.o fpga.o uart401.o

dtcmain.o: dtcmain.c  dtc3.h dtc3_int.h link.h uart401.h /linux/include/linux/version.h
	$(CC) $(EFLAGS) $(LOCALS) -o dtcmain.o -c dtcmain.c

uart401.o: uart401.c uart401.h dtc3.h dtc3_int.h
	$(CC) $(EFLAGS) $(LOCALS) -o uart401.o -c uart401.c

fpga.o: fpga.c dtc3.h dtc3_int.h fpgabits.i
	$(CC) $(EFLAGS) $(LOCALS) -o fpga.o -c fpga.c

fpgabits.i:	$(BITFI) ./fmkbit
	./fmkbit $(BITFI)

./fmkbit:	./fmkbit.c
	$(CC) -O2 -o ./fmkbit ./fmkbit.c

#devices:
#	rm -f /dev/linkmem
#	mknod -m 666 /dev/linkmem c 31 16

clean:
	rm -f *.o *.b *.i *~ t? t.? *.orig *.rej
