# Fatal Error Compiling Kernel FreeBSD 9



## UnOmE (Jun 11, 2012)

Just starting out with FreeBSD and it's been a long time since I've used a *nix OS.  I wanted to compile a custom kernel and get the feel for this process and so I set up a configuration file and tried to compile which resulted in this error.

```
"Makefile.inc1", line 1112: Malformed conditional (${MK_GCC} != "no" && ${MK_CLANG_IS_CC} == "no")
"Makefile.inc1", line 1114: if-less endif
"Makefile.inc1", line 1174: Malformed conditional (${MK_CLANG} != "no" && (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang"))
"Makefile.inc1", line 1177: if-less endif
"Makefile.inc1", line 1179: Malformed conditional (${MK_GCC} != "no" && ${MK_CLANG_IS_CC} == "no")
"Makefile.inc1", line 1181: if-less endif
"Makefile.inc1", line 1242: Malformed conditional (${MK_LIBCPLUSPLUS} != "no")
"Makefile.inc1", line 1244: if-less endif
make: fatal errors encountered -- cannot continue
*** Error code 1
```
Seems that make is complaining about the mentioned lines of code but I have no idea why, or what to do about it. I did download the source for base and sys today but I hadn't tried compiling the kernel prior to this so I can*'*t say if that has anything to do with the error. I've already searched posts by others that have had this same issues and couldn't find any so here I am.  Really need some help, thanks in advance.


----------



## SirDice (Jun 12, 2012)

Is there anything in /etc/make.conf or /etc/src.conf?


----------



## docds (Jul 2, 2012)

I have the same problem.

```
===>  Building for dahdi-kmod-2.4.0rc5_6
===> freebsd (all)
===> freebsd/dahdi (all)
"/sys/conf/kmod.mk", line 116: Malformed conditional (${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang")
"/sys/conf/kmod.mk", line 120: if-less endif
"/sys/conf/kern.mk", line 18: Malformed conditional (${MK_CLANG_IS_CC} != "no" || ${CC:T:Mclang} == "clang")
"/sys/conf/kern.mk", line 32: if-less endif
"/sys/conf/kern.mk", line 54: Malformed conditional (${MK_CLANG_IS_CC} == "no" && ${CC:T:Mclang} != "clang")
"/sys/conf/kern.mk", line 61: if-less endif
make: fatal errors encountered -- cannot continue
*** Error code 1

Stop in /usr/ports/misc/dahdi-kmod/work/dahdi-freebsd-complete-2.4.0-rc5+2.4.0-rc1/freebsd/freebsd.
*** Error code 1

Stop in /usr/ports/misc/dahdi-kmod/work/dahdi-freebsd-complete-2.4.0-rc5+2.4.0-rc1/freebsd.
*** Error code 1

Stop in /usr/ports/misc/dahdi-kmod.
```
My system:

```
uname -a
FreeBSD www.net.com 9.0-STABLE FreeBSD 9.0-STABLE #3 r237555M: Mon Jun 25 12:14:49 EEST 2012
root@www.net.com:/usr/obj/usr/src/sys/GENERIC  i386
```
Does anyone have any idea?


----------



## zer0sig (Oct 24, 2012)

I'm getting the same thing building a kernel in 8.3 after many successful installs from cvsupped src.


----------



## SirDice (Oct 25, 2012)

What's in /etc/make.conf?


----------



## jalla (Oct 25, 2012)

Also make sure that you build the kernel in the "most failsafe way", as outlined in /usr/src/UPDATING.

I usually build in a different way myself and was bitten by this error a few days ago.


----------



## kpa (Oct 25, 2012)

It's safest to do make buildworld before make buildkernel, if you don't build world first the kernel compilation may use out of date files from /usr/share/mk.


----------



## zer0sig (Oct 27, 2012)

Not just buildworld but installworld. running *make install* from /usr/src/share/mk fixed this, but I almost always build and install world first as a matter of course. Was just trying to speed things up a little bit. I'm running 9.0 now and so far so good.


----------



## kpa (Oct 27, 2012)

Building world creates a toolchain under /usr/obj that the kernel compilation uses if it exists. If there's no toolchain in /usr/obj  the kernel compilation will use the system tools and include files. Using the system tools to build the kernel may fail when upgrading to a higher major version and that's the reason make buildworld should be done first. Installing is recommended to be done in the opposite order, kernel first and then world, world preferably installed after a reboot with the new kernel in single user mode.


----------



## zer0sig (Oct 27, 2012)

Roger that. I have done well installing world first, even updating to 9 but I usually have done fresh installations for new major versions historically so your reasoning makes sense.


----------



## jalla (Oct 27, 2012)

From /usr/src/UPDATING

```
To build a kernel
-----------------
If you are updating from a prior version of FreeBSD (even one just
a few days old), you should follow this procedure.  It is the most
failsafe as it uses a /usr/obj tree with a fresh mini-buildworld,

make kernel-toolchain
make -DALWAYS_CHECK_MAKE buildkernel KERNCONF=YOUR_KERNEL_HERE
make -DALWAYS_CHECK_MAKE installkernel KERNCONF=YOUR_KERNEL_HERE
```
Using that you can avoid doing a full buildworld.


----------

