# Makefile for the tipar driver (Texas Instruments' BlackLink cable or 
# home-made serial link cable)
# (w) 6/2001, Romain Lievin <rlievin@mail.com>

PREFIX = /usr
INCLUDEDIR = $(PREFIX)/include
KDIR := /usr/src/linux
KVERS := $(shell uname -r)

TARGETS := Rules.make arch tipar.o

.PHONY: tipar.o

default: $(TARGETS)


Rules.make: $(KDIR)/Rules.make
	cp -pf $(KDIR)/Rules.make .

arch: $(KDIR)/arch
	rm -f arch
	ln -s $(KDIR)/arch .

clean:
	rm -f $(TARGETS)
	rm -f *.o core *~ \#*

tipar.o:
	$(MAKE) -f Makefile.tipar KDIR=$(KDIR)

install:
	$(MAKE) -f Makefile.tipar KDIR=$(KDIR) KVERS=$(KVERS) install_mod

load:
	$(MAKE) -f Makefile.tipar KDIR=$(KDIR) load_module

unload:
	rmmod tipar

dist: clean
	mkdir /tmp/tiparlink-$(VERSION) ; cp -r ../* /tmp/tiparlink-$(VERSION)
	cd /tmp ; tar cvf - tiparlink-$(VERSION) | \
	gzip > tiparlink-$(VERSION).tar.gz

# Old Makefile, for backwards compatibility

insmod: tipar.o
	insmod tipar.o

rmmod:
	rmmod tipar

reins: tipar.o
	rmmod tipar
	insmod tipar.o

read:
	cat /dev/tipar0

write:
	cat seq.txt > /dev/tipar0

rw:
	cat seq.txt > /dev/tipar0
	cat /dev/tipar0

nodes:
	rm -f /dev/tipar?
	rm -f /dev/tiP?
	rm -f /dev/ti
	mknod -m 666 /dev/tipar0 c 61 1
	mknod -m 666 /dev/tipar1 c 61 2
	mknod -m 666 /dev/tipar2 c 61 3
	ln -s /dev/tipar0 /dev/tiP0     # compatibility with the 'tidev' module
	ln -s /dev/tipar1 /dev/tiP1
	ln -s /dev/tipar2 /dev/tiP2
	ln -s /dev/tipar1 /dev/ti