Add revised makefile adapted from out of tree it87 driver
This commit is contained in:
parent
5900763c43
commit
275aa66133
118
Makefile
118
Makefile
|
@ -1,22 +1,108 @@
|
|||
# Originally sourced from https://github.com/a1wong/it87/blob/master/Makefile
|
||||
# For building for the current running version of Linux
|
||||
ifndef TARGET
|
||||
TARGET := $(shell uname -r)
|
||||
endif
|
||||
# Or specific version
|
||||
#TARGET := 2.6.33.5
|
||||
|
||||
KDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
obj-m := asus-wmi-sensors.o
|
||||
MY_CFLAGS += -g -DDEBUG
|
||||
ccflags-y += ${MY_CFLAGS}
|
||||
CC += ${MY_CFLAGS}
|
||||
KERNEL_MODULES := /lib/modules/$(TARGET)
|
||||
|
||||
all:
|
||||
make -C $(KDIR) C=2 M=$$PWD modules
|
||||
ifneq ("","$(wildcard /usr/src/linux-headers-$(TARGET)/*)")
|
||||
# Ubuntu
|
||||
KERNEL_BUILD := /usr/src/linux-headers-$(TARGET)
|
||||
else
|
||||
ifneq ("","$(wildcard /usr/src/kernels/$(TARGET)/*)")
|
||||
# Fedora
|
||||
KERNEL_BUILD := /usr/src/kernels/$(TARGET)
|
||||
else
|
||||
KERNEL_BUILD := $(KERNEL_MODULES)/build
|
||||
endif
|
||||
endif
|
||||
|
||||
install:
|
||||
make -C $(KDIR) M=$$PWD modules_install
|
||||
#SYSTEM_MAP := $(KERNEL_BUILD)/System.map
|
||||
ifneq ("","$(wildcard /boot/System.map-$(TARGET))")
|
||||
SYSTEM_MAP := /boot/System.map-$(TARGET)
|
||||
else
|
||||
# Arch
|
||||
SYSTEM_MAP := /proc/kallsyms
|
||||
endif
|
||||
|
||||
DRIVER := asus-wmi-sensors
|
||||
ifneq ("","$(wildcard .git/*)")
|
||||
DRIVER_VERSION := $(shell git describe --long --always)
|
||||
else
|
||||
ifneq ("", "$(wildcard VERSION)")
|
||||
DRIVER_VERSION := $(shell cat VERSION)
|
||||
else
|
||||
DRIVER_VERSION := unknown
|
||||
endif
|
||||
endif
|
||||
|
||||
# DKMS
|
||||
DKMS_ROOT_PATH=/usr/src/$(DRIVER)-$(DRIVER_VERSION)
|
||||
MODPROBE_OUTPUT=$(shell lsmod | grep asus-wmi-sensors)
|
||||
|
||||
# Directory below /lib/modules/$(TARGET)/kernel into which to install
|
||||
# the module:
|
||||
MOD_SUBDIR = drivers/hwmon
|
||||
MODDESTDIR=$(KERNEL_MODULES)/kernel/$(MOD_SUBDIR)
|
||||
|
||||
obj-m := $(patsubst %,%.o,$(DRIVER))
|
||||
obj-ko := $(patsubst %,%.ko,$(DRIVER))
|
||||
|
||||
MAKEFLAGS += --no-print-directory
|
||||
|
||||
ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)")
|
||||
COMPRESS_GZIP := y
|
||||
endif
|
||||
ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)")
|
||||
COMPRESS_XZ := y
|
||||
endif
|
||||
|
||||
.PHONY: all install modules modules_install clean dkms dkms_clean
|
||||
|
||||
all: modules
|
||||
|
||||
# Targets for running make directly in the external module directory:
|
||||
|
||||
ASUS_WMI_SENSORS_CFLAGS=-DASUS_WMI_SENSORS_DRIVER_VERSION='\"$(DRIVER_VERSION)\"'
|
||||
|
||||
modules:
|
||||
@$(MAKE) EXTRA_CFLAGS="$(ASUS_WMI_SENSORS_CFLAGS)" -C $(KERNEL_BUILD) M=$(CURDIR) $@
|
||||
|
||||
clean:
|
||||
make -C $(KDIR) M=$$PWD clean
|
||||
@$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) $@
|
||||
|
||||
test:
|
||||
-rmmod asus_wmi_sensors
|
||||
-insmod asus-wmi-sensors.ko
|
||||
dmesg
|
||||
sensors
|
||||
|
||||
install: modules_install
|
||||
|
||||
modules_install:
|
||||
mkdir -p $(MODDESTDIR)
|
||||
cp $(DRIVER).ko $(MODDESTDIR)/
|
||||
ifeq ($(COMPRESS_GZIP), y)
|
||||
@gzip -f $(MODDESTDIR)/$(DRIVER).ko
|
||||
endif
|
||||
ifeq ($(COMPRESS_XZ), y)
|
||||
@xz -f $(MODDESTDIR)/$(DRIVER).ko
|
||||
endif
|
||||
depmod -a -F $(SYSTEM_MAP) $(TARGET)
|
||||
|
||||
dkms:
|
||||
@sed -i -e '/^PACKAGE_VERSION=/ s/=.*/=\"$(DRIVER_VERSION)\"/' dkms.conf
|
||||
@echo "$(DRIVER_VERSION)" >VERSION
|
||||
@mkdir $(DKMS_ROOT_PATH)
|
||||
@cp `pwd`/dkms.conf $(DKMS_ROOT_PATH)
|
||||
@cp `pwd`/VERSION $(DKMS_ROOT_PATH)
|
||||
@cp `pwd`/Makefile $(DKMS_ROOT_PATH)
|
||||
@cp `pwd`/asus-wmi-sensors.c $(DKMS_ROOT_PATH)
|
||||
@dkms add -m $(DRIVER) -v $(DRIVER_VERSION)
|
||||
@dkms build -m $(DRIVER) -v $(DRIVER_VERSION)
|
||||
@dkms install --force -m $(DRIVER) -v $(DRIVER_VERSION)
|
||||
@modprobe $(DRIVER)
|
||||
|
||||
dkms_clean:
|
||||
@if [ ! -z "$(MODPROBE_OUTPUT)" ]; then \
|
||||
rmmod $(DRIVER);\
|
||||
fi
|
||||
@dkms remove -m $(DRIVER) -v $(DRIVER_VERSION) --all
|
||||
@rm -rf $(DKMS_ROOT_PATH)
|
||||
|
|
19
README.md
19
README.md
|
@ -32,6 +32,18 @@ The module can be manually loaded by issuing ```sudo modprobe asus_wmi_sensors``
|
|||
|
||||
Run ```sensors``` and you should see a ```asuswmisensors-virtual-0``` device and readouts as you see in the UEFI interface.
|
||||
|
||||
### Other distributions
|
||||
|
||||
Clone the git repo: ```git clone https://github.com/electrified/asus-wmi-sensors.git```
|
||||
|
||||
Build the module ```sudo make dkms```
|
||||
|
||||
Insert the module ```sudo modprobe asus-wmi-sensors```
|
||||
|
||||
Run ```sensors``` and you should see a ```asuswmisensors-virtual-0``` device and readouts as you see in the UEFI interface.
|
||||
|
||||
Optional - consult your distro's documentation for info on how to make the module be loaded automatically at boot
|
||||
|
||||
## FAQ
|
||||
|
||||
### I think my motherboard should be supported but it doesn't work, what can I do?
|
||||
|
@ -87,4 +99,9 @@ CPU VRM Temperature: +31.0°C
|
|||
Water In: +216.0°C
|
||||
Water Out: +28.0°C
|
||||
CPU VRM Output Current: +1.00 A
|
||||
```
|
||||
```
|
||||
|
||||
## Thanks
|
||||
Ray Hinchcliffe, author of SIV for info
|
||||
Original authors of the IT87 makefile
|
||||
Authors of other mainlined HWMON kernel modules that I've studied
|
Loading…
Reference in New Issue