4. Build systems

4.1. Synopsis

FreeBSD employs a number of well-written, intelligent and efficient build processes to ease development. These systems build the kernel, build the user-land programs, the documentation, the web site, and even generate the release that is shipped on CDs and the ftp site.

These systems are powered by Berkeley Make, with some nifty and elegant macros and variables. This means that all the above tasks can be achieved in one command, and most are extremely easy to use and customize.

4.2. world

make world is probably one of the main reasons people who like FreeBSD like FreeBSD. With one command, the entire bunch of commands, libraries, and utilities are rebuilt, and installed.

Actually, most people use two commands, make buildworld and make installworld. These commands accept make variables like NO_SENDMAIL which customize which utilities are built and installed.

There is a good explanation of using make world to rebuild your system in the FreeBSD handbook.

4.3. ports

The ports system is one of the other things that set FreeBSD (and NetBSD and OpenBSD to a lesser degree) apart. With over 3000 ports in the collection, it consists of a set of targets, macros, and variables that combine with "port skeletons" to build and install programs on a FreeBSD system.

Ports first download all necessary original virgin source tarballs, applies the set of patches kept in the ports skeleton, configures the build, builds the software, and installs it. After installation, the ports install is recorded in the local package database. Packages can be generated with the package target, which can be directly installed onto other systems using pkg_add.

The power of the ports system is hard to comprehend without an example:

Example 4. Ports example - screen

    DISTNAME=       screen-3.9.5
    CATEGORIES=     misc
    MASTER_SITES=   ftp://ftp.uni-erlangen.de/pub/utilities/screen/ \
                    ${MASTER_SITE_GNU}
    MASTER_SITE_SUBDIR=     screen
    
    MAINTAINER=     ache@FreeBSD.org
    
    GNU_CONFIGURE=  yes
    MAN1=           screen.1
    
    post-install:
            @install-info ${PREFIX}/info/screen.info ${PREFIX}/info/dir
    
    .include <bsd.port.mk>
        

This ports Makefile says to get screen-3.9.5.tar.gz from one of the MASTER_SITES (which includes a large number of gnu mirrors in this case), and configures it using GNU configure.

The MAINTAINER variable indicates that ache@FreeBSD.org is the person responsible for the port, and the contact address if the port needs updating or fixing.

There is a lot more to that, and this is a very simple example. The FreeBSD Handbook has a section on ports which explains it better, and also how to make your own.

4.4. doc and www

FreeBSD documentation, and the FreeBSD web site, use the same sort of system to build themselves, converting the SGML and other formats to produce HTML (for the web site), postscript, TeX, rtf, and other formats.

The HTML is kept on the web site, and the other formats are available on the FreeBSD ftp site.

4.5. release

The release target allows one to generate an entire release, packed with all the documentation, floppies (boot, root, and fixit), kernels, CD and ftp distributions.