Ports build parameters (knobs)

Maxim Khitrov mkhitrov at gmail.com
Wed Aug 22 06:32:38 PDT 2007


On 8/22/07, Gabriel Linder <linder at jeuxvideo.com> wrote:
> Hello,
>
> During the build of the graphical portion of my new FreeBSD-powered
> laptop I noticed that some knobs are not listed in /usr/ports/KNOBS and
> so, I can't add them to make.conf before building the packages.
>
> When I run "make fetch-recursive" for fluxbox, I get :
>
> WITH_DEBUG=yes          Build with debugging symbols
> WITH_DOCHTML=yes        Install the HTML documentation
> WITH_DOCPDF=yes         Install the PDF documentation
> WITH_GNOME=yes          Enable GNOME support
> WITH_IMLIB2=yes         Enable Imlib2 (pixmap themes) support
> [snip]
>
> and for libiconv :
>
> WITHOUT_EXTRA_ENCODINGS=yes     Disable extra character sets
> WITH_EXTRA_PATCHES=yes          Apply extra patches (fixes cp932, adds
> EUCJP-MS)
>
> GNOME and DEBUG are listed in /usr/ports/KNOBS, but IMLIB2 and
> EXTRA_PATCHES are not... Is there a way to have the full list of
> supported build options ? Or maybe I am wrong and these settings are not
> supposed to be in make.conf but in /var/db/ports/<portname>/options, if
> so please let me know :)

My experience has shown that it's always best to look at the Makefile
of any port you are about to install. That's the most reliable way to
learn about the port and the knobs it supports. However, this can be
rather tedious when installing something with a few hundred
dependencies (like gnome), so I actually came up with a solution to
speed things up.

First of all, you should install portconf from ports-mgmt and use it
to specify port-specific options. It's a much cleaner way of doing
things than using if statements in make.conf. You can also easily
transfer the configuration to other systems. In addition to
port-specific options, you can use * to set global knobs. Here's the
start of my ports.conf file just to give you an idea:

*:                            WITHOUT_BDB                |\
                              WITHOUT_DEBUG              |\
                              WITHOUT_DEBUGGING          |\
                              WITHOUT_IPV6               |\
                              WITHOUT_NLS                |\
                              WITHOUT_PROFILE            |\
                              WITH_OPTIMIZED_CFLAGS      |\
                              WITH_TTF_BYTECODE_ENABLED
converters/libiconv:          WITHOUT_EXTRA_ENCODINGS
lang/php5:                    WITHOUT_CGI                |\
                              WITH_MULTIBYTE

And so on... Now as far as actually discovering what knobs are
available, I wrote a simple script to do this. The contents are below,
save them as /usr/local/sbin/getknobs or something similar. The idea
is this; when you are about to install a port, run getknobs from the
port's directory. The script uses 'make missing' to determine all the
other ports that are about to be installed, then goes through their
port directories and searches all the files for WITH/WITHOUT_*
patterns. You then get a nice print out of all the knobs that you can
configure before running make install for the current port.

Since this script is using make missing you will not get the knobs for
ports that are already installed. The script was meant to be used from
the very beginning (i.e. starting from a clean system), so that on
each step you are only shown knobs for ports that aren't already
configured. You can easily modify this behavior if you want. You may
also need to adjust the regular expression used to find the knobs.

- Max

#!/bin/sh

cmd='make missing'
regex='WITH(OUT)?_[^[:space:]=)}\?]+'

dir=`pwd`
dir=`dirname $dir`
dir=`dirname $dir`

if [ "/usr/ports" != "$dir" ]; then
	echo 1>&2 "This script must be run for a port's directory."
	exit 1
fi

ports="`$cmd` `pwd | sed 's/\/usr\/ports\///'`"

for port in $ports; do
	knobs=`grep -Eho $regex /usr/ports/$port/* | sort | uniq`

	if [ -z "$knobs" ]; then
		continue
	fi

	echo "--- ${port}:"

	for knob in $knobs; do
		echo "    $knob"
	done

	echo
done


More information about the freebsd-questions mailing list