Say there are a bunch of (e.g. nearly 200) modules that all depend on a core module. All are using Autotools.
The core module installs a core.m4 file which the dependents already use for various things.
All the dependents also have some lines in their install-data-local rule to generate some scripts and install them, e.g.
core_stuffdir=$(prefix)/share/core/stuff/
install-data-local:
generate-stuff stuff.xml
test -d $(DESTDIR)$(core_stuffdir) || mkdir $(DESTDIR)$(core_stuffdir)
stuff=`xmllint --xpath '//stuff[@install="yes"]/@name' stuff.xml`; \
$(INSTALL_DATA) $$stuff $(DESTDIR)$(core_stuffdir); \
rm $$stuff
…
$(INSTALL_DATA) other-module-specific-stuff …
…
I would like to remove those five lines which are currently redundantly duplicated over ~200 files, and instead define the lines in the core.m4. The dependents should be able to say something like SOMEVAR: somevalue
(or something similarly short, at worst a one-line thing in install-data-local) and have those lines executed during make install.
Is there a nice way to do define these lines in core.m4 and make them available to Makefile.am? I can't find any similar examples on the net.
The only solution I can think of now is that the m4 spits out a shell script that I can call from install-data-local, but I'm not sure that's the best (or most autotoolish) way.
Alternatively, is there a simple way to distribute an automake fragment.am
file from my core module? (This seems to be the way e.g. Python compilation rules are defined.)