# List all dependencies in Makefiles



## Simpson (Nov 25, 2015)

`make all-depends-list` lists all build dependencies, run dependencies, lib dependencies, etc, and the dependencies of dependencies.

However, it does not include another type of dependency shown below.

Take the Makefile of dns/bind-tools as an example:


```
# $FreeBSD: head/dns/bind-tools/Makefile 397807 2015-09-25 10:05:48Z mat $

# Define PORTREVISION in ${MASTERDIR}
MASTERDIR=      ${.CURDIR}/../../dns/bind910
...
...
```

dns/bind910 is required to build dns/bind-tools.

How do I list or find out this type of dependency?

Thanks!


----------



## wblock@ (Nov 25, 2015)

That is actually not a dependency in this case.  dns/bind-tools is just a port that is built from the same source as dns/bind910.


----------



## Simpson (Nov 25, 2015)

I ran `make all-depends-list` for a port and it generates a list with dns/bind-tools only, without dns/bind910. Then I go ahead to download the source of the ports in the list and build them, however, it complains with errors that it cannot find ../../dns/bind910.

Since dns/bind910 is not one of the ports in the dependency list, how could I know that dns/bind910 and dns/bind-tools share the same source?


----------



## wblock@ (Nov 25, 2015)

Some combination of `make -V DISTFILES` and `make fetch-urlall-list`, possibly.


----------



## Simpson (Nov 25, 2015)

Take the Makefile of databases/postgresql94-server as another example:


```
# Created by: Marc G. Fournier <scrappy@FreeBSD.org>
# $FreeBSD: head/databases/postgresql94-server/Makefile 392696 2015-07-22 21:46:
27Z bapt $

DISTVERSION?= 9.4.4
...
...
.include "${.CURDIR}/../postgresql92-server/Makefile"
```

Both `make -V DISTFILES` and `make fetch-urlall-list` don't generate a list with databases/postgresql92-server. Neither does `make all-depends-list`.

What could I do about this?


----------



## tobik@ (Nov 25, 2015)

Simpson said:


> What could I do about this?


Nothing (edit: besides grepping for those .include lines of course). Why would it include databases/postgresql92-server?

If you think about ports as classes (as in Java or any other OOP language) databases/postgresql94-server is a subclass of databases/postgresql92-server with some methods/variables overridden to build another version of PostgreSQL because the basic recipe and options to build both of them are the same.

In other words the ports have a _is-a_ relationship with one another. The dependent ports of a port that you get with `make all-depends-list` form a _has-a_ relationship with that port instead i.e they are used as part of the recipe and do not make the recipe.


----------



## Simpson (Nov 25, 2015)

How do I get a list of ports which have a _is-a_ relationship with one another?


----------



## tobik@ (Nov 25, 2015)

Only idea I have is greping for the .include and MASTERDIR lines: `grep -Er '\.include \"\$\{.CURDIR}/../(.*)/Makefile\"' /usr/ports` and `grep -Er 'MASTERDIR=.*\$\{.CURDIR\}/\.\./' /usr/ports`


----------



## Simpson (Nov 25, 2015)

Are the following steps what I should do?

1. Download the source of the port (target)
2. Run `make all-depends-list` and download the source of the dependencies
3. Repeat step 2 until it resolves all dependencies
4. Run `grep -Er '\.include \"\$\{.CURDIR}/../(.*)/Makefile\"' /usr/ports` and `grep -Er 'MASTERDIR=.*\$\{.CURDIR\}/\.\./' /usr/ports` and download the source of the ports
5. Repeat step 4 until it resolves everything
6. Build the target port


----------



## tobik@ (Nov 26, 2015)

Simpson said:


> Are the following steps what I should do?


What are you trying to do?

If all you want to do is build the target port you just run `make` in the port's directory. If you want download all sources beforehand you run `make fetch-recusive`.


----------



## kpa (Nov 26, 2015)

It's not recommended to get only small parts of the ports tree. It is really meant to be fetched completely and updated completely to avoid situation where you have parts of the ports tree out of sync with the master copy at the SVN or portsnap(8) servers.


----------



## wblock@ (Nov 26, 2015)

Maybe `make fetch-recursive` is really all that is needed.


----------



## Simpson (Nov 26, 2015)

It seems that `make fetch-recursive` will not download the ports with Makefiles required for building the target port (see my examples above).

Should I always get the full ports tree even if I just need about 200 ports only?


----------



## phoenix (Nov 26, 2015)

Simpson said:


> It seems that `make fetch-recursive` will not download the ports with Makefiles required for building the target port (see my examples above).
> 
> Should I always get the full ports tree even if I just need about 200 ports only?



YES!  Period.  Full-stop.

The ports tree is designed to work as an integrated whole.  Either install the whole thing, or don't install any of it.  To do anything other than that will lead to all kinds of issues, and you'll spend longer trying to work around them than it would take to download the entire thing.


----------



## Simpson (Nov 28, 2015)

Thank you all for your replies.

We used to maintain a subset of ports, so we can tell if there's any updates that impact our ports.

Now the full ports tree is used, a list of dependency ports is not necessary any more. Take the same example in reply #5, how could I determine if any updates in databases/postgresql92-server may impact our port databases/postgresql94-server?


----------



## Simpson (Nov 30, 2015)

There're two questions here indeed. Let me clarify:

1. If there's an update to a port A whose Makefile is used by another port B, how could we determine if this update will impact port B or not? `pkg info` will list port B only and has no info about port A.

2. Take the example in reply #5. Why does databases/postgresql94-server include the Makefile of databases/postgresql92-server?


----------

