Best practice for extracting information from a makefile
Michael Schwendt
mschwendt at gmail.com
Tue Aug 16 16:27:08 UTC 2011
On Tue, 16 Aug 2011 10:38:43 -0500, RS (Richard) wrote:
> > cd %{buildroot}%{libdir}
> > ldconfig -n $(pwd)
> > ln -s %{name}.so.? %{name}.so
> > cd -
>
> Wouldn't that create a symlink of a symlink?
That isn't a problem, is it? All that matters is that the final symlink would
point at a usable library the build-time linker can load
libfoo.so -> libfoo.so.1 > libfoo.so.1.0.0
and ldconfig adjusts libfoo.so.1 to point at the latest version anyway.
Or just the direct:
libfoo.so -> libfoo.so.1.0.0
Both types of symlinks exist in Fedora packages.
You could
shopt -s failglob
ln -s %{name}.so.*.* %{name}.so
enforcing existence of a fully versioned library, and else an error.
All that matters is that the final symlink would point at a usable
library.
> I ended up doing it this way:
>
> # Extract library name from Makefile
> LIBNAME=$(make -f Makefile -f - <<<'lib_so:; @echo $(lib_so)' lib_so)
>
> # Create symbolic link for -devel subpackage.
> ldconfig -n %{buildroot}%{_libdir}
> pushd %{buildroot}%{_libdir}
> ln -s $LIBNAME %{name}.so
> popd
Enjoy it if it works for you. :)
Note though that if the make command fails, you would end up with an
empty $LIBNAME and a %{name}.so -> %{name}.so most likely, so some guard
in the spec file would be beneficial.
More information about the devel
mailing list