automake
[Top][All Lists]
Advanced

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

Re: AM_CONDITIONAL + AM_COND_IF does not work


From: Marc Wäckerlin
Subject: Re: AM_CONDITIONAL + AM_COND_IF does not work
Date: Tue, 10 Mar 2015 10:02:05 +0100
User-agent: Roundcube Webmail/0.9.5

Hi Gavin

Thank you, that helps up to the next step ...

Am 09.03.2015 18:45, schrieb Gavin Smith:
automake doesn't know or care that one of these uses of
AC_CONFIG_FILES was conditional. It is looking for the input files to
automake (like "Makefile.am"), which it will derive from the arguments
to AC_CONFIG_FILES. It wouldn't be possible for these input files to
be defined conditionally in the configure script, because logically
automake runs before the configure script.

That's what I thought, so AM_COND_IF + AC_CONFIG_FILES only works for existing files, but not in my case. A limitation, that should be better documented ...

In my eyes, this behaviour is a bug, automake should not test, read or evaluate conditional files, if the condition does not match.


Now, is there a way to workaround that?

Your idea is a good approach:

The automake manual says that automake won't recognize an argument to
AC_CONFIG_FILES if its value is given indirectly through a shell
variable (see "Requirements" node), so maybe you could try that.

It works, e.g. I always generate RPM spec files by filling in configure information:
------------------------------------------
AC_CONFIG_FILES([${PACKAGE_NAME}.spec])
------------------------------------------

That works great. But here, automake is not involved. Unfortunately, variables seem not to work, if automake is required. The code:
------------------------------------------
makefile=makefile
AM_CONDITIONAL([HAVE_SRC_DIR], [test -f src/${makefile}.am])
AM_COND_IF([HAVE_SRC_DIR], [AC_CONFIG_FILES([src/${makefile}])])
------------------------------------------
does not generate "src/makefile.in" by automake, as it should.

So, the meaning od the above mentioned manual text is: "variables don't work with automake" ... :(


Other ideas? Other solutions?

Am I the only one with dozens of similar projects who wants to save some typing ...? ;)




On 9 March 2015 at 15:06, Marc Wäckerlin <address@hidden> wrote:
I try to generically find out, whether examples/makefile.am exists in a
project and to automatically use it, if it exists:
------------------------------------------
AM_CONDITIONAL([HAVE_EXAMPLES_DIR], [test -f examples/makefile.am])
AM_COND_IF([HAVE_EXAMPLES_DIR], [AC_CONFIG_FILES([examples/makefile])])
------------------------------------------

A note for those who did not understand the intention:

If and only if file "examples/makefile.am" exists, then it should be added to "AC_CONFIG_FILES". That means, it is possible and wanted behavior that "examples/makefile.am" does not exists, then it should simply not be added. So if "examples/makefile.am" does not exists, also "examples/makefile.in" will not exist.

The idea behind: I have a standard project setup, where examples, tests and other subdirectories are optional and I want to write a generic M4-file that scans for the existing makefiles and automatically adds those that exist.

So, yes the file does not exits, but no, it does not have to, since that's exactly the idea of the test: Find out if it exists and use it in case it exists.



Thank you
Regards
Marc
--
Marc Wäckerlin
http://marc.wäckerlin.ch



reply via email to

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