When working with FreeBSD ports, one frequent pain point is discovering hidden dependency chains. The standard make build-depends-list
only shows first-level dependencies, which can be misleading as demonstrated by the apache-ant
example where runtime dependencies were completely omitted from the initial output.
Here are three reliable ways to uncover the full dependency tree:
# Method 1: Using 'make all-depends-list'
make all-depends-list | sort -u
# Method 2: Recursive pkg-info approach (after installation)
pkg info -dRs apache-ant
# Method 3: Pre-build analysis with 'portmaster'
portmaster --show-work apache-ant
For complex scenarios, consider these approaches:
# Generate a visual dependency graph (requires graphviz)
cd /usr/ports/devel/apache-ant && make pretty-print-build-depends-list | \
grep '^/' | xargs -n 1 portgraph | dot -Tpng > dependencies.png
# JSON output for programmatic processing
make -V BUILD_DEPENDS -V RUN_DEPENDS -V LIB_DEPENDS -V \
EXTRACT_DEPENDS | jq -nR '[inputs | select(. != "")]'
Let's examine the actual dependency chain for apache-ant:
# Install ports-mgmt/pkg_tree first
pkg install pkg_tree
pkg_tree -r devel/apache-ant
# Output will show:
# └── devel/apache-ant
# ├── java/jdk16
# │ ├── math/gmp
# │ ├── devel/libpthread-stubs
# │ └── ...
# ├── devel/gamin
# │ ├── devel/glib20
# │ │ ├── converters/libiconv
# │ │ └── devel/gettext
# └── ...
- Use
make missing
to identify uninstalled dependencies - Combine with
portsclean -L
to remove orphaned dependencies later - For CI/CD pipelines, generate a complete inventory with
make all-depends-list | cut -d/ -f4- | sort -u > deps.txt
When working with FreeBSD ports, the dependency chain can often surprise you. Unlike package managers that show full dependency trees upfront, FreeBSD's ports system requires specific commands to reveal the complete picture.
# For build dependencies (what's needed to compile)
make build-depends-list
# For run dependencies (what's needed to execute)
make run-depends-list
# For all dependencies (both build and run)
make all-depends-list
The real magic happens when you trace dependencies recursively. Here's how to see the complete tree for apache-ant:
# Install ports-mgmt/pkgtree first
pkg install pkgtree
# Then run for any port
pkgtree -r devel/apache-ant
Alternatively, using make recursively:
make recursive-depends-list | sort -u
Let's examine why apache-ant pulls in unexpected dependencies like X11 libraries:
# First-level dependencies
$ make all-depends-list
/usr/ports/devel/apache-ant
/usr/ports/java/jdk16
/usr/ports/math/gmp
# Full recursive view (abbreviated)
$ pkgtree -r devel/apache-ant
devel/apache-ant
├── java/jdk16
│ ├── devel/gmake
│ ├── math/gmp
│ └── x11/libX11
└── devel/gmp
└── devel/libiconv
For developers needing even more control:
# Show dependencies with their origin
make -V BUILD_DEPENDS -V RUN_DEPENDS
# Export the complete dependency graph
make all-depends-list | xargs -n1 make all-depends-list
The initial build-depends-list
shows only direct build dependencies. Many ports (especially Java-related ones) have hidden runtime dependencies that only appear during installation or when checking with pkg info -d
.
- Always check both build and run dependencies
- Use
pkgtree
for visual representation - Consider
portmaster --show-work
before installation - For clean systems, use
pkg clean -a
after testing