require 'mkmf'

$CFLAGS = "-I../../include"

puts("checking ruby version ... #{RUBY_VERSION}")
if RUBY_VERSION > "1.6.8"
  $defs.push("-DRUBY_1_8_LATER")
end

begin
  print("checking gsl version ... ")
  IO.popen("gsl-config --version") do |f|
    ver = f.gets.chomp
    puts(ver)
    if ver >= "1.4.90"
      $defs.push("-DGSL_1_4_9_LATER")
    end
    if ver < "1.4"
    $defs.push("-DGSL_CONST_OLD")
    end
    if ver >= "1.3"
      $defs.push("-DGSL_1_3_LATER")
    end
  end
rescue
  raise("Check the command \"gsl-config\" is in search path.")
end

narray_config = dir_config("narray")
have_header("narray.h")
have_header("gsl_wavelet.h")

#cblas_config = dir_config("cblas")
#atlas_config = dir_config("atlas")

IO.popen("gsl-config --cflags") do |f|
  $CFLAGS += " -Wall " + f.gets.chomp
end

IO.popen("gsl-config --libs") do |f|
  $LOCAL_LIBS += " " + f.gets.chomp
end

=begin
require("ftools")
if narray_config[0] 
  File.cp("gsl-narray.rb", "../lib/gsl.rb")
else
  File.cp("gsl.rb", "../lib/gsl.rb")
end
=end

create_makefile("wavelet")
