about summary refs log tree commit homepage
path: root/lib/PublicInbox/XapHelperCxx.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-04 23:49:45 +0000
committerEric Wong <e@80x24.org>2023-09-05 03:01:44 +0000
commit6e0d801c4ace7675ba2accf75150e6790f6c6827 (patch)
tree7fd74795f6cea617ea0e4c7af270b1b91e9d3aed /lib/PublicInbox/XapHelperCxx.pm
parentb914e67f82eeeadc223d2ba0f7c2ad5979819b02 (diff)
downloadpublic-inbox-6e0d801c4ace7675ba2accf75150e6790f6c6827.tar.gz
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).
Diffstat (limited to 'lib/PublicInbox/XapHelperCxx.pm')
-rw-r--r--lib/PublicInbox/XapHelperCxx.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/PublicInbox/XapHelperCxx.pm b/lib/PublicInbox/XapHelperCxx.pm
index a22dda1e..1c9a314f 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: \$?=$?";