From: nobu.nokada@... Date: 2004-04-22T04:14:06+09:00 Subject: Re: C ext best practices Hi, At Wed, 21 Apr 2004 23:04:11 +0900, Ara.T.Howard wrote in [ruby-talk:97854]: > i guess i'm thinking more along the lines of smallish packages, and would like > avoid having site_ruby/1.8/i686/foobar.so depend on > /usr/local/lib/libfoobar.so.... (i just had a bad experience supporting some > software that required LD_RUN_PATH to manage dependancies). it would be ideal > if > > foobar.so > > was the result of compiling > > foobar.c # original C source > _foobar.c # ruby binding to it > > obviously this wouldn't apply to packages likely to be updated independently > (like ImageMagick) but might be o.k. for smallish things like cdb, lockfile > utils, etc. Though, makefile created by configure and one created by extconf.rb, could conflict. I think you would have to separate the directories. One thought (but not tested), ---------- depend: $(DLLIB): src/foobar.$(LIBEXT) src/foobar.$(LIBEXT): $(RUBY) -C "$(@D)" -e "exec *ARGV" $(MAKE) $(MFLAGS) $(@F) ---------- extconf.rb: topdir = Dir.pwd IO.foreach(File.join($srcdir, "depend")) do |line| /\$\(DLLLIB\):\s*(.*\.\$\(LIBEXT\))/ =~ line or next lib = $1 subdir = File.dirname(lib) Dir.mkdir(subdir) rescue nil Dir.chdir(subdir) do srcdir = $srcdir unless File.expand_path(srcdir, topdir) == File.expand_path(srcdir) srcdir = File.join("..", srcdir) end system(File.join(srcdir, "configure"), *ARGV) or exit end $LOCAL_LIBS << " " + lib end create_makefile("foobar") -- Nobu Nakada