I am type of person who likes to build everything from source code in FreeBSD to get better performance and other customizations. It has become a habit to play with ports tree and system source code and now I believe I have my own template for various server platforms.

One of the most important parts of each configuration template is the /etc/make.conf file. This is were you can change general behavior of the build system. This file is where you actually say which compiler optimizations should be used or what options has to be considered as defaults. Good news is that ports collection as well as the operating system itself honor these configuration.

Here is how a typical make.conf on one of my boxes look like:

CFLAGS=         -O2 -pipe -fno-strict-aliasing
COPTFLAGS=      -O2 -pipe -funroll-loops -ffast-math -fno-strict-aliasing


WITHOUT_X11=            YES
NO_PROFILE=             YES

The CPUTYPE variable tells gcc to optimize generated binary code for specified processor. In this case I am using 64bit Xeon processor architecture and “nocona” is the correct CPUTYPE to use. You may want to use “pentium4” on a typical Intel P4 CPU. A list of possible CPUTYPE values can be found in the sample make.conf file located at /usr/share/examples/etc/make.conf.

The CFLAGS variable indicates what parameters should be passed to gcc compiler when compiling typical programs such as ports or when building the whole operating system (i.e. buildworld process). I have been using this for a few years now and I haven’t experienced any issues in generated binaries.

The COPTFLAGS variables only applies to kernel builds. So if you need special compiler optimization for kernel, this is the variable you should consider using.

The KERNCONF tells system to compile one or more kernels based on the existing configuration files. In this example I have two kernels, first is GENERIC which is the default kernel file and exists in all systems by default and the other is the customized kernel configuration file called SERVER that I use on my typical servers. Both kernels will be built when running “make kernel“. The first will be installed and used as the default kernel.

Everything else here is some defaults to be used mostly for ports. They can be found by looking into ports Makefile or the default make.conf file at /usr/share/examples/etc/make.conf.

Tagged with:

7 Responses to make.conf in FreeBSD

  1. […] just posted a new article about make.conf in my other […]

  2. میلاد says:

    امیدوارم همیشه موفق باشی.

  3. Thanks Babak! useful post!

  4. argv says:

    Is there a way to tell make not to query the user with a sysinstall type screen? I’d like to have make accept all the defaults for each application. This way I can perhaps automate an install of a bunch of applications at once.

  5. tofumaster says:


    You mean suppression of the options dialog? There are several ways to do it, mainly by setting BATCH=yes. (e.g. in make.conf, or in your environment before running make.) Google it for more examples.

    (i.e. http://sonicchicken.net/blog/wordpress/20090111/batch-port-install/)

  6. Rogerio Soares says:

    Thanks Babak! useful very post!your book “Network Administration with FreeBSD 7” too is very useful, I recommend to all.

  7. Behzad says:

    Thanks Babak!