]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper: use rpath for libxapian on NetBSD
authorEric Wong <e@80x24.org>
Mon, 4 Sep 2023 23:49:45 +0000 (23:49 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Sep 2023 03:01:44 +0000 (03:01 +0000)
While rpath is frowned upon by Debian and other distro packagers; it
appears embraced by in the world of NetBSD ports and packages.  This is
because ldconfig(8) on NetBSD doesn't put /usr/pkg/lib in its search
path by default.  This behavior differs from the ports and packaging
systems of FreeBSD and OpenBSD which do search library paths of
pkg*-installed packages (and presumably ports).

lib/PublicInbox/XapHelperCxx.pm

index a22dda1e26318d824108c0c5a58b2366b4f5ddc8..1c9a314f8dc7d5b0e0f22a451a07c88a16e125d6 100644 (file)
@@ -54,6 +54,15 @@ sub build () {
        my $cmd = "$pkg_config --libs --cflags xapian-core";
        chomp(my $fl = `$cmd`);
        die "$cmd failed: \$?=$?" if $?;
+
+       # Using rpath seems acceptable/encouraged in the NetBSD packaging world
+       # since /usr/pkg/lib isn't searched by the dynamic loader by default.
+       # Not sure if other OSes need this, but rpath seems fine for JAOT
+       # binaries (like this one) even if other distros discourage it for
+       # distributed packages.
+       $^O eq 'netbsd' and $fl =~ s/(\A|[ \t])\-L([^ \t]+)([ \t]|\z)/
+                               "$1-L$2 -Wl,-rpath=$2$3"/egsx;
+
        my $cxx = $ENV{CXX} // 'c++';
        $cmd = "$cxx $src $fl $xflags -o $tmp/$prog";
        system($cmd) and die "$cmd failed: \$?=$?";