Skip to content

Commit

Permalink
Install binary executable files to architecture dependent path
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Feb 18, 2024
1 parent 104100f commit 87c4c6c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
8 changes: 4 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3555,7 +3555,7 @@ AS_CASE("$enable_shared", [yes], [
RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ['-Wl,-soname,$(LIBRUBY_SONAME)' "$LDFLAGS_OPTDIR"])
LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)'
AS_IF([test "$load_relative" = yes], [
libprefix="'\$\${ORIGIN}/../${libdir_basename}'"
libprefix="'\$\${ORIGIN}/../${multiarch+../../}${libdir_basename}'"
LIBRUBY_RPATHFLAGS="-Wl,-rpath,${libprefix}"
LIBRUBY_RELATIVE=yes
])
Expand All @@ -3567,7 +3567,7 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_SO="$LIBRUBY_SO.\$(TEENY)"
LIBRUBY_ALIASES=''
], [test "$load_relative" = yes], [
libprefix="'\$\$ORIGIN/../${libdir_basename}'"
libprefix="'\$\$ORIGIN/../${multiarch+../../}${libdir_basename}'"
LIBRUBY_RPATHFLAGS="-Wl,-rpath,${libprefix}"
LIBRUBY_RELATIVE=yes
])
Expand All @@ -3591,7 +3591,7 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_ALIASES='$(LIBRUBY_SONAME) lib$(RUBY_SO_NAME).$(SOEXT)'
RUBY_APPEND_OPTIONS(LIBRUBY_DLDFLAGS, ["${linker_flag}-h${linker_flag:+,}"'$(@F)'])
AS_IF([test "$load_relative" = yes], [
libprefix="'\$\$ORIGIN/../${libdir_basename}'"
libprefix="'\$\$ORIGIN/../${multiarch+../../}${libdir_basename}'"
LIBRUBY_RPATHFLAGS="-R${libprefix}"
LIBRUBY_RELATIVE=yes
], [
Expand All @@ -3608,7 +3608,7 @@ AS_CASE("$enable_shared", [yes], [
LIBRUBY_SONAME='$(LIBRUBY_SO)'
LIBRUBY_ALIASES='lib$(RUBY_INSTALL_NAME).$(SOEXT)'
AS_IF([test "$load_relative" = yes], [
libprefix="@executable_path/../${libdir_basename}"
libprefix="@executable_path/../${multiarch+../../}${libdir_basename}"
LIBRUBY_RELATIVE=yes
])
LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS -install_name ${libprefix}"'/$(LIBRUBY_SONAME)'
Expand Down
10 changes: 7 additions & 3 deletions tool/mkrunnable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,22 @@
rubylibdir = config["rubylibdir"]
rubyarchdir = config["rubyarchdir"]
archdir = "#{extout}/#{arch}"
[bindir, libdir, archdir].uniq.each do |dir|
exedir = libdirname == "archlibdir" ? "#{config["libexecdir"]}/#{arch}/bin" : bindir
[exedir, libdir, archdir].uniq.each do |dir|
File.directory?(dir) or mkdir_p(dir)
end
unless exedir == bindir
ln_dir_relative(exedir, bindir)
end

exeext = config["EXEEXT"]
ruby_install_name = config["ruby_install_name"]
rubyw_install_name = config["rubyw_install_name"]
goruby_install_name = "go" + ruby_install_name
[ruby_install_name, rubyw_install_name, goruby_install_name].map do |ruby|
[ruby_install_name, rubyw_install_name, goruby_install_name].each do |ruby|
if ruby and !ruby.empty?
ruby += exeext
ln_relative(ruby, "#{bindir}/#{ruby}", true)
ln_relative(ruby, "#{exedir}/#{ruby}", true)
end
end
so = config["LIBRUBY_SO"]
Expand Down
40 changes: 30 additions & 10 deletions tool/rbinstall.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
rescue LoadError
$" << "zlib.rb"
end
require_relative 'lib/path'

INDENT = " "*36
STDOUT.sync = true
Expand Down Expand Up @@ -360,6 +361,13 @@ def CONFIG.[](name, mandatory = false)
goruby_install_name = "go" + ruby_install_name

bindir = CONFIG["bindir", true]
if CONFIG["libdirname"] == "archlibdir"
libexecdir = MAKEFILE_CONFIG["archlibdir"].dup
unless libexecdir.sub!(/\$\(lib\K(?=dir\))/) {"exec"}
libexecdir = "$(libexecdir)/$(arch)"
end
archbindir = RbConfig.expand(libexecdir) + "/bin"
end
libdir = CONFIG[CONFIG.fetch("libdirname", "libdir"), true]
rubyhdrdir = CONFIG["rubyhdrdir", true]
archhdrdir = CONFIG["rubyarchhdrdir"] || (rubyhdrdir + "/" + CONFIG['arch'])
Expand All @@ -384,22 +392,34 @@ def CONFIG.[](name, mandatory = false)
rdoc_noinst = %w[created.rid]

install?(:local, :arch, :bin, :'bin-arch') do
prepare "binary commands", bindir
prepare "binary commands", (dest = archbindir || bindir)

def (bins = []).add(name)
push(name)
name
end

install ruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
install bins.add(ruby_install_name+exeext), dest, :mode => $prog_mode, :strip => $strip
if rubyw_install_name and !rubyw_install_name.empty?
install rubyw_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
install bins.add(rubyw_install_name+exeext), dest, :mode => $prog_mode, :strip => $strip
end
# emcc produces ruby and ruby.wasm, the first is a JavaScript file of runtime support
# to load and execute the second .wasm file. Both are required to execute ruby
if RUBY_PLATFORM =~ /emscripten/ and File.exist? ruby_install_name+".wasm"
install ruby_install_name+".wasm", bindir, :mode => $prog_mode, :strip => $strip
install bins.add(ruby_install_name+".wasm"), dest, :mode => $prog_mode, :strip => $strip
end
if File.exist? goruby_install_name+exeext
install goruby_install_name+exeext, bindir, :mode => $prog_mode, :strip => $strip
install bins.add(goruby_install_name+exeext), dest, :mode => $prog_mode, :strip => $strip
end
if enable_shared and dll != lib
install dll, bindir, :mode => $prog_mode, :strip => $strip
install bins.add(dll), dest, :mode => $prog_mode, :strip => $strip
end
if archbindir
prepare "binary command links", bindir
relpath = Path.relative(archbindir, bindir)
bins.each do |f|
ln_sf(File.join(relpath, f), File.join(bindir, f))
end
end
end

Expand Down Expand Up @@ -690,7 +710,7 @@ class << (w = [])
install?(:dbg, :nodefault) do
prepare "debugger commands", bindir
prepare "debugger scripts", rubylibdir
conf = RbConfig::MAKEFILE_CONFIG.merge({"prefix"=>"${prefix#/}"})
conf = MAKEFILE_CONFIG.merge({"prefix"=>"${prefix#/}"})
Dir.glob(File.join(srcdir, "template/ruby-*db.in")) do |src|
cmd = $script_installer.transform(File.basename(src, ".in"))
open_for_install(File.join(bindir, cmd), $script_mode) {
Expand All @@ -707,9 +727,9 @@ class << (w = [])
install File.join(srcdir, ".gdbinit"), File.join(rubylibdir, "gdbinit")
if $debug_symbols
{
ruby_install_name => bindir,
rubyw_install_name => bindir,
goruby_install_name => bindir,
ruby_install_name => archbindir || bindir,
rubyw_install_name => archbindir || bindir,
goruby_install_name => archbindir || bindir,
dll => libdir,
}.each do |src, dest|
next if src.empty?
Expand Down

0 comments on commit 87c4c6c

Please sign in to comment.