GNU bug report logs -
#74387
Cannot use ifdef and other Make conditionals
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 74387 in the body.
You can then email your comments to 74387 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Sun, 17 Nov 2024 04:09:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-automake <at> gnu.org
.
(Sun, 17 Nov 2024 04:09:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hello,
Consider the following:
--8<---------------cut here---------------start------------->8---
$ guix shell --pure automake autoconf coreutils grep \
--with-latest=automake --with-latest=autoconf --without-tests=automake
[...]
[env]$ autoconf --version
autoconf (GNU Autoconf) 2.72
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+/Autoconf: GNU GPL version 3 or later
<https://gnu.org/licenses/gpl.html>, <https://gnu.org/licenses/exceptions.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by David J. MacKenzie and Akim Demaille.
[env]$ automake --version
automake (GNU automake) 1.17
Features: subsecond-mtime
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv2+: GNU GPL version 2 or later
<https://gnu.org/licenses/gpl-2.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Tom Tromey <tromey <at> redhat.com>
and Alexandre Duret-Lutz <adl <at> gnu.org>.
[env]$ cat configure.ac
AC_INIT([if-without-endif-bug], [0.0.0])
AM_INIT_AUTOMAKE([foreign])
AM_CONDITIONAL([CAN_RUN_TESTS], [true])
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
[env]$ cat Makefile.am
if CAN_RUN_TESTS
SH_TESTS = dummy/test1.sh dummy/test2.sh
SH_TESTS_SLOW = dummy/slow-test.sh
TESTS = $(SH_TESTS)
# By default, filter out slow tests. The slow tests can be requested
# by setting the WITH_SLOW_TESTS Make variable.
ifdef WITH_SLOW_TESTS
TESTS += $(SH_TESTS_SLOW)
else
$(info Skipping slow tests; set WITH_SLOW_TESTS=1 to run them)
endif
endif
$ autoreconf -vif
autoreconf: export WARNINGS=
autoreconf: Entering directory '.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: configure.ac: not using Intltool
autoreconf: configure.ac: not using Gtkdoc
autoreconf: running: /gnu/store/6vdjwn5yjnwir2279h0mfc5ws9wnz8d7-autoconf-2.72/bin/autoconf --force
autoreconf: configure.ac: not using Autoheader
autoreconf: running: automake --add-missing --copy --force-missing
Makefile.am:16: error: endif without if
autoreconf: error: automake failed with exit status: 1
--8<---------------cut here---------------end--------------->8---
In other words, Automake doesn't handle nesting pure Make conditionals
(ifeq, ifneq, ifdef, offended) inside an Automake conditional block (if).
My attaching the configure.ac and Makefile.am files for convenience.
[configure.ac (application/octet-stream, attachment)]
[Makefile.am (application/octet-stream, attachment)]
[Message part 4 (text/plain, inline)]
Thanks for maintaining Automake!
--
Maxim
Changed bug title to 'Cannot use ifdef and other Make conditionals' from 'Cannot nest Make conditionals inside Automake conditionals'
Request was from
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
to
control <at> debbugs.gnu.org
.
(Sun, 17 Nov 2024 04:50:01 GMT)
Full text and
rfc822 format available.
Information forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Sun, 17 Nov 2024 04:58:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 74387 <at> debbugs.gnu.org (full text, mbox):
Hi,
The problem appears simpler than I first thought; it seems Automake is
hard-coded to expect 'endif' to be matched with its own 'if'; causing parsing
errors when attempting to use Make's conditional such as ifdef, ifeq,
etc. that also end with 'endif'.
This was reported 23 years ago here: https://lists.gnu.org/archive/html/bug-automake/2001-11/msg00015.html
There is workaround proposed that makes use of an output variable to hide the
'endif' behind it:
--8<---------------cut here---------------start------------->8---
ENDIF=endif
AC_SUBST(ENDIF)
and to apply this in Makefile.am:
ifdef f
..
@ENDIF@
--8<---------------cut here---------------end--------------->8---
I've tested the above and it appear to work, but perhaps Automake could
accommodate Make snippets better?
--
Thanks,
Maxim
Information forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Sun, 17 Nov 2024 22:36:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 74387 <at> debbugs.gnu.org (full text, mbox):
Hi Maxim - thanks for the report and doing the research to find that old
answer. Do you have any ideas for a better solution? I can't think of
one. We can't change Automake syntax now. Nor does it seem maintainble
for automake to have special knowledge of all of make's builtin
conditionals and match them too.
I'll see about adding something to the manual about the workaround,
at least. --thanks, karl.
Information forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Tue, 19 Nov 2024 13:36:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 74387 <at> debbugs.gnu.org (full text, mbox):
Hi Karl,
Karl Berry <karl <at> freefriends.org> writes:
> Hi Maxim - thanks for the report and doing the research to find that old
> answer. Do you have any ideas for a better solution? I can't think of
> one. We can't change Automake syntax now. Nor does it seem maintainble
> for automake to have special knowledge of all of make's builtin
> conditionals and match them too.
>
> I'll see about adding something to the manual about the workaround,
> at least. --thanks, karl.
The workaround got rid of the Automake syntax checks, but I faced more
problems passed that. It was very confusing; the Make conditionals
would not work as I expected. I could give it another look to see if I
can distill some interesting points from that experiment; I still have
my minimal example around.
--
Thanks,
Maxim
Information forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Tue, 19 Nov 2024 21:29:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 74387 <at> debbugs.gnu.org (full text, mbox):
Hi Maxim,
the Make conditionals would not work as I expected.
Since Automake rearranges things quite a lot when generating the
Makefile from Makefile.am, I'm not too surprised there can be problems.
I could give it another look to see if I
can distill some interesting points from that experiment
If you have time, it couldn't hurt, though I fear there is no real
solution :(. (At least without automake recognizing every make
conditional, which isn't anything I'll be implementing). --thanks, karl.
Information forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Tue, 19 Nov 2024 23:47:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 74387 <at> debbugs.gnu.org (full text, mbox):
Automake conditionals were originally created because make conditionals aren't portable. In principle, if you are willing to require GNU make (or any other specific Make that has conditionals) you shouldn't *need* Automake conditionals.
Of course, things may not be that simple anymore. Can you please give some examples of the things you are trying to do, that seem to require use of both kinds of conditionals?
zw
Information forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Sun, 24 Nov 2024 13:43:01 GMT)
Full text and
rfc822 format available.
Message #25 received at 74387 <at> debbugs.gnu.org (full text, mbox):
Hi Zack,
"Zack Weinberg" <zack <at> owlfolio.org> writes:
> Automake conditionals were originally created because make
> conditionals aren't portable. In principle, if you are willing to
> require GNU make (or any other specific Make that has conditionals)
> you shouldn't *need* Automake conditionals.
>
> Of course, things may not be that simple anymore. Can you please give some examples of the things you are trying to do, that seem to require use of both kinds of conditionals?
I was trying to come up with an environment variable to control whether
expensive tests of the test suite should be run or not,
e.g. depending on WITH_SLOW_TESTS=1 or WITH_SLOW_TESTS=0.
I didn't want to use an Autoclave conditional, as these are baked in the
build system following 'configure', i.e., not dynamic enough (I want the
ability to switch this on or off anytime I run the tests -- not just at
configure time).
This is where I thought of employing Make's native conditionals, which
would have enabled checking the value of the WITH_SLOW_TESTS environment
variable every time Make is run.
In the end, I've worked around the issue by moving the skip check/logic
in each test that I wanted to skip. That's a bit ugly as when running
the test individually you need to remember to set WITH_SLOW_TESTS=1 to
really have it run, but it's the best I've found thus far.
For the full context of what I was working on, see the patches submit
for consideration to GNU Guix [0].
[0] https://issues.guix.gnu.org/74394
I guess this can be closed, though I'd still be interested if there are
better ways to accomplish skipping some tests than what I've ended up
using, as that seems like some shortcoming that build system tinkerers
having gotten used to the likes of Meson, where you can script pretty
much anything, would not easily accept.
--
Thanks,
Maxim
Information forwarded
to
bug-automake <at> gnu.org
:
bug#74387
; Package
automake
.
(Sun, 23 Feb 2025 21:36:03 GMT)
Full text and
rfc822 format available.
Message #28 received at 74387 <at> debbugs.gnu.org (full text, mbox):
Hi Maxim - I think so much depends on the details of a given project
that I lack ideas for something to do in general.
One possibility that occurs to me in your case is to turn your automake
conditional into a make conditional, instead of mixing them.
Another possibility might be to move the make-specific stuff out of the
automake conditional and simplify away the +=, as in something like:
ifdef WITH_SLOW_TESTS
SLOW_TESTS = $(SH_TESTS_SLOW)
else
SLOW_TESTS =
endif # WITH_SLOW_TESTS
if CAN_RUN_TESTS
..
TESTS = $(SH_TESTS) $(SLOW_TESTS)
endif CAN_RUN_TESTS
No real idea if it will avoid the other problems you had.
I guess I'm going to close this for lack of any way forward, but feel
free to reply/reopen or open a new issue if desired. --thanks, karl.
Reply sent
to
Karl Berry <karl <at> freefriends.org>
:
You have taken responsibility.
(Sun, 23 Feb 2025 21:36:04 GMT)
Full text and
rfc822 format available.
Notification sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 23 Feb 2025 21:36:04 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 24 Mar 2025 11:24:13 GMT)
Full text and
rfc822 format available.
This bug report was last modified 45 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.