AddThis Social Bookmark Button


make for Nonprogrammers
Pages: 1, 2

Understanding make config

You may be wondering what the difference is between make configure and make config. I've shown so far that make configure runs after several targets and may or may not require the user to interact with a dialog script.

In contrast, the config target is the first to run and always uses a dialog script to allow you to configure OPTIONS. Note that OPTIONS is uppercase on purpose; it refers to a make variable.

For example:

# cd /usr/ports/multimedia/xmms
# make config
===> No options to configure

That shouldn't be surprising, as the Makefile doesn't use any OPTIONS:

# grep -w OPTIONS /usr/ports/multimedia/xmms/Makefile

However, this Makefile does use this variable:

# grep OPTIONS /usr/ports/graphics/kdegraphics3/Makefile
OPTIONS=  IMLIB "Build Kuickshow, a fast and versatile image viewer" off \

Note that the trailing \ indicates that there are more options; to see more, change grep to grep -A 5 to see the five lines starting at (After) OPTIONS.

Now try:

# cd /usr/ports/graphics/kdegraphics3
# make config

A dialog script immediately opens, displaying all of the possible options. Those enabled in the Makefile will be on by default, whereas those tagged as off will not. Once you make your own selections and tab over to OK, you'll receive your prompt back, as make config is the first and only target to run.

Did you know that /var/db/ports/ saves your selected OPTIONS for you?

# more /var/db/ports/kdegraphics/options
# This file is auto-generated by 'make config'.
# No user-servicable parts inside!
# Options for kdegraphics-3.3.2_2

You can also view your selections from within the port's directory using the showconfig target:

# pwd

# make showconfig
===> The following configuration options are set for kdegraphics-3.3.2_2:
     IMLIB=off "Build Kuickshow, a fast and versatile image viewer"
     GPHOTO2=off "Enable support for digital cameras"
     SANE=off "Build Kooka, a SANE scanner frontend for KDE"

Should you change your mind, you can always rerun make config. Alternatively, remove the config options using:

# make rmconfig
===> Removing user-configured options for kdegraphics-3.3.2_2

# more /var/db/ports/kdegraphics/options
/var/db/ports/kdegraphics/options: No such file or directory

Your World's Makefile

Quick, what directory are you in when you issue a make command to upgrade the operating system or build a new kernel? There has to be a Makefile in that directory, or else your make command would fail. Take a look at it:

% more /usr/src/Makefile

This is an interesting Makefile that starts off mentioning targets you've probably used before, such as buildworld, buildkernel, installkernel, and installworld. However, search for Targets and you'll see this section:

# Targets that begin with underscore are internal targets intended for
# developer convenience only.  They are intentionally not documented and
# completely subject to change without notice.
TGTS=	all all-man buildkernel buildworld checkdpadd clean \
	cleandepend cleandir depend distribute distributeworld everything \
	hierarchy install installcheck installkernel installkernel.debug\
	reinstallkernel reinstallkernel.debug installworld \
	kernel-toolchain libraries lint maninstall \
	obj objlink regress rerelease tags toolchain update \
	_worldtmp _legacy _bootstrap-tools _cleanobj _obj \
	_build-tools _cross-tools _includes _libraries _depend

Note: It's one thing to try new make targets in the ports tree--the worst that can happen is you'll end up installing an application. However, if you have the urge to deviate from the targets described in the Handbook for safely upgrading the operating system or a kernel, practice on a test system that doesn't contain any data you'd miss should something go terribly wrong.

The rest of the Makefile describes the documented targets. There are a few interesting things to note. The Handbook cautions against using make world. This Makefile explains further:

# world
# Attempt to rebuild and reinstall everything. This target is not to be
# used for upgrading an existing FreeBSD system, because the kernel is
# not included. One can argue that this target doesn't build everything
# then.
	@echo "WARNING: make world will overwrite your existing FreeBSD"
	@echo "installation without also building and installing a new"
	@echo "kernel.  This can be dangerous.  Please read the handbook,"
	@echo "'Rebuilding world', for how to upgrade your system."
	@echo "Define DESTDIR to where you want to install FreeBSD,"
	@echo "including /, to override this warning and proceed as usual."
	@echo "You may get the historical 'make world' behavior by defining"
	@echo "HISTORICAL_MAKE_WORLD.  You should understand the implications"
	@echo "before doing this."
	@echo ""
	@echo "Bailing out now..."

This file also indicates that make kernel is really make buildkernel followed by make installkernel. That means that you could replace:

# make buildkernel KERNCONF=NEW && make installkernel KERNCONF=NEW


# make kernel KERNCONF=NEW

Note that the Makefile assumes GENERIC unless you specify another kernel with KERNCONF.

The last target I want to mention is make update. If you try typing that as is, you'll just receive your prompt back, meaning nothing happened. This is because this target reads the file /etc/make.conf to see exactly what you'd like to update.

On my test system, I already had cvsup up and running and had created a sup file in /root/cvs-supfile. So, I added these lines to /etc/make.conf:

SUP=			/usr/local/bin/cvsup
SUPFLAGS=		-g -L 2
SUPFILE=		/root/cvs-supfile

Note: In order for this to work, you must have cvsup-without-gui installed and have configured a SUPFILE at the specified location. If you've installed cvsup-without-gui but haven't yet created a SUPFILE, replace that SUPFILE line with these:

SUPFILE=		/usr/share/examples/cvsup/standard-supfile
PORTSSUPFILE=		/usr/share/examples/cvsup/ports-supfile
DOCSUPFILE=		/usr/share/examples/cvsup/doc-supfile

When filling in SUPHOST=, please choose a mirror geographically close to you. Also, review the three files in /usr/share/examples/cvsup to pick and choose which parts of the operating system, ports, and docs you wish to update.

When you've finished, run make update from /usr/src to update the specified sources.


Perhaps you've wondered how some people on the mailing lists knew about commands that went beyond make install. Today you found out what files they read to learn that information. Just remember, if you want to try out some new make targets for yourself, use a testing system and back up any data that is important to you first.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.

Managing Projects with GNU Make

Related Reading

Managing Projects with GNU Make
By Robert Mecklenburg

Return to the BSD DevCenter.