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 configure.ac 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 configure.ac like this:

AC_ARG_ENABLE(random_feature,
	      AC_HELP_STTRING([--with-random-feature],
	      		      [Add random features to Rhythmbox]),,
	      enable_random_feature=auto)
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])
fi
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,
	have_libsexy=no)
	if test "x$have_libsexy" = "xno"; then
		AC_MSG_ERROR([libsexy is required for random features])
	else
		RHYTHMBOX_CFLAGS="$RHYTHMBOX_CFLAGS $LIBSEXY_CFLAGS"
		RHYTHMBOX_LIBS="$RHYTHMBOX_LIBS $LIBSEXY_LIBS"
	fi

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

(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]