# Could not find a Makefile in the kernel source[SOLVED]

## se ven

As title said. after i emerge --sync and emerge -uD world last night, 

i'v got an issue now when i emerge a package which need a Makefile:

```

 * Fetching files in the background.

 * To view fetch progress, run in another terminal:

 * tail -f /var/log/emerge-fetch.log

 * vbox-kernel-module-src-5.0.16.tar.xz SHA256 SHA512 WHIRLPOOL size ;-) ...                [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Could not find a Makefile in the kernel source directory.

 * Please ensure that /usr/src/linux points to a complete set of Linux sources

 * Unable to calculate Linux Kernel version for build, attempting to use running version

 * Could not find a usable .config in the kernel source directory.

 * Please ensure that /usr/src/linux points to a configured set of Linux sources.

 * If you are using KBUILD_OUTPUT, please set the environment var so that

 * it points to the necessary object directory so that it might find .config.

 * ERROR: app-emulation/virtualbox-modules-5.0.16::gentoo failed (setup phase):

 *   Kernel not configured; no .config found in 

 * 

 * Call stack:

 *                          ebuild.sh, line 133:  Called pkg_setup

 *   virtualbox-modules-5.0.16.ebuild, line  31:  Called linux-mod_pkg_setup

 *                   linux-mod.eclass, line 570:  Called require_configured_kernel

 *                  linux-info.eclass, line 297:  Called die

 * The specific snippet of code:

 *              die "Kernel not configured; no .config found in ${KV_OUT_DIR}"

 * 

 * If you need support, post the output of `emerge --info '=app-emulation/virtualbox-modules-5.0.16::gentoo'`,

 * the complete build log and the output of `emerge -pqv '=app-emulation/virtualbox-modules-5.0.16::gentoo'`.

 * The complete build log is located at '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.16/temp/build.log'.

 * The ebuild environment file is located at '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.16/temp/die.env'.

 * Working directory: '/usr/lib64/python3.4/site-packages'

 * S: '/var/tmp/portage/app-emulation/virtualbox-modules-5.0.16/work'

```

and im thinking that running kernel source may unmerged as part of an update. 

```

# equery list -i gentoo-sources

 * Searching for gentoo-sources ...

[IP-] [  ] sys-kernel/gentoo-sources-4.5.0-r1:4.5.0-r1

```

```

# uname -r

4.5.0-gentoo

```

and gentoo-source-4.5.0-r1 is installed automatically.

```

eix gentoo-sources

...

(4.4.6) (~)4.4.6^bs

     (4.5.0) (~)4.5.0^bs

       {build deblob experimental kdbus symlink}

     Installed versions:  4.5.0-r1(4.5.0-r1)^bs(01:38:37 PM 03/30/2016)(-build -experimental -kdbus -symlink)

     Homepage:            https://dev.gentoo.org/~mpagano/genpatches

     Description:   

```

and i don't know how to fix this problem what if  i want to stay with gentoo-sources-4.5.0 forever?Last edited by se ven on Tue Apr 12, 2016 11:37 am; edited 2 times in total

----------

## Roman_Gruber

ls -ali /usr/src/linux

does this point to a valid kernel source which contains full kernel sources + valid kernel.config?

e.g. runnen kernel config from current gentoo-sources

--

i do not use symlink useflag of the kernel sources. i set the kernel link by hand.

when you unmerge /update your current gentoo-sources, the symlink will be updated and than you get such errors

----------

## se ven

yes.

```

# ls -ali /usr/src/linux

264604 lrwxrwxrwx 1 root root 18 Mar 17 20:27 /usr/src/linux -> linux-4.5.0-gentoo

```

