makefile - Can I define an install rule / install hook in configure.ac -
say there bunch of (e.g. 200) modules depend on core module. using autotools.
the core module installs core.m4 file dependents use various things.
all dependents have lines in install-data-local rule generate scripts , 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 remove 5 lines redundantly duplicated on ~200 files, , instead define lines in core.m4. dependents should able somevar: somevalue
(or short, @ worst one-line thing in install-data-local) , have lines executed during make install.
is there nice way define these lines in core.m4 , make them available makefile.am? can't find similar examples on net.
the solution can think of m4 spits out shell script can call install-data-local, i'm not sure that's best (or autotoolish) way.
alternatively, there simple way distribute automake fragment.am
file core module? (this seems way e.g. python compilation rules defined.)
after digging, found http://thread.gmane.org/gmane.comp.sysutils.automake.general/5704/focus=5708 has solution similar problem (i couldn't ac_config_files solution mentioned there work).
so core.m4 defines core_mkinclude:
ac_defun([core_mkinclude], [ ac_subst_file(core_include) core_include=$srcdir/core_include.am cat >$srcdir/core_include.am <<eof core_stuffdir=\$(prefix)/share/core/stuff/ install-stuff: 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 eof ])
ie. goal printed file core_include.am, , has own name. each module's configure.ac calls core_mkinclude
, , each makefile.am has
@core_include@ install-data-local: install-stuff
an improvement @ least.
Comments
Post a Comment