The FreeBSD make.conf file

If you are like me, then you compile all of your software using the ports collection rather than use precompiled packages. You also probably recompile the kernel periodically to take advantage of new features or to patch a critical vulnerability that was reported.

One thing you can do to improve the performance and behavior of your ports is to update /etc/make.conf. This is where you can tell the compiler which optimizations should be used or what options should be used by default for various ports. This file also impacts the compilation of both the kernel and the ports so in one place, you can have a big impact on your system.

Typical make.conf

Below is an example make.conf that can be used for many systems:

CPUTYPE?=nocona

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

KERNCONF=       SERVER GENERIC

OPTIMIZED_CFLAGS=       YES
BUILD_OPTIMIZED=        YES
WITH_CPUFLAGS=          YES
WITHOUT_DEBUG=          YES
WITH_OPTIMIZED_CFLAGS=  YES
NO_PROFILE=             YES
BUILD_STATIC=		YES

The CPUTYPE variable tells gcc to optimize generated binary code for specified processor. In this case I am using Core I7 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.

Other Options

Some other options I use in my /etc/make.conf include:

NO_LPR=                 YES
NO_NIS=                 YES
CUPS_OVERWRITE_BASE=    YES

# SASL (cyrus-sasl v2) sendmail build flags...
SENDMAIL_CFLAGS=-I/usr/local/include/sasl -DSASL
SENDMAIL_LDFLAGS=-L/usr/local/lib
SENDMAIL_LDADD=-lsasl2

# Adding to enable alternate port (smtps) for sendmail...
SENDMAIL_CFLAGS+= -D_FFR_SMTP_SSL

WITH_NVIDIA_GL=YES
WITH_NVIDIA=YES
WITHOUT_NOUVEAU=YES

I use CUPS to print with instead of the FreeBSD LPR system. I don't use NIS or NIS+. The SENDMAIL lines let me use SASL for SMTP authentication. I use the proprietary NVIDIA driver and finally, the NOUVEAU line allowed me to get the later version of Mesa3d and libdrm per /usr/ports/UPDATING:

20100207:
  AFFECTS: users of Mesa3D libraries and x11-drivers/xf86-video-nouveau
  AUTHOR: nork@FreeBSD.org
  
  If you want to use Mesa3D 7.6.1 and libdrm 2.4.17 rather than 7.4.4
  and 2.4.12, you must define WITHOUT_NOUVEAU global macro, at least,
  enabled on graphics/libGL*, graphics/libglut, graphics/dri,
  graphics/mesa-demos, and graphics/libdrm.  And please give up using
  x11-drivers/xf86-video-nouveau.

I hope this helps and please let me know if you have any questions.