# make.conf configuration



## Windmill (Apr 23, 2014)

Hi, I need to to configure make.conf. First, what's the correct way to configure CFLAGS and CXXFLAGS? 
	
	



```
CFLAGS+="-march=native -O2"
```
 or without the ""? And what's the correct option for -O? I read that -O3 and -O4 can cause problems, so it's safe to use just -O2? 
What's the option for parallel compilations? I didn't find it in `make.conf manpage`
These are my questions for now.


----------



## SirDice (Apr 23, 2014)

Windmill said:
			
		

> Hi, I need to to configure make.conf. First, what's the correct way to configure CFLAGS and CXXFLAGS?


Don't mess with them. Seriously. It's going to do more harm than good. Ports already use the most optimal flags, setting them explicitly negates this.


----------



## Windmill (Apr 23, 2014)

I set cflags/cxxflags different times with gentoo and never had any problems. Howewer, setting only cputype is good enough, in that case?


----------



## SirDice (Apr 23, 2014)

Windmill said:
			
		

> I set cflags/cxxflags different times with gentoo and never had any problems.


I'm sure you do, but this is FreeBSD not Gentoo.



> Howewer, setting only cputype is good enough, in that case?


Yes, but it won't improve much.


----------



## Windmill (Apr 23, 2014)

Ok, didn't know that setting cflags explicitly could cause problems. I set only cputype.


What's the option for parallel compilations? I didn't find it in `make.conf manpage`


----------



## trh411 (Apr 23, 2014)

Windmill said:
			
		

> Ok, didn't know that setting cflags explicitly could cause problems.


For one of many such real life examples available here, see the final solution to: [SOLVED] Virtualbox 4.3.10 on FreeBSD 10.


----------



## kpa (Apr 23, 2014)

trh411 said:
			
		

> Windmill said:
> 
> 
> 
> ...



Many of the ports use hand tailored CFLAGS because it's the only way to get the compiler to compile the source code in the first place and produce properly working code on FreeBSD. We were stuck a long time with the ancient GCC version 4.2.1 (that had its own incompatiblities vs. newer GCCs) and only now were are getting a modern C/C++ compiler to replace it, CLang. With CLang however many of the compiler flags have slightly different meanings and can't just blindly assume that the same compiler flags that work on Linux that has a newer GCC also work with CLang on FreeBSD.


----------



## wblock@ (Apr 23, 2014)

Windmill said:
			
		

> Ok, didn't know that setting cflags explicitly could cause problems. I set only cputype.
> 
> 
> What's the option for parallel compilations? I didn't find it in `make.conf manpage`



For ports, it's done automatically when the ports are capable of being built in parallel.  The number of jobs is set in MAKE_JOBS_NUMBER.


----------



## Windmill (Apr 23, 2014)

Ok, thank you.


----------

