Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Is it mandatory to have the name of the makefile as 'Makefile' for kernal module comp

    Is it mandatory to have the name of the makefile as 'Makefile' for kernal module compilation ?

    I have written a small kernel module for 2.6 kernel. I have written the make file as required for 2.6, but named the makefile as 'Makefile.2.6'.

    When I execute make using the command "make -f Makefile.2.6", Compilation starts and when kbuild has to call my Makefile, instead of calling Makefile.2.6 it calls Makefile (which is available in the same directory, for user space compilation).

    Can't I have any userdefined name for my kernel module Makefile like Makefile.2.6

    Below is the error log.

    make -w -f
    make: Entering directory `/home/kernel/TOS/code/my_module'
    make -C /lib/modules/2.6.18-EP80579_8K/build M=/home/kernel/TOS/code/my_module SUBDIRS=/home/kernel/TOS/code/my_module
    make[1]: Entering directory `/usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386'
    /home/kernel/TOS/code/my_module/Makefile:4: ../LR/make.h: No such file or directory
    /home/kernel/TOS/code/my_module/Makefile:5: ../LR/make.rule: No such file or directory
    /home/kernel/TOS/code/my_module/Makefile:6: make.h: No such file or directory
    make[2]: *** No rule to make target `make.h'. Stop.
    make[1]: *** [_module_/home/kernel/TOS/code/my_module] Error 2
    make[1]: Leaving directory `/usr/src/redhat/BUILD/kernel-2.6.18/linux-2.6.18.i386'
    make: *** [all] Error 2
    make: Leaving directory `/home/kernel/TOS/code/future/ipsecv4'
    [root@localhost ipsecv4]# vim /lib/modules/2.6.18-EP80579_8K/build/Makefile

    Any help will be appreciated.

    Thanks in advance.


  2. #2
    Linux Enthusiast gerard4143's Avatar
    Join Date
    Dec 2007
    Canada, Prince Edward Island
    If you look at the lines in your make file or my example:

    obj-m += test.o

    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules

    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
    and expand them you'll see your calling another makefile at location
    make -C /lib/modules/$(shell uname -r)/build

    on my system that path would be:

    make -C /lib/modules/2.6.27-9-default/build/

    where there exists a file called Makefile...Hope this helps...Gerard4143

    so is it mandatory to call it it probably should be...enter and change at your own peril...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts