diff --git a/Rakefile b/Rakefile index 44924b7..630590a 100644 --- a/Rakefile +++ b/Rakefile @@ -7,6 +7,28 @@ Rake::TestTask.new do |t| t.test_files = FileList["test/**/t_*.rb"] end -task :gem do +desc "Create the size_t size macro for c_struct" +file 'lib/linux/c_struct_sizeof_size_t.rb' do |t| + begin + sz = Integer(`echo __SIZEOF_SIZE_T__ | /usr/bin/gcc -E -P -`) + File.open(t.name, 'w+') do |fh| + fh.puts "module Linux ; class CStruct ; SIZEOF_SIZE_T = #{sz} ; end ; end" + end + rescue + rm_f t.name + end +end + +desc "Package a gem" +task :gem do + # + # FIXME. If using a gem, fall back on GCC to determine sizeof size_t. + # + rm_f "lib/linux/c_struct_sizeof_size_t.rb" sh "gem build netlinkrb.gemspec" end + +desc "clean up" +task :clean do + rm_f "lib/linux/c_struct_sizeof_size_t.rb" +end diff --git a/debian/changelog b/debian/changelog index 769d925..e35e4c1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +linux-netlink-ruby (0.10-4) unstable; urgency=low + + * Removed dependency on gcc, in favour of having arch-dependent packages + which rely on build-time ascertation of sizeof size_t. + + -- Patrick J Cherry Tue, 24 Jan 2012 15:56:46 +0000 + linux-netlink-ruby (0.10-3) unstable; urgency=low * Updated version number to cover the previous changes. diff --git a/debian/control b/debian/control index 18f7c77..4688a24 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Maintainer: Matthew Bloch Uploaders: Patrick J Cherry Section: ruby Priority: optional -Build-Depends: debhelper (>= 7), cdbs, ruby1.8, ruby1.9.1, ruby-pkg-tools +Build-Depends: debhelper (>= 7), cdbs, ruby1.8, ruby1.9.1, ruby-pkg-tools, rake Standards-Version: 3.8.0 Package: liblinux-netlink-ruby @@ -17,8 +17,8 @@ Description: Netlink socket library for Ruby This is the metapackage for all versions of Ruby. Package: liblinux-netlink-ruby1.8 -Architecture: all -Depends: ruby1.8 (>= 1.8.7), libffi-ruby1.8, gcc, ${misc:Depends} +Architecture: any +Depends: ruby1.8 (>= 1.8.7), libffi-ruby1.8, ${misc:Depends} Description: Netlink socket library for Ruby 1.8 This library provides an API for using a Linux Netlink socket, for doing things like manipulating IP interfaces and routes programmatically, and @@ -28,8 +28,8 @@ Description: Netlink socket library for Ruby 1.8 Package: liblinux-netlink-ruby1.9.1 -Architecture: all -Depends: ruby1.9.1, libffi-ruby1.9.1, gcc, ${misc:Depends} +Architecture: any +Depends: ruby1.9.1, libffi-ruby1.9.1, ${misc:Depends} Description: Netlink socket library for Ruby 1.9.1 This library provides an API for using a Linux Netlink socket, for doing things like manipulating IP interfaces and routes programmatically, and diff --git a/debian/rules b/debian/rules index 4616b2f..bf1db75 100755 --- a/debian/rules +++ b/debian/rules @@ -4,3 +4,8 @@ include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/ruby-pkg-tools/1/class/ruby-setup-rb.mk +makebuilddir:: + rake lib/linux/c_struct_sizeof_size_t.rb + +clean:: + rake clean diff --git a/lib/linux/c_struct.rb b/lib/linux/c_struct.rb index 28375e2..9f6b606 100644 --- a/lib/linux/c_struct.rb +++ b/lib/linux/c_struct.rb @@ -79,7 +79,13 @@ class CStruct define_type :ns, :pattern => "n", :align => true define_type :nl, :pattern => "N", :align => true - SIZEOF_SIZE_T = Integer(`echo __SIZEOF_SIZE_T__ | gcc -E -P -`) rescue 1.size + begin + require 'linux/c_struct_sizeof_size_t.rb' + rescue LoadError + warn "Falling back to gcc to determine sizeof size_t." if $VERBOSE + SIZEOF_SIZE_T = Integer(`echo __SIZEOF_SIZE_T__ | gcc -E -P -`) rescue 1.size + end + define_type :size_t, case SIZEOF_SIZE_T when 8