ext/rapngasm/extconf.rb in rapngasm-3.1.7 vs ext/rapngasm/extconf.rb in rapngasm-3.2.0.pre2
- old
+ new
@@ -1,13 +1,28 @@
-require 'rubygems'
-require 'mkmf-rice'
+require 'mkmf'
-$CFLAGS = '-x c++'
-$LOCAL_LIBS = '-lapngasm'
+return unless have_library('stdc++') # make sure we don't have some funny system
-dir_config 'apngasm'
+$stdout.write 'Checking for APNGAsm.'
+if have_library('apngasm')
+ $stdout.write 'APNGAsm found, building RAPNGAsm.'
+else
+ $stdout.write 'APNGAsm NOT found. Please install libapngasm.'
+ exit 1
+end
-# if have_header('apngasm.h')
-create_makefile 'rapngasm'
-# else
-# puts 'apngasm is not installed or the headers are not in the system path.'
-# end
+#find header location
+header_loc = `echo '#include <apngasm-conf.h>' | gcc -xc - -E`
+header_loc = header_loc.to_s.match(".*apngasm-conf\.h")
+header_loc = header_loc.to_s.match("\/.*\/")
+$stdout.write "\nAPNGAsm config header found in: #{header_loc.to_s}"
+
+dir_config('rapngasm')
+
+$stdout.write "\nGenerating native interface wrappers with SWIG\n"
+$stdout.write "Using SWIG from #{`which swig`}\n"
+$stdout.write "Generating wrapper sources from #{File.expand_path(File.dirname(__FILE__))}/apngasm.i\n"
+`swig -c++ -ruby -I#{header_loc.to_s} #{File.expand_path(File.dirname(__FILE__))}/apng.i`
+$stdout.write 'Wrappers generated'
+$distcleanfiles += ['apngasm_wrap.cxx']
+
+create_makefile('rapngasm')