ext/extconf.rb in ruby-vpi-21.0.0 vs ext/extconf.rb in ruby-vpi-21.1.0

- old
+ new

@@ -1,6 +1,12 @@ # Generates a makefile for buiding the C extension. +# +# = Environment variables +# +# CFLAGS_EXTRA :: Provide additional options for the compiler. +# LDFLAGS_EXTRA :: Provide additional options for the linker. +# #-- # Copyright 2006 Suraj N. Kurapati # See the file named LICENSE for details. require 'mkmf' @@ -26,6 +32,29 @@ have_library(libName, RUBY_FUNC, libPath) end end # generate the makefile -create_makefile 'ruby-vpi' if hasRuby +if hasRuby + # apply additional arguments for compiler and linker + if flags = ENV['CFLAGS_EXTRA'] + $CFLAGS << " #{flags}" + end + + if flags = ENV['LDFLAGS_EXTRA'] + $LDFLAGS << " #{flags}" + end + + $CFLAGS << ' -Wall' + + # disable optimization when debugging + $CFLAGS << ' -g -O0' if $CFLAGS =~ /-DDEBUG\b/ + + # detect ruby version on behalf of C extension + v = RUBY_VERSION.split('.') + until v.empty? + $CFLAGS << " -DHAVE_RUBY_#{v.join '_'}" + v.pop + end + + create_makefile 'ruby-vpi' +end