# Makefile for a basic kernel module

CC		:= gcc
ARCH		:= $(shell uname -m | sed 's/i.86/i386/')
KSRC		:= /lib/modules/$(shell uname -r)/build
CONFIG_FILE	:= $(KSRC)/include/linux/autoconf.h


ifeq ($(ARCH),x86_64)
   MODCFLAGS	+= -mcmodel=kernel -mno-red-zone
endif

#standard flags for module builds
MODCFLAGS	+= -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
MODCFLAGS	+= -I$(KSRC)/include -I.
MODCFLAGS	+= -DMODVERSIONS -DEXPORT_SYMTAB -include $(KSRC)/include/linux/modversions.h

SMP		:= $(shell $(CC) $(MODCFLAGS) -E -dM $(CONFIG_FILE) | \
   grep CONFIG_SMP | awk '{print $$3}')

ifneq ($(SMP),1)
   SMP		:= 0
endif

ifeq ($(SMP),1)
   MODCFLAGS	+= -D__SMP__
endif

modules: r1000_n.c
	$(CC) $(MODCFLAGS)  -c r1000_n.c -o r1000.o 

clean:
	rm *.o -f




