blob: 1179995c4939e9ec706e6ff4f4c0c18c3bbc7bb8 [file] [log] [blame]
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
require 'rbconfig'
def rbconfig
RbConfig::CONFIG
end
def all_ccflags
ccflags = '-DCFCRUBY '
if defined?(rbconfig["ARCH_FLAG"])
ccflags += rbconfig['ARCH_FLAG'] + ' '
end
if defined?(rbconfig["CFLAGS"])
ccflags += rbconfig['CFLAGS'] + ' '
end
if ENV.has_key?('CFLAGS')
ccflags += ENV['CFLAGS']
end
# Compile as C++ under MSVC. Turn off stupid warnings, too.
if cc_command =~ /^cl\b/
ccflags += '/TP -D_CRT_SECURE_NO_WARNINGS '
end
# Blindly include GCC-specific flags even though we don't know that the
# compiler is GCC.
if ccflags !~ /-std=/
ccflags += "-std=gnu99 "
end
if ccflags !~ /-D_GNU_SOURCE/
ccflags += "-D_GNU_SOURCE "
end
return ccflags
end
def cc_command
rbconfig["CC"]
end
def extra_ccflags
ccflags = '-DCFCRUBY '
if defined?(rbconfig["ARCH_FLAG"])
ccflags += rbconfig['ARCH_FLAG'] + ' '
end
if defined?(rbconfig["CFLAGS"])
ccflags += rbconfig['CFLAGS'] + ' '
end
if ENV.has_key?('CFLAGS')
ccflags += ENV['CFLAGS']
end
# Compile as C++ under MSVC. Turn off stupid warnings, too.
if cc_command =~ /^cl\b/
ccflags += '/TP -D_CRT_SECURE_NO_WARNINGS '
end
# Blindly include GCC-specific flags even though we don't know that the
# compiler is GCC.
if ccflags !~ /-std=/
ccflags += "-std=gnu99 "
end
if ccflags !~ /-D_GNU_SOURCE/
ccflags += "-D_GNU_SOURCE "
end
return ccflags
end
def make_command
command = rbconfig["make-prog"]
if !command
if RUBY_PLATFORM =~ /mswin/i
if cc_command =~ /^cl\b/
command = "nmake"
end
end
end
if !command
command = 'make'
end
return command
end
def run_make(dir, params)
current_dir = Dir.pwd
chdir(dir) if dir
command = params.clone
command.unshift("CC=#{cc_command}")
if RUBY_PLATFORM =~ /(mswin|mingw)/i
if cc_command =~ /^cl\b/
command.unshift("-f", "Makefile.MSVC")
else
command.unshift("-f", "Makefile.MinGW")
end
end
command.unshift(make_command)
success = system(*command)
if !success
raise "Make failed"
end
chdir(current_dir) if dir
end
def quotify(string)
return '"' + string.gsub(/([\\\"])/,'\\\\\\1') + '"'
end
def autogen_header
"
***********************************************
!!!! DO NOT EDIT !!!!
This file was auto-generated by Rakefile.
***********************************************
"
end