Skip to content

Commit

Permalink
Merge pull request #554 from nobu/link-pic-objects
Browse files Browse the repository at this point in the history
Make a static library from PIC object files
  • Loading branch information
nobu authored Mar 31, 2022
2 parents ecb6b96 + 5652e32 commit bf9908d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ext/psych/depend
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ $(TARGET_SO): $(LIBYAML)

libyaml $(LIBYAML):
cd libyaml && $(MAKE)
$(AR) $(ARFLAGS) $(LIBYAML) $(LIBYAML_OBJDIR)/*.$(OBJEXT)
$(RANLIB) $(LIBYAML)

clean-so::
-cd libyaml && $(MAKE) clean

distclean-so::
-cd libyaml && $(MAKE) distclean
-$(Q)$(RMDIRS) libyaml/* libyaml
Expand Down
9 changes: 7 additions & 2 deletions ext/psych/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
puts("Configuring libyaml source in #{yaml_source.quote}")
yaml = "libyaml"
Dir.mkdir(yaml) unless File.directory?(yaml)
shared = $enable_shared || !$static
unless system(yaml_configure, "-q",
"--enable-#{$enable_shared || !$static ? 'shared' : 'static'}",
"--enable-#{shared ? 'shared' : 'static'}",
"--host=#{RbConfig::CONFIG['host'].sub(/-unknown-/, '-')}",
*(["CFLAGS=-w"] if RbConfig::CONFIG["GCC"] == "yes"),
chdir: yaml)
Expand All @@ -50,12 +51,16 @@
inc = yaml_source.start_with?("#$srcdir/") ? "$(srcdir)#{yaml_source[$srcdir.size..-1]}" : yaml_source
$INCFLAGS << " -I#{yaml}/include -I#{inc}/include"
Logging.message("INCLFAG=#$INCLFAG\n")
libyaml = "#{yaml}/src/.libs/libyaml.#$LIBEXT"
libyaml = "libyaml.#$LIBEXT"
$cleanfiles << libyaml
$LOCAL_LIBS.prepend("$(LIBYAML) ")
end

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

# :startdoc:

0 comments on commit bf9908d

Please sign in to comment.