Skip to content

Commit 5652e32

Browse files
committed
Make a static library from PIC object files
On some platforms, PIC and non-PIC code are incompatible and the latter cannot be used for shared objects.
1 parent ecb6b96 commit 5652e32

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

ext/psych/depend

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ $(TARGET_SO): $(LIBYAML)
22

33
libyaml $(LIBYAML):
44
cd libyaml && $(MAKE)
5+
$(AR) $(ARFLAGS) $(LIBYAML) $(LIBYAML_OBJDIR)/*.$(OBJEXT)
6+
$(RANLIB) $(LIBYAML)
7+
58
clean-so::
69
-cd libyaml && $(MAKE) clean
10+
711
distclean-so::
812
-cd libyaml && $(MAKE) distclean
913
-$(Q)$(RMDIRS) libyaml/* libyaml

ext/psych/extconf.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@
3939
puts("Configuring libyaml source in #{yaml_source.quote}")
4040
yaml = "libyaml"
4141
Dir.mkdir(yaml) unless File.directory?(yaml)
42+
shared = $enable_shared || !$static
4243
unless system(yaml_configure, "-q",
43-
"--enable-#{$enable_shared || !$static ? 'shared' : 'static'}",
44+
"--enable-#{shared ? 'shared' : 'static'}",
4445
"--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-')}",
4546
*(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
4647
chdir: yaml)
@@ -50,12 +51,16 @@
5051
inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
5152
$INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
5253
Logging.message("INCLFAG=#$INCLFAG\n")
53-
libyaml = "#{yaml}/src/.libs/libyaml.#$LIBEXT"
54+
libyaml = "libyaml.#$LIBEXT"
55+
$cleanfiles << libyaml
5456
$LOCAL_LIBS.prepend("$(LIBYAML) ")
5557
end
5658

5759
create_makefile 'psych' do |mk|
5860
mk << "LIBYAML = #{libyaml}".strip << "\n"
61+
mk << "LIBYAML_OBJDIR = libyaml/src#{shared ? '/.libs' : ''}\n"
62+
mk << "OBJEXT = #$OBJEXT"
63+
mk << "RANLIB = #{config_string('RANLIB') || config_string('NULLCMD')}\n"
5964
end
6065

6166
# :startdoc:

0 commit comments

Comments
 (0)