Created
April 18, 2010 19:59
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check kernel version | |
KVERS := $(shell uname -r) | |
KVER := $(shell uname -r | cut -c1-3) | |
ifneq ($(KVER), 2.6) | |
$(error via-velocity driver for kernel 2.6 only) | |
endif | |
KSP := \ | |
/lib/modules/$(KVERS)/build \ | |
/usr/src/linux-$(KVERS) \ | |
/usr/src/linux-$(shell uname -r | sed 's/-.*//') \ | |
/usr/src/kernel-headers-$(KVERS) \ | |
/usr/src/kernel-source-$(KVERS) \ | |
/usr/src/linux-$(KVER) \ | |
/usr/src/linux | |
test_dir = $(shell [ -e $(dir)/include/linux ] && echo $(dir)) | |
KSP := $(foreach dir, $(KSP), $(test_dir)) | |
KSRC := $(firstword $(KSP)) | |
ifeq (,$(KSRC)) | |
$(error Linux kernel source not found) | |
endif | |
# 2.6 kernel | |
SRC = via-velocity.c | |
TARGET = via-velocity.ko | |
INSTDIR := /lib/modules/$(KVERS)/kernel/drivers/net | |
BACKUPEXT=$(shell date +%Y-%m-%d-%s) | |
obj-m += via-velocity.o | |
via_velocity-objs := via-velocity.o | |
default: | |
make -C $(KSRC) SUBDIRS=$(shell pwd) modules | |
install: default | |
mkdir -p $(INSTDIR) | |
@if [ -f $(INSTDIR)/$(TARGET) ] ; then \ | |
if [ ! -f $(INSTDIR)/$(TARGET).backup ]; then \ | |
echo "***** Move official driver $(TARGET) to $(TARGET).$(BACKUPEXT) file" ; \ | |
BACKUPEXT="backup"; \ | |
else \ | |
echo "***** Move current driver $(TARGET) to $(TARGET).$(BACKUPEXT) file" ; \ | |
BACKUPEXT=$(BACKUPEXT); \ | |
fi ; \ | |
echo "mv $(INSTDIR)/$(TARGET) $(INSTDIR)/$(TARGET).$${BACKUPEXT}";\ | |
mv $(INSTDIR)/$(TARGET) $(INSTDIR)/$(TARGET).$${BACKUPEXT} ; \ | |
echo ;\ | |
fi ; | |
install -m 644 -o root $(TARGET) $(INSTDIR) | |
/sbin/depmod -a || true | |
uninstall: | |
@if [ -f $(INSTDIR)/$(TARGET).backup ] ; then \ | |
echo "***** Restore official driver $(TARGET) from $(INSTDIR)/$(TARGET).backup"; \ | |
echo "mv $(INSTDIR)/$(TARGET).backup $(INSTDIR)/$(TARGET)";\ | |
mv -f $(INSTDIR)/$(TARGET).backup $(INSTDIR)/$(TARGET) ;\ | |
fi | |
/sbin/depmod -a | |
clean: | |
-rm -f $(addprefix $(SRC:.c=),.o .ko .mod.c .mod.o) Module.symvers modules.order *~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment