pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Set install_name to fix devel/mustach on macOS



Sijmen Mulder <ik%sjmulder.nl@localhost> writes:

>> Longer term, it would be nice to have some higher-level declarative
>> workaround.  I suppose this is either a bug in upstreams or a bug in
>> macos (is install_name covered by any standards?) depending on how you
>> look at it :-)

What I mean is to have some pkgsrc mechanism to set a variable like

MACOS_INSTALL_NAME_LIBS+=	lib/libmustach.so

and have pkgsrc automatically do what you have done in the patch.  I'm
not sure how many cases there are where upstream doesn't do the
macos-right thing.

> It's used to add the installed library's location to the list of library
> search paths of macOS binaries (at link time):
>
>   An install name is just a pathname embedded within a dynamic library
>   which tells the linker where that library can be found at runtime.
>   For example, libfoo.dylib might have an install name of
>   /usr/lib/libfoo.dylib. This install name gets copied into the
>   application at link time. When the dynamic linker goes looking for
>   libfoo.dylib at runtime, it will fetch the install name out of the
>   application and know to look for the library in /usr/lib.
>
> https://www.mikeash.com/pyblog/friday-qa-2009-11-06-linking-and-install-names.html
>
> So it's a different mechanism, one any install target for projects
> wanting to support macOS should account for (so yes, upstream).

Good luck with upstreams!

> Index: devel/mustach/Makefile
> ===================================================================
> RCS file: /cvsroot/pkgsrc/devel/mustach/Makefile,v
> retrieving revision 1.2
> diff -u -r1.2 Makefile
> --- devel/mustach/Makefile	25 Dec 2019 17:34:31 -0000	1.2
> +++ devel/mustach/Makefile	27 Dec 2019 18:46:58 -0000
> @@ -15,5 +15,15 @@
>  # Workaround is portable, might as well use it everywhere.
>  CFLAGS+=	-DNO_OPEN_MEMSTREAM
>  
> +# install_name must be set on macOS. Upstream PR:
> +# https://gitlab.com/jobol/mustach/merge_requests/16
> +.if ${OPSYS} == "Darwin"
> +.PHONY: fix-darwin-install-name
> +post-install: fix-darwin-install-name
> +fix-darwin-install-name:
> +	install_name_tool -id ${PREFIX}/lib/libmustach.so \
> +	    ${DESTDIR}${PREFIX}/lib/libmustach.so
> +.endif
> +
>  .include "../../textproc/json-c/buildlink3.mk"
>  .include "../../mk/bsd.pkg.mk"

Interesting that it is .so and not .dylib.

Assuming you actually built the package and built some depending package
that worked, that looks fine -- please go ahead and commit it.


Home | Main Index | Thread Index | Old Index