autoconf
[Top][All Lists]
Advanced

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

Re: Custom source configuration


From: Yvan Barthélemy
Subject: Re: Custom source configuration
Date: Tue, 13 Nov 2007 13:57:32 +0100


Le 13 nov. 07 à 13:36, Ralf Wildenhues a écrit :

Hello Yvan,

* Yvan Barthélemy wrote on Tue, Nov 13, 2007 at 12:56:41PM CET:
I am new to autoconf and I would want to do the following uses :

- I have made a m4 macro to check the Qt environment of a user. Now I would like to check the sources in order to correctly set compiler and linker flags. Is that sort of thing (source scanning) already performed somewhere
?

Do you know <http://autoconf-archive.cryp.to/bnv_have_qt.html>?

This fails gracefully on my Mac, so I did it from scratch (I've also look at an aother script called qt.m4, but no more luck)... In fact, I proabbly could have improved bnv_have_qt instead, but I did it as an exercise since I had not used autoconf before...


We're using an older version of this macro in some code, with
something like this (you also need pkg.m4 for it):

 PKG_CHECK_MODULES(QT, [qt-mt >= 3.1],
   [CPPFLAGS="$CPPFLAGS $QT_CFLAGS"
    LIBS="$QT_LIBS $LIBS"
    AC_PATH_PROG([MOC], [moc], [:])],
   [BNV_HAVE_QT
    CPPFLAGS="$CPPFLAGS $QT_CXXFLAGS"
    LIBS="$QT_LIBS $LIBS"
    MOC="$QT_MOC"])

(improvements and bug reports welcome).

I'll share my macros :-D
The improvements I provide are :
        - Better compatibility (I assume, becvause I only tried on my machine)
        - Support for more locations
        - Support for qmake bin
        - Support for weird name (on Debian qmake is called qmake-qt4)
        - Provide more variables (version of qmake, version of tools)
- TODO : Qt module management (scan source and add flags depending on Qt includes)
        - … Probably some more …

Drawback :
        - Less support for compilation (as of now)




- The previous use was mostly been thought to be performed at configure time, but it maybe be interesting to perform this at autoreconf time. For example, I would want to generate myself all code with Qt uic, and Qt moc, and distribute the generated code rather than asking the user to do it again (assuming there is no difference in the generated code when generated
on different environment).

This is what we do in Makefile.am:

 bin_PROGRAMS            = foo
 foo_SOURCES             = bar.cpp bar.h baz.cpp baz.h ...
 nodist_foo_SOURCES      = $(MOC_SRC) ...
 BUILT_SOURCES           = $(MOC_SRC) ...
 CLEANFILES              = $(MOC_SRC) ...
 SUFFIXES = .cpp .moc .h
 MOC_SRC = bar.moc baz.moc ...

If you want to distribute .moc files, you can probably just move
them from nodist_foo_SOURCES to foo_SOURCES.  And from CLEANFILES
to MAINTAINERCLEANFILES.

If the list of .moc files matches the list of header files, you can
further factor and simplify to:
 foo_hdrs = bar.h baz.h
 foo_SOURCES = $(foo_hdrs) bar.cpp baz.cpp ...
 MOC_SRC = $(foo_hdrs:.h=.moc)

We don't use uic, though.

In fact, I will rely on qmake for Makefile generation for now. But I will want something more automated and robust by the time. In fact, I don't want to fill the Makefile.am myself with used modules. Neither I want modules to be systematically added if I don't use them.

But for now, the main problem for me with current available m4 is : no qmake support, no Mac support...



FWIW, yes, I know the SUFFIXES list is not crucially necessary.
It is not wrong though, either, and I think it helps being clear.

Cheers,
Ralf

I join my macro (this is a work in progress I started last Sunday, but with already some things interesting for me) for information. But it doesn't help me to scan the sources :P.

Don't hesitate to try it and provide feedback...
May be both can be merged...



Thanks,
Yvan



reply via email to

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