LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Build Kernel - Makefile Error (https://www.linuxquestions.org/questions/linux-newbie-8/build-kernel-makefile-error-4175582338/)

theochenko 06-15-2016 10:45 AM

Build Kernel - Makefile Error
 
Hi,

When i do #make menuconfig, #make oldconfig, or any #make command
(from the kernel's repository: /usr/src/linux$) i get:

Code:

make: Makefile: No such file or directory

make: *** No rule to make target 'Makefile'.  Stop.

I think i need to create a Makefile file on the kernel's repository, but how can i do that?

SlackProby 06-15-2016 12:18 PM

Quote:

Originally Posted by theochenko (Post 5561270)
Hi,

When i do #make menuconfig, #make oldconfig, or any #make command
(from the kernel's repository: /usr/src/linux$) i get:

Code:

make: Makefile: No such file or directory

make: *** No rule to make target 'Makefile'.  Stop.

I think i need to create a Makefile file on the kernel's repository, but how can i do that?

What distro? Are you just rebuilding current kernel or a new one? Some distros you have to install linux-headers and linux-source to rebuild current kernel.

smallpond 06-15-2016 12:29 PM

You should not be building in /usr/src/linux. You should install kernel source in a work area under your home directory and build there. The README file in the top-level directory of the kernel has instructions to build it.

http://lxr.free-electrons.com/source/README
http://kernelnewbies.org/KernelBuild

Fred Caro 06-15-2016 07:14 PM

If /usr/src/linux is initially empty why would this be a problem if you could become root and were able to disconnect from the internet to run the make process(s)?

Fred.

smallpond 06-16-2016 08:08 AM

Quote:

Originally Posted by Fred Caro (Post 5561551)
If /usr/src/linux is initially empty why would this be a problem if you could become root and were able to disconnect from the internet to run the make process(s)?

Fred.

Two reasons:
  • You should not build as root (or do anything else as root that you don't have to)
  • /usr/src/linux is where the header files for your running kernel are placed

Fred Caro 06-16-2016 06:37 PM

Reason 1, yes I suppose so, but do you run fakeroot instead?

For reason 2, I get:

Quote:

ls /usr/src/linux
ls: cannot access /usr/src/linux: No such file or directory
But it seems /usr/src does contain the headers

Quote:

ls /usr/src/
linux-headers-4.0.5-XXXX1-486-smp ndiswrapper-1.59
Without fakeroot how does the final make command know the correct permissions, or do you move the files manually, which would make things more complicated?

Fred.

keefaz 06-16-2016 06:59 PM

/usr/src/linux should be left to distro kernel install, not for custom kernels

I mean /lib/modules/$(uname -r)/source link is created after kernel install, if you mess with your custom kernel and want to revert to the distro kernel, you won't be able to compile new modules (nvidia driver for example), as source link for reverted kernel will point to wrong sources

Fred Caro 06-17-2016 08:11 PM

But /usr/src/linux does not exist until you create it.

The reason why the original poster might get errors could be explained by reference to:

and in particular (relating to Ubuntu, if that is your distro)

Quote:


sudo apt-get install libncurses5-dev gcc make git exuberant-ctags bc libssl-dev
Fred.

jpollard 06-17-2016 08:27 PM

/usr/src/linux exists IF you are rebuilding system libraries so that they can interface to the kernel. If it doesn't exist at that time, you can't rebuild the libraries. It is to be owned by root to avoid the user from mucking up the system.

The intent is to provide kernel headers for the system libc (and some others) rebuld process.

The kernel is NOT to be put there. It belongs in a users workspace, the kernel rebuild is completely self contained. The only step requiring root is the final installation step that copies things to /boot, /lib/modules, and modifies any boot menus.

Fred Caro 06-18-2016 08:15 PM

jpollard,

so, if you create /usr/src/linux, as root, where there was only /usr/src and do your build there it will not 'interface' with the current system only the source code you have downloaded from kernel.org? The finished kernel would still be inoperative until you put somewhere it could work,i.e., /boot /lib/modules.

If you are using your home pc (disconnected from the internet) I don't see any advantage from putting the build in user space, unless there is more space.

Fred.

jpollard 06-18-2016 08:25 PM

Quote:

Originally Posted by Fred Caro (Post 5563086)
jpollard,

so, if you create /usr/src/linux, as root, where there was only /usr/src and do your build there it will not 'interface' with the current system only the source code you have downloaded from kernel.org? The finished kernel would still be inoperative until you put somewhere it could work,i.e., /boot /lib/modules.

If you are using your home pc (disconnected from the internet) I don't see any advantage from putting the build in user space, unless there is more space.

Fred.

Safety is one. Why do you want to destroy a working system?

Kernel developers designed the kernel to be compiled by a user. That is why it is done that way.

Too many times the ability to compile an out-of-distribution driver failed because the wrong kernel headers are in /usr/src... So to silence the complaints, they moved the development out. Doing it in /usr/src hasn't been done since about version 2 of the kernel. More flexible, ability to have multiple compiles (bisections searching for regressions for one thing), no ownership issues or access problems... And it keeps the installed system safe for updates.

Fred Caro 06-19-2016 07:07 PM

Quote:

Safety is one. Why do you want to destroy a working system?
I do not.

But on systems where I have compiled kernels on, /usr/src exists but is empty, on this pc it contains headers (this one being AntiX). Perhaps I was just lucky in that I chose Debian to to do the compiling on?

I was under the impression that you could put the downloaded tarball in either the user space or /usr/src, I stuck it in the later because it was empty and would automatically have root permissions, are you saying it would still interact with the current kernel, in the case of Debian.

Fred.

keefaz 06-19-2016 07:44 PM

As long as /lib/modules/$(uname -r)/source link points to the correct kernel source dir, it should be ok.

[edit]
See Linus words about kernel source install in this README:
https://github.com/torvalds/linux

jpollard 06-20-2016 05:20 AM

Quote:

Originally Posted by Fred Caro (Post 5563400)
I do not.

But on systems where I have compiled kernels on, /usr/src exists but is empty, on this pc it contains headers (this one being AntiX). Perhaps I was just lucky in that I chose Debian to to do the compiling on?

I was under the impression that you could put the downloaded tarball in either the user space or /usr/src, I stuck it in the later because it was empty and would automatically have root permissions, are you saying it would still interact with the current kernel, in the case of Debian.

Fred.

The source code SHOULDN'T be root owned... as then you would be either compiling it as root (with binaries going in /usr/src) or forced to to use the -O option to put the binaries elsewhere. Normal security precautions say you shouldn't be compiling programs as root...

As per the link given by keefaz:
Code:

...
 If you install the full sources, put the kernel tarball in a
  directory where you have permissions (e.g. your home directory) and
  unpack it:
...

from http://www.pathname.com/fhs/pub/fhs-...RSRCSOURCECODE
Code:

/usr/src : Source code (optional)
Purpose

Source code may be place placed in this subdirectory, only for reference purposes. [35]

Not compiling...

If you look at /lib/modules/$(uname -r)/source, it is a symbolic link to "build" (same directory), and that is a symbolic link to /usr/src/kernels/$(uname -r), which doesn't normally exist.

The /usr/src directory tree is "reserved" for source code for the distribution, not experimental kernels.

Now if you want to fill up /usr... go ahead. Most of the time you will get away with it.

Shadow_7 06-20-2016 06:29 AM

$ less README

in the root of the kernel tree. You probably skipped make mrproper which builds some of the first timer initial stuff. YMMV depending on where you got your sources from.


All times are GMT -5. The time now is 03:05 PM.