Newbie Portfile writer question: what does "subport" do?

Joshua Root jmr at macports.org
Sat Jul 10 08:07:35 UTC 2021


On 2021-7-10 17:42 , Jim DeLaHunt wrote:
> Hi folks:
> 
> I'm trying to write my first Portfile, and I have a terribly naive 
> question: what does the "subport" directive in the Portfile do?

Please see <https://trac.macports.org/ticket/36957#comment:3>.

> And: How do the "subport" directives interact with what is defined at 
> the top level of the Portfile?  How do both the top level of the 
> Portfile and the subport blocks relate to a) fetching the source code 
> and b) configuring the source code and c) building the software and d) 
> installing the software?
> 
> Should I think of the top-level Portfile definitions and each subport as 
> being separate ports, each with their own fetch, configure, build, and 
> install activity? Or do the subports somehow modify the top-level 
> Portfile definitions for a single fetch, configure, build, and install 
> activity?

Both really. Each subport is added to the PortIndex as a distinct port. 
Any code not inside a subport block executes for all subports defined in 
the Portfile. They are separate ports that share part of their definition.

> I don't see the subport directive mentioned in the MacPorts Guide, 
> particularly not in Chapter 4. Portfile Development[1], nor in Chapter 
> 5. Portfile Reference[2]. I didn't see anything about subports authoring 
> in the Wiki either.

Indeed, see previously referenced ticket.

> FYI, I am working on a Portfile for ticket #62984 on port:freeciv [3]. 
> The upstream code can be configured to generate about 5 different sets 
> of client software, with about five different sets of dependencies. So 
> the concept is to make each set of client software a subport, and have a 
> base subport and an overarching port. But I don't know if this means six 
> fetches, configures, and builds, or one.

The former. All the subports will share a dist_subdir by default though, 
so you won't have to actually download 6 copies of the distfile.

- Josh

P.S. Please use the list address @lists.macports.org, not the old 
macosforge address.


More information about the macports-dev mailing list