From: Eric Wong Date: Mon, 4 Sep 2023 23:49:45 +0000 (+0000) Subject: xap_helper: use rpath for libxapian on NetBSD X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e0d801c4ace7675ba2accf75150e6790f6c6827;p=thirdparty%2Fpublic-inbox.git xap_helper: use rpath for libxapian on NetBSD 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). --- diff --git a/lib/PublicInbox/XapHelperCxx.pm b/lib/PublicInbox/XapHelperCxx.pm index a22dda1e2..1c9a314f8 100644 --- a/lib/PublicInbox/XapHelperCxx.pm +++ b/lib/PublicInbox/XapHelperCxx.pm @@ -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: \$?=$?";