From: Sean Chittenden Date: 2002-07-08T07:45:21+09:00 Subject: Re: [PATCH] lib/mkfm.rb: have_bin()/find_bin() --HeFlAV5LIbMFYYuh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline > This could be me over looking something, but in mkmf.rb, there is no > reliable way to test for an external binary, such as net-snmp-config, > which contains much of the linking/compiling information. Anyway, the > attached implements have_bin() and find_bin() methods. Comments? -sc Whoops, wrong patch (the other patch was for fix to a security error in resolv.rb that mod_ruby tickled: in case anyone was interested). The correct patch is attached. -sc -- Sean Chittenden --HeFlAV5LIbMFYYuh Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch Index: lib/mkmf.rb =================================================================== RCS file: /src/ruby/lib/mkmf.rb,v retrieving revision 1.87 diff -u -r1.87 mkmf.rb --- lib/mkmf.rb 2002/06/28 14:42:46 1.87 +++ lib/mkmf.rb 2002/07/07 22:42:25 @@ -351,6 +351,42 @@ return true end +def have_bin(bin) + printf "checking for %s... ", bin + STDOUT.flush + + path = ENV['PATH'].split(':') + for dir in path + file = File.join(dir, bin) + if FileTest.executable?(file) + print "yes\n" + return true + else + next + end + end + print "no\n" + return false +end + +def find_bin(bin) + printf "checking for %s... ", bin + STDOUT.flush + + path = ENV['PATH'].split(':') + for dir in path + file = File.join(dir, bin) + if FileTest.executable?(file) + print "yes\n" + return file + else + next + end + end + print "no\n" + return nil +end + def arg_config(config, default=nil) $configure_args.fetch(config, default) end --HeFlAV5LIbMFYYuh--