From: "Ara.T.Howard" Date: 2004-04-21T23:04:11+09:00 Subject: Re: C ext best practices On Tue, 20 Apr 2004, Tim Hunter wrote: > Well, I won't argue that it's "best practices" but here's what RMagick > does. RMagick assumes that the ImageMagick library, libMagick, has already > been installed in a separate step. > > RMagick uses the standard GNU ./configure, make, make install sequence. > The configure script (built by autoconf) handles any > non-Ruby configuration - such as finding libMagick - and builds a custom > Makefile, extconf.rb, and a metaconfig file for install.rb. The Makefile's > all: target runs install.rb's config and setup steps. The Makefile's > install: target runs install.rb's install step. > > Here's RMagick's Makefile.in. This will probably make it clearer than my > prose description. (The ./configure script also accepts a number of > options, like --with-std-ruby, that it passes on to install.rb via > @RUBY_CONFIG_OPTS@.) > > # Path to ruby interpreter > RUBY=@RUBY@ > > # Any extra options from configure script to pass to 'install.rb config' > RUBY_CONFIG_OPTS=@RUBY_CONFIG_OPTS@ > > all: config.save > $(RUBY) install.rb setup > > install: > $(RUBY) install.rb install > > clean: config.save > $(RUBY) install.rb clean > > distclean: config.save > $(RUBY) install.rb clean > rm -f Makefile ext/RMagick/extconf.rb metaconfig > rm -f config.status Makefile config.cache config.log > rm -rf autom4te.cache > > uninstall: config.save > $(RUBY) uninstall.rb $(RUBY_CONFIG_OPTS) > > config.save: metaconfig > $(RUBY) install.rb config $(RUBY_CONFIG_OPTS) very nice. 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. thoughts? -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================