Sha256: 010caa8ed84cb116c7b2aed367bd0b2b19675ec6cfadc3f0d621d106c2bbfbc2

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

require 'mkmf'

if with_config('static-libstdc++')
  $LDFLAGS << ' ' << `#{CONFIG['CC']} -print-file-name=libstdc++.a`.chomp
else
  have_library('stdc++')

  case RbConfig::CONFIG['host_os']
  when /mswin/
    # Avoid `error C7555: use of designated initializers requires at least '/std:c++20'`
    $CFLAGS << ' ' << '-std:c++20'
    $CPPFLAGS << ' ' << '-std:c++20'
    $CXXFLAGS << ' ' << '-std:c++20'
  when /solaris(!?2.11)/
    # Do a little trickery here to enable C++ standard on Solaris 11 if found.
    # This also forces 64bit compilation mode.
    $CXX = CONFIG['CXX']
    $CXX << ' ' << '-m64'
    $CFLAGS = CONFIG['CFLAGS'].gsub(/-std=c99/, '')
    $CFLAGS << ' ' << '-m64 -std=c++11'
    $CPPFLAGS = CONFIG['CFLAGS'].gsub(/-std=c99/, '')
    $CPPFLAGS << ' ' << '-m64 -std=c++11'
    $CXXFLAGS = CONFIG['CFLAGS'].gsub(/-std=c99/, '')
    $CXXFLAGS << ' ' << '-m64 -std=c++11'
  when /aix/
    # Compiler flags necessary on AIX.
    # rubocop:disable Style/GlobalVars
    $CFLAGS << ' ' << '-D_ALL_SOURCE=1'
    $CPPFLAGS << ' ' << '-D_ALL_SOURCE=1'
    $CXXFLAGS << ' ' << '-D_ALL_SOURCE=1'
  end
end

create_makefile 'unf_ext'

unless CONFIG['CXX']
  case CONFIG['CC']
  when %r{((?:.*[-/])?)gcc([-0-9.]*)$}
    cxx = $1 + 'g++' + $2
  when %r{((?:.*[-/])?)clang([-0-9.]*)$}
    cxx = $1 + 'clang++' + $2
  else
    cxx = CONFIG['CC']
  end

  warn "CXX is automatically set to #{cxx}"

  new_mf = <<-EOF << File.read('Makefile')
CXX=#{cxx}
  EOF

  File.open('Makefile', 'w') { |mf|
    mf.print new_mf
  }
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
unf_ext-0.0.9.1-x86-mingw32 ext/unf_ext/extconf.rb
unf_ext-0.0.9.1-x64-mingw32 ext/unf_ext/extconf.rb
unf_ext-0.0.9.1-x64-mingw-ucrt ext/unf_ext/extconf.rb
unf_ext-0.0.9.1 ext/unf_ext/extconf.rb
unf_ext-0.0.9-x86-mingw32 ext/unf_ext/extconf.rb
unf_ext-0.0.9-x64-mingw32 ext/unf_ext/extconf.rb
unf_ext-0.0.9-x64-mingw-ucrt ext/unf_ext/extconf.rb
unf_ext-0.0.9 ext/unf_ext/extconf.rb