-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
extconf.rb
55 lines (48 loc) · 1.49 KB
/
extconf.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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