LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-15-2016, 10:45 AM   #1
theochenko
LQ Newbie
 
Registered: Jun 2016
Posts: 5

Rep: Reputation: Disabled
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?
 
Old 06-15-2016, 12:18 PM   #2
SlackProby
LQ Newbie
 
Registered: Jun 2016
Posts: 8

Rep: Reputation: Disabled
Quote:
Originally Posted by theochenko View Post
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.
 
Old 06-15-2016, 12:29 PM   #3
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,749

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
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
 
Old 06-15-2016, 07:14 PM   #4
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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.
 
Old 06-16-2016, 08:08 AM   #5
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,749

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
Quote:
Originally Posted by Fred Caro View Post
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
 
Old 06-16-2016, 06:37 PM   #6
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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.
 
Old 06-16-2016, 06:59 PM   #7
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,388

Rep: Reputation: 408Reputation: 408Reputation: 408Reputation: 408Reputation: 408
/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
 
Old 06-17-2016, 08:11 PM   #8
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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.
 
Old 06-17-2016, 08:27 PM   #9
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,688

Rep: Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259
/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.
 
Old 06-18-2016, 08:15 PM   #10
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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.
 
Old 06-18-2016, 08:25 PM   #11
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,688

Rep: Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259
Quote:
Originally Posted by Fred Caro View Post
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.
 
Old 06-19-2016, 07:07 PM   #12
Fred Caro
Member
 
Registered: May 2007
Posts: 999

Rep: Reputation: 166Reputation: 166
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.
 
Old 06-19-2016, 07:44 PM   #13
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 5,388

Rep: Reputation: 408Reputation: 408Reputation: 408Reputation: 408Reputation: 408
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

Last edited by keefaz; 06-19-2016 at 07:49 PM.
 
Old 06-20-2016, 05:20 AM   #14
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,688

Rep: Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259Reputation: 1259
Quote:
Originally Posted by Fred Caro View Post
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.
 
Old 06-20-2016, 06:29 AM   #15
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 2,981
Blog Entries: 1

Rep: Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626Reputation: 626
$ 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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
A rather odd kernel build error while building a powerpc version of kernel 3.0.3 bloggins666 Linux - Kernel 2 01-29-2015 10:08 AM
Gimp build from source libtool error makefile edit ZeroDaHero Linux - Software 6 04-11-2010 12:40 PM
Makefile VS IDE build? Katherine Programming 4 01-20-2009 06:08 AM
kernel build error CowboyJ Linux - Newbie 4 01-04-2004 10:13 PM
kernel build error tandre *BSD 1 06-03-2003 02:55 AM


All times are GMT -5. The time now is 09:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration