That variable - I only see it being used, but not defined anywhere.
That could be another reason for the wrong link.
I do not understand it well enough - not tested, as I said.
and I will not test it …
All of the above variables such as $pkgname and $pkgver are available for use in the packaging functions. In addition, makepkg defines the following variables:
This contains the directory where makepkg extracts, or copies, all source files.
All of the packaging functions defined above are run starting inside $srcdir
This contains the directory where makepkg bundles the installed package. This directory will become the root directory of your built package. This variable should only be used in the package() function.