What I'm trying to achieve is build a package for program X that depends on library Y. Making another package for Y is not feasible because in this particular case X needs a very specific and/or outdated version of Y. So I want to construct the package template for X in such a way that it downloads and builds both distfiles for X and Y and then statically links them together so that the target system is not cluttered with library garbage.

I'm pretty sure I can make that work by copying files around in the working directory and patching the Makefile of X. It would be somewhat more elegant if I could "install" the statically compiled library of Y and its header-files to some temporary lib/include directory on the building system which would automatically be used when compiling X and afterwards cleaned.

I of course realize that this is a somewhat esoteric use-case but I thought I'd better ask before doing it manually :)