automake
[Top][All Lists]
Advanced

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

Re: Implementing a plugin-like module


From: Sam Varshavchik
Subject: Re: Implementing a plugin-like module
Date: Thu, 04 Aug 2011 12:29:31 -0400

Stefano Lattarini writes:

A quick workaround to obtain this behaviour is to write your custom/rules
defintion in a `.am' fragment in your source tree, and then include it
from all the Makefile.am files that need it:

  $ cat my-rules.am
  my_variable = ...
  .ctpl.c:
        # rules to create a C file from a template `.ctpl'.

  $ cat lib/Makefile.am
  include  $(top_srcdir)/my-rules.am
  ... [specific rules]

  $ cat src/Makefile.am
  include  $(top_srcdir)/my-rules.am
  ... [other specific rules]
There's no need to install an `.am' file there in order to use it with the
`include' directive.

I saw that, when I was rooting around in automake -- that it attempts to expand relative include statements in Makefile.am, rather than leaving them in Makefile.in, and have gmake handle them.

It just didn't register to me that I don't need to add the .am file into make dist, since automake handles the inclusion.

I guess I can whip-up something analogous to gettextize, that symlinks the .am file from $top_srcdir, and adds the include statement to Makefile.am, if it's not there already. That should do it.

I also came up with a different solution last night. I install something like this into /usr/share/aclocal:

AC_DEFUN([LIBX_INIT],[
PKG_PROG_PKG_CONFIG
PKG_CHECK_EXISTS([libx],[:],[AC_MSG_ERROR([libx not found])])

libx_pkgdatadir="`$PKG_CONFIG --variable=pkgdatadir libx`"

LIBX_AM="include $libx_pkgdatadir/msgdispatcher.am"
AC_SUBST([LIBX_AM])
])

Then, I add

LIBX_INIT

to the configure.ac and add

@LIBX_AM@

in Makefile.am; and aclocal ends up automatically adding the m4 macro to aclocal.m4, which gets expanded into configure.in. At runtime, configure picks up the toolkit's installation directory, and creates an include statement that references it, which gets SUBST-ed into the Makefile.

Rather than having automake handle the inclusion, it's left up to gmake; but my build-rules are already gmake-specific, and this wouldn't be an additional requirement.

Thanks.

Attachment: pgpCOuRfn6mEw.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]