automake
[Top][All Lists]
Advanced

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

Re: How to add new Makefile-Rules through Configure?


From: Gavin Smith
Subject: Re: How to add new Makefile-Rules through Configure?
Date: Mon, 9 Mar 2015 17:58:19 +0000

On 8 March 2015 at 22:29, Marc Wäckerlin <address@hidden> wrote:
> I didn't find any proper solution with google for the following problem:
>
> How do the makefile rules come into the makefile?
>
> E.g. when I use AC_PROG_CXX, in the makefile rules should be added, such as
> compiling .o from .cxx and to cleanup .o files, and so on -  or ar these
> rules always there?

The rules are always there. To be more precise, automake will generate
rules to build .o files from .cxx files if you give .cxx files as
source files in Makefile.am. However, these rules will use a variable
to give the name of the compiler. Hence, automale checks that the
necessary macros are used in configure.ac to appropriately set the
variables these rules need.

>
> I would like to add something to configure.ac, that creates new rules, new
> cleanup files, etc.
>
> e.g. for adding Qt support (or support for any other code generating tool):
>
> uic creates uic_%.h files from %.ui and the derieved uic_%.h files should
> then be cleaned up with "make clean"
>
> I found the following "hack" as solution:
>
> In ax_check_qt.m4 that I include in configure.ac, I add:
> -------------------------------------------
>   AX_ADDITIONAL_QT_RULES_HACK='
> %_ui.hxx: %.ui
>         ${UIC} -o address@hidden $<
>
> moc_%.cxx: %.hxx
>         ${MOC} -o address@hidden $<'
>   AC_SUBST(AX_ADDITIONAL_QT_RULES_HACK)
> ])
> -------------------------------------------
>
> In the makefile, automake copies the variable, but is unable to handle the
> multi-line content, so the rules go straight into the makefile:
> -------------------------------------------
> AX_ADDITIONAL_QT_RULES_HACK =
> %_ui.hxx: %.ui
>         ${UIC} -o $@ $<
>
> moc_%.cxx: %.hxx
>         ${MOC} -o $@ $<
> -------------------------------------------
>
> So, it works, but it is a dirty hack, and it doesnot resolve the problem of
> adding the derieved objects to CLEANFILES.

In case you didn't know, you can add your own rules directly in
Makefile.am. You may have trouble if you use GNU make extensions,
though.

>
> All ui-files in xxx_SOURCES should automatically add ui_xxx.hxx to the
> CLEANFILES, so:
> -------------------------------------------
> bin_PROGRAMS = cardgui
> cardgui_SOURCES = cardgui.cxx cardgui.hxx \
>                   password.hxx cardgui-model.hxx \
>                   cardgui.ui password.ui
> -------------------------------------------
> Should generate "CLEANFILES += ui_cardgui.hxx ui_password.hxx". How can I
> achieve this?
>
>
> Any ideas? What would be the intended solution?

If you are generating files to be used as sources, you might want to
use the BUILT_SOURCES automake variable in Makefile.am. This should
cause these built sources to be included in cleaning.



reply via email to

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