Re: [Rhythmbox-devel] Officially adding ./configure option?

On Wed, Feb 22, 2006 at 11:21:03AM +0000, Jack Miller wrote:
> I'm writing a completely extraneous patch for Rhythmbox and want to make
> it not only optional but also include libraries that vanilla Rhythmbox
> doesn't require (i.e. libsexy).

The typical approach to dealing with autotools seems to be to find
something that does what you want and copy it.  There are various
examples in Rhythmbox's file that make as good starting
points as anything else.

So, to add an --enable-x or --with-x argument to ./configure, you add a
block to like this:

	      		      [Add random features to Rhythmbox]),,
if test "x$enable_random_feature" = xyes; then
	# do checks and get compile/link flags for your feature
	AC_DEFINE(USE_RANDOM_FEATURE, 1, [define for random features])
AM_CONDITIONAL(USE_RANDOM_FEATURE, test "x$enable_random_feature" = "xyes")

You can then use USE_RANDOM_FEATURE as a conditional in makefiles and
c code.

For libraries that ship a pkg-config .pc file (like libsexy), you can
check that the library is installed and get the flags required to use it
like this:

	PKG_CHECK_MODULES(LIBSEXY, libsexy > 0.1.5, have_libsexy=yes,
	if test "x$have_libsexy" = "xno"; then
		AC_MSG_ERROR([libsexy is required for random features])

For bonus points, you can have the feature automatically enable itself
when with_random_feature is set to 'auto' and its dependencies are

(I haven't actually used the above code, so it may not be correct)

> I snooped around in the ./configure and the Makefile and everything (all
> the .ams and .ins) and I just can't figure out how to add an option
> cleanly (i.e. without hacking up the files myself).
> Sorry for this newbie question, but this is the first time I've screwed
> with a project and didn't just write my own Makefile.

One of the main reasons people dislike the autotools is the huge
scary files they create.  It takes a while to figure out how it all fits
together, and then you realise you can mostly just ignore them.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]