KERNELINC :=/usr/src/linux/include

CC=gcc
MODCFLAGS = -g `uname -a | awk '{ if ($$5 == "SMP") print "-D__SMP__" }'` -D__KERNEL__ -I$(KERNELINC) -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -fno-strength-reduce -malign-loops=2 -malign-jumps=2 -malign-functions=2 -DCPU=686 -DMODULE -DMODVERSIONS -include $(KERNELINC)/linux/modversions.h
CFLAGS = -g -O2 -I $(KERNELINC)
INSTALLDIR=/lib/modules/`uname -r`/misc/

all: stradis.o parsempeg loadcard testing playtransport playprogram

stradis.o: stradis.c saa7146.h saa7146reg.h saa7121.h
	$(CC) $(MODCFLAGS) -c stradis.c

videodev.o: videodev.h
	$(CC) -DEXPORT_SYMTAB $(MODCFLAGS) -c videodev.c

stradis.s:
	$(CC) -S $(MODCFLAGS) stradis.c

install: stradis.o loadcard parsempeg playtransport
	cp -f stradis.o $(INSTALLDIR)
	dmesg -c 2>/dev/null >/dev/null >/var/log/messages
	if (lsmod | grep ^stradis); then rmmod stradis; fi
	sleep 1
	sync
	sleep 1
	sync
	sleep 1
	modprobe stradis
	./loadcard 0
	dmesg
clean:
	rm -f *.o *.s parsempeg core loadcard testing playtransport playprogram

save: clean
	cd /root ; tar -czvf stradis.tar.gz stradis/*
