Problem compiling a driver : "No rule to make target"

20,713

First Issue

You're missing the kernel-headers package. You need these to compile kernel modules.

yum install kernel-headers

Assuming this where you downloaded the drivers from. When I unpacked them on a CentOS 6.4 system I got the following error:

$ cd jmebp-1.0.8.5
$ ls
CHANGELOG  jme.c  jme.h  Makefile  scripts
$ make
make: *** /lib/modules/2.6.32-279.14.1.el6.x86_64/build: No such file or directory.  Stop.
make: *** [modules] Error 2

After installing the kernel-headers package, I ran make a second time:

$ make
make: *** /lib/modules/2.6.32-279.14.1.el6.x86_64/build: No such file or directory.  Stop.
make: *** [modules] Error 2

Still a problem? Debugging it further I figured out my other problem, which you might encounter as well, so I'm documenting it below, just in case.

Second Issue

The link in the kernel directory appeared to be broken.

$ pwd
/lib/modules/2.6.32-279.14.1.el6.x86_64

$ ls -l | grep build
lrwxrwxrwx  1 root root     51 Dec 15 14:49 build -> ../../../usr/src/kernels/2.6.32-279.14.1.el6.x86_64
lrwxrwxrwx  1 root root      5 Dec 15 14:50 source -> build

$ ls -l build/
ls: cannot access build/: No such file or directory

Whoops, wrong version of the kernel-headers and kernel-devel for our kernel version. We're currently running this version of the kernel:

$ uname -r
2.6.32-279.14.1.el6.x86_64

But we just installed the kernel-headers and kernel-devel packages for this version:

2.6.32-358.6.1.el6.x86_64

So let's install that version of the kernel as well and reboot so we can use the newer kernel:

$ yum update kernel

After our reboot everything looks much better:

$ ls
CHANGELOG  jme.c  jme.h  Makefile  scripts

$ make
make[1]: Entering directory `/usr/src/kernels/2.6.32-358.6.1.el6.x86_64'
  CC [M]  /home/sam/jmebp/jmebp-1.0.8.5/jme.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/sam/jmebp/jmebp-1.0.8.5/jme.mod.o
  LD [M]  /home/sam/jmebp/jmebp-1.0.8.5/jme.ko.unsigned
  NO SIGN [M] /home/sam/jmebp/jmebp-1.0.8.5/jme.ko
make[1]: Leaving directory `/usr/src/kernels/2.6.32-358.6.1.el6.x86_64'

$ ls
CHANGELOG  jme.c  jme.h  jme.ko  jme.ko.unsigned  Makefile  scripts

Now we see the jme.ko kernel module. To install it:

make install
Share:
20,713

Related videos on Youtube

Ahuri3
Author by

Ahuri3

Updated on September 18, 2022

Comments

  • Ahuri3
    Ahuri3 over 1 year

    First of all I am running a CentOS 6.4 installation. My computer is a laptop and I am trying to install the drivers for my ethernet card, because this week end I lost my ability to connect to the Internet.

    So I downloaded the driver : jmebp-1.0.8.5

    I installed gcc, kernel-devel and since it wasn't working I finally installed the group Development Tools (in case I had forgot something).

    When I

    make install
    

    I get this error :

    *** No rule to make target `internet/jmebp-1.0.8.5'.  Stop.
    Leaving directory `/lib/modules/2.6.32-358.6.1.el6.x86_64/build'
    

    My makefile is :

        MODNAME := jme
    obj-m := $(MODNAME).o
    
    ifneq ($(KERNELRELEASE),)
    #########################
    # kbuild part of makefile
    #########################
    EXTRA_CFLAGS += -Wall -O3
    #EXTRA_CFLAGS += -DTX_DEBUG
    #EXTRA_CFLAGS += -DREG_DEBUG
    
    else
    #########################
    # Normal Makefile
    #########################
    TEMPFILES := $(MODNAME).o $(MODNAME).mod.c $(MODNAME).mod.o Module.symvers .$(MODNAME).*.cmd .tmp_versions modules.order Module.markers Modules.symvers
    
    ifeq (,$(KVER))
    KVER=$(shell uname -r)
    endif
    KSRC ?= /lib/modules/$(KVER)/build
    MINSTDIR ?= /lib/modules/$(KVER)/kernel/drivers/net
    
    all: modules
        @rm -rf $(TEMPFILES)
    modules:
        @$(MAKE) -C $(KSRC) M=$(shell pwd) modules
    
    checkstack: modules
        objdump -d $(obj-m) | perl $(KSRC)/scripts/checkstack.pl $(shell uname -m)
        @rm -rf $(TEMPFILES)
    
    namespacecheck: modules
        perl $(KSRC)/scripts/namespace.pl
        @rm -rf $(TEMPFILES)
    
    install: modules
        install -m 644 $(MODNAME).ko $(MINSTDIR)
        depmod -a $(KVER)
    
    patch:
        @/usr/bin/diff -uar -X dontdiff ../../trunc ./ > bc.patch || echo > /dev/null
    
    buildtest:
        SRCDIRS=`find ~/linux-src -mindepth 1 -maxdepth 1 -type d -name 'linux-*' | sort -r -n`; \
        SRCDIRS="$${SRCDIRS} `find ~/linux-src/centos -mindepth 2 -maxdepth 2 -type d -name 'linux-*' | sort -r -n`"; \
        SRCDIRS="$${SRCDIRS} `find ~/linux-src/fedora -mindepth 2 -maxdepth 2 -type d -name 'linux-*' | sort -r -n`"; \
        for d in $${SRCDIRS}; do \
            $(MAKE) clean && $(MAKE) -C . KSRC=$${d} modules; \
            if [ $$? != 0 ]; then \
                exit $$?; \
            fi; \
        done
        $(MAKE) clean
    
    clean:
        @rm -rf $(MODNAME).ko $(TEMPFILES)
    
    %::
        $(MAKE) -C $(KSRC) M=`pwd` $@
    
    endif
    

    Any suggestions ?

    • vonbrand
      vonbrand about 11 years
      How did you "loose the ability to connect to the Internet"? A kernel update should never break existing setups, and you can boot into the old kernel anyway. Also note that most third party drivers are utter rubbish, and will at most work for a very narrow selection of kernels.
    • Ahuri3
      Ahuri3 about 11 years
      My issue is similar to this :ubuntuforums.org/showthread.php?t=2102394 I don't know why it stopped working, but it just stopped after a reboot (the system is brand new, installed thursday I think). It doesn't work on the "old" kernel either, it's one of the first thing I tried. So now I am trying to install the driver to see if it helps
    • slm
      slm about 11 years
      This where you go the drivers? driver.jmicron.com.tw/Ethernet/Linux
    • Ahuri3
      Ahuri3 about 11 years
      Yes this is where I got the driver
  • Ahuri3
    Ahuri3 about 11 years
    Thank you very much. I will try this and report back the results.
  • slm
    slm about 11 years
    I've cleaned up the answer, hope it's more clear.
  • RabT
    RabT over 8 years
    @slm I have a related question. I found your answer here by googling the current error message. Are you willing to help me resolve the related problem? Here is the link: unix.stackexchange.com/questions/262215/…