1 # change KERNELSRC to the location of your kernel build tree only if
2 # autodetection does not work
3 #KERNELSRC=/usr/src/linux
4 #KERNELSRC=/usr/src/kernel-source-2.4.21-acpi-i2c-lmsensors
5 KERNELSRC?
=/lib
/modules
/`uname -r`/build
6 KERNELVERSION
=$(shell awk
-F
\" '/REL/ {print $$2}' $(shell grep
-s
-l REL
$(KERNELSRC
)/include/linux
/version.h
$(KERNELSRC
)/include/linux
/utsrelease.h
))
8 KERNELMAJOR
=$(shell echo
$(KERNELVERSION
)|head
-c3
)
11 # next line is for kernel 2.6, if you integrate the driver in the kernel tree
12 # /usr/src/linux/drivers/acer_acpi - or something similar
13 # don't forget to add the following line to the parent dir's Makefile:
14 # (/usr/src/linux/drivers/Makefile)
16 obj-m
+= wmi-acer.o acer_acpi.o
17 #acer_acpi-objs := wmi-acer.o acer_acpi.o
20 EXTRA_CFLAGS
+=-c
-Wall
-Wstrict-prototypes
-Wno-trigraphs
-O2
-fomit-frame-pointer
-fno-strict-aliasing
-fno-common
-pipe
21 INCLUDE
=-I
$(KERNELSRC
)/include
23 ifneq ($(KERNELMAJOR
), 2.6)
27 TARGET
:= wmi-acer.ko acer_acpi.ko
28 SOURCE
:= wmi-acer.c acer_acpi.c
33 @echo
"No support for 2.4 series kernels"
36 @echo Possible targets
:
37 @echo
-e
all\\t- default target
, builds kernel module
38 @echo
-e
install\\t- copies module binary to
/lib
/modules
/$(KERNELVERSION
)/extra
/
39 @echo
-e
clean\\t- removes
all binaries and temporary files
41 wmi-acer.ko
: $(SOURCE
)
42 $(MAKE
) -C
$(KERNELSRC
) SUBDIRS
=$(PWD
) modules
45 $(CC
) $(INCLUDE
) $(CFLAGS
) -DMODVERSIONS
-DMODULE
-D__KERNEL__
-o
$(TARGET
) $(SOURCE
)
47 acer_acpi.ko
: $(SOURCE
)
48 $(MAKE
) -C
$(KERNELSRC
) SUBDIRS
=$(PWD
) modules
50 acer_acpi.o
: $(SOURCE
)
51 $(CC
) $(INCLUDE
) $(CFLAGS
) -DMODVERSIONS
-DMODULE
-D__KERNEL__
-o
$(TARGET
) $(SOURCE
)
54 rm -f
*~
*.o
*.s
*.ko
*.mod.c .
*.cmd Module.symvers
64 mkdir
-p
${DESTDIR}/lib
/modules
/$(KERNELVERSION
)/extra
65 cp
-v
$(TARGET
) ${DESTDIR}/lib
/modules
/$(KERNELVERSION
)/extra
/
66 depmod
$(KERNELVERSION
) -a