no rule to make a target error

hi I’m compiling a simple kernel module but in the messages I have this error:
make[1]: *** No rule to make target ‘modules’. Stop.
i installed linux header,but i don’t understand the error.
thank you

Will need a little more info.

What directory were you in when you ran make.

What exact command did you use.

What is in your makefile.

Are you trying to build a custom kernel module, or just rebuild the Linux kernel modules.

Telling us the above will give us some pointers as to what is going wrong

debian@beaglebone:/hello$ ls
Makefile mymodule.c

obj-m += mymodule.o

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

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

this is Makefile

#include <linux/module.h>
#include <linux/init.h>

/* Meta Information */
MODULE_AUTHOR(“Johannes 4 GNU/Linux”);


  • @brief This function is called, when the module is loaded into the kernel
    static int __init my_init(void) {
    printk(“Hello, Kernel!\n”);
    return 0;


  • @brief This function is called, when the module is removed from the kernel
    static void __exit my_exit(void) {
    printk(“Goodbye, Kernel\n”);


this is mymodule.c

i use command simple make for build my kernel module,
but i didn t tryed to build a custom kernel module

ln -s /usr/src/ /lib/modules/ 
but the same problem

Does that director exist ?
If you type ‘uname -r’ in a console it will tell you what string is being inserted.

uname -r

debian@beaglebone:/$ cd lib
debian@beaglebone:/lib$ cd modules
debian@beaglebone:/lib/modules$ ls
debian@beaglebone:/lib/modules$ cd 4.19.94-ti-r42
debian@beaglebone:/lib/modules/4.19.94-ti-r42$ ls
build modules.alias.bin modules.dep.bin modules.symbols
extra modules.builtin modules.devname modules.symbols.bin
kernel modules.builtin.bin modules.order
modules.alias modules.dep modules.softdep

debian@beaglebone:/lib/modules/4.19.94-ti-r42$ cd build
debian@beaglebone:/lib/modules/4.19.94-ti-r42/build$ ls

Is there a Makefile in /lib/modules/4.19.94-ti-r42/build ?

The “make -C /lib/modules/$(shell uname -r)/build” is trying to call a Makefile.
I think you are probably missing some stuff.

no ,no Makefile

only linux-headers-4.19.94-ti-r42

Ok, just trued installing the linux headers on my BBB.
I am running 5.10.140-ti-r52 and installing the kernel headers does give me a Makefile in build.

Have you checked in /lib/modules/4.19.94-ti-r42/build/linux-headers-4.19.94-ti-r42
Perhaps on older versions the Makefile is in a different location

ok how can i remove this version and install the new one, what are the commands?

or else I have to change the directory: