2016-05-04 16:54:51 +10:00
|
|
|
require 'mkmf'
|
2016-05-13 23:02:11 +03:00
|
|
|
require 'libv8'
|
2016-05-04 16:54:51 +10:00
|
|
|
|
2018-09-26 07:34:25 +08:00
|
|
|
IS_DARWIN = RUBY_PLATFORM =~ /darwin/
|
|
|
|
|
2016-05-04 16:54:51 +10:00
|
|
|
have_library('pthread')
|
2018-09-26 07:34:25 +08:00
|
|
|
have_library('objc') if IS_DARWIN
|
2016-05-04 16:54:51 +10:00
|
|
|
$CPPFLAGS += " -Wall" unless $CPPFLAGS.split.include? "-Wall"
|
|
|
|
$CPPFLAGS += " -g" unless $CPPFLAGS.split.include? "-g"
|
|
|
|
$CPPFLAGS += " -rdynamic" unless $CPPFLAGS.split.include? "-rdynamic"
|
2018-09-26 07:34:25 +08:00
|
|
|
$CPPFLAGS += " -fPIC" unless $CPPFLAGS.split.include? "-rdynamic" or IS_DARWIN
|
2016-05-04 16:54:51 +10:00
|
|
|
$CPPFLAGS += " -std=c++0x"
|
|
|
|
$CPPFLAGS += " -fpermissive"
|
|
|
|
|
2018-09-26 07:34:25 +08:00
|
|
|
$CPPFLAGS += " -Wno-reserved-user-defined-literal" if IS_DARWIN
|
|
|
|
|
2018-09-27 17:54:15 +03:00
|
|
|
$LDFLAGS.insert(0, " -stdlib=libc++ ") if IS_DARWIN
|
2016-05-14 18:59:50 +10:00
|
|
|
|
2016-05-14 17:00:40 +10:00
|
|
|
if ENV['CXX']
|
|
|
|
puts "SETTING CXX"
|
|
|
|
CONFIG['CXX'] = ENV['CXX']
|
|
|
|
end
|
|
|
|
|
2016-07-27 22:15:28 +03:00
|
|
|
CXX11_TEST = <<EOS
|
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
# error A compiler that supports at least C++11 is required in order to compile this project.
|
|
|
|
#endif
|
|
|
|
EOS
|
|
|
|
|
|
|
|
`echo "#{CXX11_TEST}" | #{CONFIG['CXX']} -std=c++0x -x c++ -E -`
|
|
|
|
unless $?.success?
|
|
|
|
warn <<EOS
|
|
|
|
|
|
|
|
|
|
|
|
WARNING: C++11 support is required for compiling mini_racer. Please make sure
|
|
|
|
you are using a compiler that supports at least C++11. Examples of such
|
|
|
|
compilers are GCC 4.7+ and Clang 3.2+.
|
|
|
|
|
2017-05-30 17:14:37 -04:00
|
|
|
If you are using Travis, consider either migrating your build to Ubuntu Trusty or
|
2016-07-27 22:15:28 +03:00
|
|
|
installing GCC 4.8. See mini_racer's README.md for more information.
|
|
|
|
|
|
|
|
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
2018-09-26 07:34:25 +08:00
|
|
|
CONFIG['LDSHARED'] = '$(CXX) -shared' unless IS_DARWIN
|
2016-05-04 16:54:51 +10:00
|
|
|
if CONFIG['warnflags']
|
|
|
|
CONFIG['warnflags'].gsub!('-Wdeclaration-after-statement', '')
|
|
|
|
CONFIG['warnflags'].gsub!('-Wimplicit-function-declaration', '')
|
|
|
|
end
|
2016-05-10 14:14:08 +10:00
|
|
|
|
2016-05-04 16:54:51 +10:00
|
|
|
if enable_config('debug')
|
2016-05-10 14:14:08 +10:00
|
|
|
CONFIG['debugflags'] << ' -ggdb3 -O0'
|
2016-05-04 16:54:51 +10:00
|
|
|
end
|
|
|
|
|
2016-05-13 23:02:11 +03:00
|
|
|
Libv8.configure_makefile
|
2016-05-04 16:54:51 +10:00
|
|
|
|
|
|
|
create_makefile 'mini_racer_extension'
|