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 for f in
$(KERNELSRC
)/include/linux
/{utsrelease.h
,version.h
}; do \
7 test -f
$$f && awk
-F
\" '/RELEASE/ {print $$2}' $$f && break
; \
10 KERNELMAJOR
=$(shell echo
$(KERNELVERSION
)|head
-c3
)
13 # next line is for kernel 2.6, if you integrate the driver in the kernel tree
14 # /usr/src/linux/drivers/acer_acpi - or something similar
15 # don't forget to add the following line to the parent dir's Makefile:
16 # (/usr/src/linux/drivers/Makefile)
21 CFLAGS
+=-c
-Wall
-Wstrict-prototypes
-Wno-trigraphs
-O2
-fomit-frame-pointer
-fno-strict-aliasing
-fno-common
-pipe
22 INCLUDE
=-I
$(KERNELSRC
)/include
24 ifneq ($(KERNELMAJOR
), 2.6)
28 TARGET
:= acer_acpi.ko
34 @echo
"No support for 2.4 series kernels"
37 @echo Possible targets
:
38 @echo
-e
all\\t- default target
, builds kernel module
39 @echo
-e
install\\t- copies module binary to
/lib
/modules
/$(KERNELVERSION
)/extra
/
40 @echo
-e
clean\\t- removes
all binaries and temporary files
42 acer_acpi.ko
: $(SOURCE
)
43 $(MAKE
) -C
$(KERNELSRC
) SUBDIRS
=$(PWD
) modules
45 acer_acpi.o
: $(SOURCE
)
46 $(CC
) $(INCLUDE
) $(CFLAGS
) -DMODVERSIONS
-DMODULE
-D__KERNEL__
-o
$(TARGET
) $(SOURCE
)
49 rm -f
*~
*.o
*.s
*.ko
*.mod.c .
*.cmd Module.symvers
59 mkdir
-p
${DESTDIR}/lib
/modules
/$(KERNELVERSION
)/extra
60 cp
-v
$(TARGET
) ${DESTDIR}/lib
/modules
/$(KERNELVERSION
)/extra
/