Example of a port with a custom build { } script
Joshua Root
jmr at macports.org
Thu Nov 27 10:43:09 PST 2008
Ian Grant wrote:
> Hi All
>
> 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?
Please don't use the Tcl 'cd' command, it can cause problems with base
code that assumes that the working directory won't be changed behind its
back. It will disappear altogether in MacPorts 1.7.
> Just being able to read the default build { } script would be a good
> start. Where is that kept?
The default build phase code has some abstractions and special cases
which mean it isn't as clear as what you'd see in a Portfile, but you
can find it in /opt/local/share/macports/Tcl/port1.0/portbuild.tcl.
>From your description it sounds like you might just want to use
build.target-append and destroot.target-append to add the targets that
build and install the plugins. But if that's not possible, then you'd do
something like:
post-build {
system "cd ${worksrcpath}/plugin_subdir && make"
}
post-destroot {
system "cd ${worksrcpath}/plugin_subdir && make install"
}
(Possibly using a foreach loop if you have to do the same thing in
several subdirs.)
- Josh
More information about the macports-dev
mailing list