CFLAGS		= -O2 -fomit-frame-pointer -Wall -Wstrict-prototypes -D__KERNEL__ \
		  -DKERNEL_VERSION=\"$(shell uname -r)\"  #-DDEBUG_GS105

######################################################################
#
#  This is the list of kernel symbols that are `exported' to
#  loadable modules. You may have to change this if you don't keep
#  your kernel sources in the usual place.
#
SYMFILE		= /usr/src/linux/kernel/ksyms.S
#
######################################################################

all:		gs105.o symbols

gs105.o:		gs105.h scanner.h

symbols:	
	@for sym in `nm -u gs105.o`; do \
	  if ! grep $$sym $(SYMFILE) > /dev/null; then \
	    if [ "$$sym" != "_mod_use_count_" ]; then \
	      echo Adding missing symbol $$sym to kernel symbol list; \
	      echo $$sym >> $(SYMFILE); \
	      SYMBOLS_ADDED=true; \
	    fi; \
	  fi; \
	done; \
	if [ "$$SYMBOLS_ADDED" = "true" ]; then \
	  echo; \
	  echo I had to add some symbols to the list of visible kernel symbols,; \
	  echo please re-make your kernel and reboot your machine. After that you; \
	  echo can load the driver by typing \`insmod gs105.o\'. The following error; \
	  echo can be ignored.; \
	  echo; \
	  exit -1; \
	else \
	  echo Kernel symbol list looks ok.; \
	fi

clean:
	rm -f gs105.o *~

load:		unload all
	@su -c "insmod gs105.o"

unload:
	-@su -c "rmmod gs105 > /dev/null"

ci:
	ci gs105.c gs105.h scanner.h

co:
	co -l gs105.c gs105.h scanner.h