```

ls -al /usr/src/linux-4.5.0-gentoo

total 1046900

drwxr-xr-x 23 root root      4096 Apr  5 11:24 .

drwxr-xr-x  6 root root      4096 Mar 30 13:38 ..

-rw-r--r--  1 root root         0 Mar 21 16:59 Appending

drwxr-xr-x  4 root root      4096 Apr  5 11:24 arch

drwxr-xr-x  3 root root      4096 Apr  5 11:24 block

drwxr-xr-x  2 root root      4096 Apr  5 11:24 certs

-rw-r--r--  1 root root    143648 Mar 30 23:02 .config

-rw-r--r--  1 root root    144567 Mar 19 02:27 .config--2016-03-19--02-27-46.bak

-rw-r--r--  1 root root    142967 Mar 21 09:04 .config--2016-03-21--09-04-39.bak

-rw-r--r--  1 root root    143711 Mar 30 23:00 .config.old

-rw-r--r--  1 root root         0 Mar 21 16:59 Copying

drwxr-xr-x  4 root root     20480 Apr  5 11:24 crypto

drwxr-xr-x 18 root root     12288 Apr  5 11:24 Documentation

drwxr-xr-x 81 root root      4096 Apr  5 11:24 drivers

-rw-r--r--  1 root root         0 Mar 21 16:59 Finalizing

drwxr-xr-x 36 root root      4096 Apr  5 11:24 firmware

drwxr-xr-x 59 root root     12288 Apr  5 11:24 fs

drwxr-xr-x  4 root root      4096 Apr  5 11:24 include

drwxr-xr-x  2 root root      4096 Apr  5 11:24 init

-rw-r--r--  1 root root         0 Mar 21 16:59 Initializing...

drwxr-xr-x  2 root root      4096 Apr  5 11:24 ipc

drwxr-xr-x 14 root root     12288 Apr  5 11:24 kernel

drwxr-xr-x 11 root root     20480 Apr  5 11:24 lib

-rw-r--r--  1 root root       485 Mar 30 23:07 .missing-syscalls.d

drwxr-xr-x  2 root root     12288 Apr  5 11:24 mm

-rw-r--r--  1 root root      6064 Mar 30 23:07 modules.builtin

-rw-r--r--  1 root root     62229 Mar 30 23:20 modules.order

-rw-r--r--  1 root root    854210 Mar 30 23:20 Module.symvers

drwxr-xr-x 36 root root      4096 Apr  5 11:24 net

drwxr-xr-x  8 root root      4096 Apr  5 11:24 scripts

drwxr-xr-x  5 root root      4096 Apr  5 11:24 security

drwxr-xr-x 21 root root      4096 Apr  5 11:24 sound

-rw-r--r--  1 root root   3326060 Mar 30 23:07 System.map

-rw-r--r--  1 root root   3531496 Mar 30 23:07 .tmp_kallsyms1.o

-rw-r--r--  1 root root   3531496 Mar 30 23:07 .tmp_kallsyms2.o

-rw-r--r--  1 root root   3326060 Mar 30 23:07 .tmp_System.map

drwxr-xr-x  2 root root     65536 Mar 30 23:20 .tmp_versions

-rwxr-xr-x  1 root root 155425336 Mar 30 23:07 .tmp_vmlinux1

-rwxr-xr-x  1 root root 157522488 Mar 30 23:07 .tmp_vmlinux2

drwxr-xr-x  3 root root      4096 Apr  5 11:24 usr

-rw-r--r--  1 root root         2 Mar 30 23:07 .version

drwxr-xr-x  4 root root      4096 Apr  5 11:24 virt

-rwxr-xr-x  1 root root 157522488 Mar 30 23:07 vmlinux

-rw-r--r--  1 root root        75 Mar 30 23:07 .vmlinux.cmd

lrwxrwxrwx  1 root root        54 Mar 30 23:07 vmlinux-gdb.py -> /usr/src/linux-4.5.0-gentoo/scripts/gdb/vmlinux-gdb.py

-rw-r--r--  1 root root 395444088 Mar 30 23:07 vmlinux.o

```

----------

## Roman_Gruber

kinda simple

```
ASUS-G75VW roman # equery list -i gentoo-sources

 * Searching for gentoo-sources ...

[I--] [??] sys-kernel/gentoo-sources-4.5.0:4.5.0

[IP-] [  ] sys-kernel/gentoo-sources-4.5.0-r1:4.5.0-r1

```

you should have 

[I--] [??] sys-kernel/gentoo-sources-4.5.0:4.5.0

your installed [IP-] [  ] sys-kernel/gentoo-sources-4.5.0-r1:4.5.0-r1 has -r1. that implies it is a different package.

4.5.0 is not 4.5.0-r1

fix reemerge 

[I--] [??] sys-kernel/gentoo-sources-4.5.0:4.5.0

or update to 4.5.0-r1 (which should be easier way)

emerge -av depclean is nasty, i only unmerge gentoo-sources which are not in use. that means manual labour and not saying yes when you are asked to.

----------

## se ven

 *tw04l124 wrote:*   

> 
> 
> ```
> ASUS-G75VW roman # equery list -i gentoo-sources
> 
> ...

 

Er... i can't got 4.5.0 in equery:

```

# equery list -i gentoo-sources

 * Searching for gentoo-sources ...

[IP-] [  ] sys-kernel/gentoo-sources-4.5.0-r1:4.5.0-r1

```

is that because sources 4.5.0 is uninstalled and i reboot the laptop?

 *tw04l124 wrote:*   

> 
> 
> fix reemerge 
> 
> [I--] [??] sys-kernel/gentoo-sources-4.5.0:4.5.0 
> ...

 

yeah, that's what i need, and should i rebuild it after remerge?

----------

## Roman_Gruber

```
equery y gentoo-sources

Keywords for sys-kernel/gentoo-sources:

             |                                 |   u            |  

             | a a   a         n   p r     s   |   n            |  

             | l m   r h i m m i   p i s   p   | e u s          | r

             | p d a m p a 6 i o p c s 3   a x | a s l          | e

             | h 6 r 6 p 6 8 p s p 6 c 9 s r 8 | p e o          | p

             | a 4 m 4 a 4 k s 2 c 4 v 0 h c 6 | i d t          | o

-------------+---------------------------------+----------------+-------

  3.4.110    | ~ ~ ~ o ~ ~ o o o ~ ~ o ~ ~ ~ ~ | 5 o 3.4.110    | gentoo

