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

######################################################################
#
#  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:		m105.o symbols

m105.o:		m105.h scanner.h

symbols:	
	@for sym in `nm -u m105.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 m105.o\'. The following error; \
	  echo can be ignored.; \
	  echo; \
	  exit -1; \
	else \
	  echo Kernel symbol list looks ok.; \
	fi

clean:
	rm -f m105.o *~

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

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

ci:
	ci m105.c m105.h scanner.h

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