#
# bt848 Linux makefile
#
# Note driver requires "bigphysarea" patch to your kernel
# brad@parker.boston.ma.us
#
# Patch c1
# Luca Iocchi (iocchi@dis.uniroma1.it - iocchi@ai.sri.com)
#

#SMP = 1
#SMP_PROF = 1


TUNER=0
BT848_MAJOR = 82
BT848_DEVICE = /dev/bt848
MET_DEVICE = /dev/meteor0
FG_DEVICE = /dev/fg0

CC = gcc

# Set this if you are using libc 6 or above
LIBC6=LIBC6

# Library for current libgcc.a
LIBGCC=/usr/lib/gcc-lib/i386-redhat-linux/2.7.2.3

DFLAGS = -DTUNER_DEFAULT=$(TUNER) -DCDEV_MAJOR=$(BT848_MAJOR) -DNBKTR=4 -DBIGPHYSAREA

OFLAGS = -O2 -Wall -Wstrict-prototypes
GFLAGS = -pipe -fno-strength-reduce -fomit-frame-pointer #-Wall 
KFLAGS = -DMODULE -D__KERNEL__ -DLINUX -Dlinux -D$(LIBC6)
CFLAGS = $(OFLAGS) $(KFLAGS) $(GFLAGS) $(DFLAGS)


all: bt848.o

INCS = ioctl_meteor.h ioctl_bt848.h brktree_reg.h bt848_common.h bt848_linux.h

OBJS = bt848_common.o bt848_linux.o

bt848_common.o: bt848_common.c $(INCS)
bt848_linux.o: bt848_common.c $(INCS)

bt848.o: $(OBJS)
#	gcc $(CFLAGS) -o bt848.o $(OBJS)
	$(LD) -r -o bt848.o $(OBJS) -L$(LIBGCC) -lgcc
 
install_dev:
	-rm /dev/bt848*
	-mknod $(BT848_DEVICE) c $(BT848_MAJOR) 0
	-chmod go+rw $(BT848_DEVICE)
	-mknod $(BT848_DEVICE)t c $(BT848_MAJOR) 16
	-chmod go+rw $(MET_DEVICE)
	-mknod $(MET_DEVICE) c $(BT848_MAJOR) 0
	-chmod go+rw $(MET_DEVICE)
	-ln -sf $(BT848_DEVICE) $(FG_DEVICE)

install: bt848.o install_dev
	-/sbin/rmmod bt848
	/sbin/insmod -f bt848

dist: 
	tar -cvzf bt848.tgz Makefile README *.o *.h *.c examples/*/*.c \
examples/*/Makefile examples/*/README examples/*/*.h examples/*/*.cc \
examples/Makefile examples/CONTENTS

clean:
	rm -f *.o *~