-------------+---------------------------------+----------------+-------

  3.4.111    | ~ ~ ~ o ~ ~ o o o ~ ~ o ~ ~ ~ ~ | 5 o 3.4.111    | gentoo

-------------+---------------------------------+----------------+-------

 3.4.9999    | o o o o o o o o o o o o o o o o | 5 o 3.4.9999   | gentoo

-------------+---------------------------------+----------------+-------

  3.10.95    | + + + o + + o ~ o + + o ~ ~ + + | 5 o 3.10.95    | gentoo

-------------+---------------------------------+----------------+-------

 3.10.101    | ~ ~ ~ o ~ ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 3.10.101   | gentoo

-------------+---------------------------------+----------------+-------

  3.12.52-r1 | + + + o + + o ~ o + + o ~ ~ + + | 5 o 3.12.52-r1 | gentoo

-------------+---------------------------------+----------------+-------

  3.12.57    | ~ ~ ~ o ~ ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 3.12.57    | gentoo

-------------+---------------------------------+----------------+-------

3.12.9999    | o o o o o o o o o o o o o o o o | 5 o 3.12.9999  | gentoo

-------------+---------------------------------+----------------+-------

  3.14.58-r1 | + + + ~ + + o ~ o + + o ~ ~ + + | 5 o 3.14.58-r1 | gentoo

-------------+---------------------------------+----------------+-------

  3.14.65    | ~ ~ ~ ~ ~ ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 3.14.65    | gentoo

-------------+---------------------------------+----------------+-------

  3.18.25-r1 | ~ + ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ + | 5 o 3.18.25-r1 | gentoo

-------------+---------------------------------+----------------+-------

  3.18.26    | ~ ~ ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 3.18.26    | gentoo

-------------+---------------------------------+----------------+-------

  3.18.27    | ~ ~ ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 3.18.27    | gentoo

-------------+---------------------------------+----------------+-------

  3.18.28    | ~ ~ ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 3.18.28    | gentoo

-------------+---------------------------------+----------------+-------

  3.18.29    | ~ ~ ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 3.18.29    | gentoo

-------------+---------------------------------+----------------+-------

    4.0.4    | ~ ~ ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 4.0.4      | gentoo

-------------+---------------------------------+----------------+-------

    4.0.9    | + + + ~ - + o ~ o + + o ~ ~ + + | 5 o 4.0.9      | gentoo

-------------+---------------------------------+----------------+-------

   4.1.12    | + + ~ ~ - + o ~ o + + o ~ ~ + + | 5 o 4.1.12     | gentoo

-------------+---------------------------------+----------------+-------

   4.1.15-r1 | + + + ~ - + o ~ o + + o ~ ~ + + | 5 o 4.1.15-r1  | gentoo

-------------+---------------------------------+----------------+-------

   4.1.20    | ~ ~ ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 4.1.20     | gentoo

-------------+---------------------------------+----------------+-------

    4.4.6    | ~ ~ ~ ~ - ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 4.4.6      | gentoo

-------------+---------------------------------+----------------+-------

 [I]4.5.0-r1 | ~ ~ ~ ~ ~ ~ o ~ o ~ ~ o ~ ~ ~ ~ | 5 o 4.5.0-r1   | gentoo

```

4.5.0 is not in the tree anymore. i only update the kernel when i have time

you should upgrade to 4.5.0-r1 (its easier for you) next time you should not update the symlink / remove the gentoo-sources

thats why the tool complained with the first characters, but i showed you that i had it still installed.

----------

## Syl20

So you uninstalled sys-kernel/gentoo-sources-4.5.0. But, when you installed sys-kernel/gentoo-sources-4.5.0-r1, the /usr/src/linux symlink wasn't updated. Is the "symlink" USE flag set (If so, it's a bug) ?

You can solve your problem by updating yourself the symlink : run eselect kernel.

----------

## Roman_Gruber

the issue is

ebuilds needs

a) valid kernel source

b) valid kernel symlink

c) valid kernel config 

so its not a bug, but a feature. 

even when the ebuild have had updated the symlink, there would still be no valid config but a valid symlink with valid kernel-sources

the symlink useflag is a bug in my eyes, as hte user needs to do things anyway. else ebuilds will fail

the user can set hte symlink with the eselct tool or with ln like i do, oldschool

----------

## Syl20

 *tw04l124 wrote:*   

> the symlink useflag is a bug in my eyes, as hte user needs to do things anyway. else ebuilds will fail

 

To paraphrase you, for me, it's not a bug, but a feature.

A kernel update is potentially a security update, so, when a new kernel-sources package is available, I compile and install the new kernel. In this case, why emerging the new kernel modules twice (one time for the current kernel, and one more time for the new one, via emerge @module-rebuild) ?

And, as some packages that need a valid kernel configuration also need a specific kernel version, I think it's better to combine the versions released more or less at the same time.

 *Quote:*   

> the user can set hte symlink with the eselct tool or with ln like i do, oldschool

 

You can do the same with all the available eselect modules. Or, to go further, you can stop using portage, and keep Gentoo up-to-date like others do with their LFS-based system : oldschool. But, sometimes, we appreciate the commands that make our life easier.

----------

