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.

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.

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

# pwd
/usr/ports/graphics/kdegraphics3
# 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:

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.

#
# 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.
#
world:
@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

with:

# 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:

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:

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

Conclusion

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.