CFLAGS = -m486 -O2 -Wall -pedantic
LDFLAGS = -s -N
CC=gcc -O2
BINDIR=/sbin
MODCFLAGS = -m486 -O2 -Wall  -DMODULE -D__KERNEL__ -DLINUX

# If character device 42 is in use, change the definition below:
HW_MAJOR=42

MAJOR=0
MINOR=1
PATCH=0
SHLIB=libcx100.so.$(MAJOR).$(MINOR).$(PATCH)

PROGS =  cx100.o

all: $(PROGS) libcx100.a shared

shared: $(SHLIB)

$(SHLIB): cxlib.o
	rm -f $@
	gcc -shared -o $@ -Wl,-soname -Wl,libcx100.so.$(MAJOR) cxlib.o
	ln -s $@ libcx100.so.$(MAJOR)

cx100.o: cx100.c cx100.h
	$(CC) $(MODCFLAGS) -c cx100.c

cxlib.o: cxlib.c cxlib.h cx100.h
	$(CC) $(CFLAGS) -c cxlib.c

libcx100.a: cxlib.o
	ar -r libcx100.a cxlib.o

/dev/cx100:
	if [ ! -c /dev/cx100 ]; then mknod /dev/cx100 c $(HW_MAJOR) 0;fi

clean:
	rm -f *.o libcx100.a $(PROGS) $(INSMOD_LINKS)

