Example of a port with a custom build { } script

Ryan Schmidt ryandesign at macports.org
Thu Nov 27 10:16:31 PST 2008


On Nov 27, 2008, at 11:05, Ian Grant wrote:

> I am trying to build a port which has a more complicated build  
> procedure than just 'make xxx' I have to first build and install  
> the main package and then go back into several subdirectories of  
> the build directory and build and install plugins.
>
> Can anyone point me to an example port which does something like  
> this? I guess I need to add a  post-destroot { } section to do  
> this. But how to change the working directory and run the make. Do  
> I just use the tcl 'cd' and 'exec' commands, or is there some  
> sophisticated error handling that I need to do?

Actually if you're wanting to "make" additional things, then that  
should happen in post-build, not post-destroot. Destroot is only for  
moving stuff that has already been built into the staging area. So  
maybe you need a post-build to build the plugins, and also a post- 
destroot to stage them. For the post-build, you would probably just  
use the tcl "system" command. You may not use the tcl "cd" command;  
it is deprecated and will not be in MacPorts 1.7.0 and later. You  
might do something like this:

set plugins {foo bar baz}

post-build {
	foreach plugin ${plugins} {
		system "cd ${worksrcpath}/plugins/${plugin} && make"
	}
}

post-destroot {
	foreach plugin ${plugins} {
		system "cd ${worksrcpath}/plugins/${plugin} && make install"
	}
}

Or you might consider fixing their existing Makefile so that it  
installs the plugins, and contributing that change back to the  
authors of the software. Then the Portfile becomes simpler.

> Just being able to read the default build { } script would be a  
> good start. Where is that kept?

That's probably a lot more complicated than you need but it's here:

http://trac.macports.org/browser/trunk/base/src/port1.0/portbuild.tcl



More information about the macports-dev mailing list