# This part is for automake.

# this option you can leave out. Just, if you use "make dist", you need it
noinst_HEADERS = ioctl.c

# if you "make distclean", this files get removed. If you want to remove
# them while "make clean", use CLEANFILES
DISTCLEANFILES = $(kmemstat_METASOURCES)

# This part is just a normal makefile.

# Where can we find the header files
INCLUDEDIR = /usr/include

# How to compile

GCC=gcc
KERNEL_FLAGS= -D__KERNEL__ -DMODULE -D__SMP__\
	 -DLINUX -I/usr/src/linux/include -DMODVERSIONS\
	-include /usr/src/linux/include/linux/modversions.h

CFLAGS = $(KERNEL_FLAGS) -Wall \
		-Wstrict-prototypes \
		-O2 -pipe \
		-I$(INCLUDEDIR)

# Extract version number from headers.
VER = $(shell awk -F\" '/REL/ {print $$2}' $(INCLUDEDIR)/linux/version.h)

MODULE_OBJS = main.o memmap_functions.o memmap_ioctl.o
USERLAND_OBJS = ioctl.c

all:	memmap.o ioctl

ioctl: $(USERLAND_OBJS) memmap.h
	$(GCC) -Wall ioctl.c -o ioctl

$(OBJS): memmap.h

memmap.o: $(MODULE_OBJS) memmap.h
	$(LD) -r $(MODULE_OBJS) -o $@

install:
	install -d /lib/modules/$(VER)/misc /lib/modules/misc
	install -c memmap.o /lib/modules/$(VER)/misc
	install -c memmap.o /lib/modules/misc
clean:
	rm -f *.o *~ core ioctl

