# Build file for the native C extension. # # = Environment variables # CFLAGS:: Arguments to the compiler. # LDFLAGS:: Arguments to the linker. =begin Copyright 2006 Suraj N. Kurapati This file is part of Ruby-VPI. Ruby-VPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Ruby-VPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Ruby-VPI; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. =end require 'rake/clean' require 'rbconfig' $:.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'ruby-vpi/rake' CFLAGS = [Config::CONFIG['CFLAGS'], ENV['CFLAGS'], '-g', '-DDEBUG'] LDFLAGS = [Config::CONFIG['LDFLAGS'], ENV['LDFLAGS']] desc "Builds the extension." task :default => 'Makefile' do |t| sh 'make', '-f', t.prerequisites[0] end file 'Makefile' => [:swig, 'extconf.rb'] do |t| ruby t.prerequisites[1], "--with-cflags=#{CFLAGS.join(' ')}", "--with-ldflags=#{LDFLAGS.join(' ')}" end CLEAN.include 'Makefile', 'mkmf.log', '*.o', '*.so' desc 'Generate Ruby wrapper for VPI.' task :swig => 'swig_wrap.cin' file 'swig_wrap.cin' => 'swig_vpi.i' do |t| sh %w{swig -ruby -o}, t.name, t.prerequisites[0] end file 'swig_vpi.i' => 'vpi_user.h' # NOTE: since SWIG is not a requirement for users, we should not clobber these generated files #CLOBBER.include 'swig_wrap.cin', 'swig_vpi.h'