From 9edd5893d574e3b6778723714787fd5f3dd09524 Mon Sep 17 00:00:00 2001 From: Mattias Ellert Date: Tue, 18 Oct 2022 19:07:29 +0200 Subject: [PATCH] Fix Makefile logic - shared_lib_priority() checks that the shared library exist in LIBPL. No need to do the same check again when shared_lib_priority() is true. - check_static_library() should check that the static library exists. - Add LIBPL, but not LIBDIR, to RPATH. --- Makefile.PL | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 7d1a1b4..407451c 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -310,12 +310,6 @@ sub special_non_windows_check_shared_static_libs { if (shared_lib_priority($ref)) { $ref->{libpython} = $ref->{ldlib}; - my $shared_lib = File::Spec->catfile($ref->{libpath}, $ref->{libpython}); - if (!-f $shared_lib) { - # Special case for pyenv. The shared library exists in $LIBDIR instead of in - # $LIBPL - $ref->{libpath} = get_config_var($ref, "LIBDIR"); - } $ref->{rpath} = $ref->{libpath}; } else { @@ -340,9 +334,14 @@ sub special_non_windows_check_shared_static_libs { . "WARNING: This is known to not work on linux.\n"; } } - $ref->{libpath} = get_config_var($ref, "LIBDIR"); $ref->{libpython} = $ref->{ldlib}; - $ref->{rpath} = $ref->{libpath}; + my $shared_lib = File::Spec->catfile($ref->{libpath}, $ref->{libpython}); + if (!-f $shared_lib) { + $ref->{libpath} = get_config_var($ref, "LIBDIR"); + } + else { + $ref->{rpath} = $ref->{libpath}; + } } } } @@ -363,6 +362,9 @@ sub shared_lib_priority { sub check_static_library_ok { my ($ref) = @_; + my $static_lib = File::Spec->catfile($ref->{libpath}, $ref->{libpython}); + return 0 if (!-f $static_lib); + # We should check if the static library was compiled with -fPIC, or else # we cannot create a shared Python.so from it. # TODO: It seem like it is possible to build python with --enable-shared -- 2.37.3