Managing ports in FreeBSD using make

make is a native tool which is used to manage ports in FreeBSD. We can download ports source code, configure its compilation process, watch port dependencies (both build and run dependencies), check its checksum and finally install the ports.

Let’s assume that we take as an example nano text editor. Perform whereis command and go to port directory:

whereis nano  ## output: /usr/ports/editors/nano
cd /usr/ports/editors/nano

Then we can download its archive with source codes and extract them. fetch and extract commands are used for this purpose. We can use them separately, but if used together, it will be faster. The archive with source codes will be downloaded to /usr/ports/distfiles directory. Source codes will be extracted to the directory with the port itself (/usr/ports/editors/nano/work/nano-4.2/):

sudo make fetch extract

Checksums are checked by default, so the files will not be damaged (and it will be re-downloaded it if it is damaged). But if their checksums was disabled manually, we can inspect the checksums of the port with the following command. This will inspect checksums of the source code archive that was downloaded to /usr/ports/distfiles/ directory:

sudo make checksum

To configure the compilation process (config OPTIONS) only for the port we need to use config command. This allows us to choose which documentation, plugins, and optional dependencies should be built for the port:

sudo make config

The following command allows us to do the same, but for dependencies:

sudo make config-recursive

Two commands to show config OPTIONS. showconfig shows config options for the port itself. showconfig-recursive shows config options for the port and dependencies:

sudo make showconfig
sudo make showconfig-recursive

Config OPTIONS can be removed exclusively for the port (the first command), or for the port and its dependencies (the second command):

sudo make rmconfig
sudo make rmconfig-recursive

To show direct ftp://, http:// links and their mirrors to archives with source codes of the port and its dependencies, use the following command:

sudo make fetch-recursive-list

We can print a list of dependencies. built-depends are dependencies that are required to build a port. run-depends are dependencies which a program needs during the work, when it is already builted:

sudo make built-depends-list
sudo make run-depends-list
sudo make all-depends-list   # It's like the two previous commands together.

The following two commands require INDEX file. We can download this from FreeBSD cluster by fetchindex command. Now we have several other commands to use with make.

pretty-print-build-depends-list and pretty-print-run-depends-list commands show port dependencies and dependencies of the port dependencies. WOW…:

cd /usr/ports
sudo make fetchindex
ls -lh /usr/ports/INDEX-12   # ~40 megabytes, 12 means FreeBSD 12.0-RELEASE which is actual in current time of this article
cd /usr/ports/editors/nano     #  We need to go back to the port directory.
sudo make pretty-print-build-depends-list
sudo make pretty-print-run-depends-list

List of dependencies that were not installed for a port. It is useful when something went wrong within installation process:

sudo make missing

Remove extracted source codes and object files, executable files and other files that remained after a port was compiled. Port directory will become clean again:

sudo make clean

Remove source code archive of a port that stores in /usr/ports/distfiles directory when fetched:

sudo make distclean

Create README.html file in a port directory. It contains some info about a port, port dependencies and other:

sudo make readmes

Print port description:

sudo make describe

Print maintainer’s email:

sudo make maintainer

Note, commands can be combined in one line:

sudo make install clean

Leave a Reply

Your email address will not be published.