#
#  Makefile for powerswitch module
#  Joris van Rantwijk
#
#  Set KERNELDIR to the directory with the Linux kernel sources,
#  if different from /usr/src/linux. Type 'make' to compile the module.
#  Do 'make install' as root to copy the module to /lib/modules.
#

ifndef KERNELDIR
KERNELDIR = /usr/src/linux
endif

CC = gcc
CPPFLAGS = -I$(KERNELDIR)/include
CFLAGS = -Wall -O2

VERSIONFILE = $(KERNELDIR)/include/linux/version.h
VERSION := $(shell awk -F\" '/REL/ {print $$2}' $(VERSIONFILE))
INSTALLDIR = /lib/modules/$(VERSION)/misc

.PHONY : all install clean

all : powerswitch.o

install : powerswitch.o
	install -d $(INSTALLDIR)
	install --mode=644 -p powerswitch.o $(INSTALLDIR)

clean:
	rm -f *.o *~
