GNU bug report logs - #74387
Cannot use ifdef and other Make conditionals

Previous Next

Package: automake;

Reported by: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Date: Sun, 17 Nov 2024 04:09:02 UTC

Severity: normal

Done: Karl Berry <karl <at> freefriends.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
Subject: bug#74387: closed (Re: bug#74387: Cannot use Make conditionals)
Date: Sun, 23 Feb 2025 21:36:04 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#74387: Cannot use ifdef and other Make conditionals

which was filed against the automake package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 74387 <at> debbugs.gnu.org.

-- 
74387: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74387
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Karl Berry <karl <at> freefriends.org>
To: maxim.cournoyer <at> gmail.com, 74387 <at> debbugs.gnu.org
Subject: Re: bug#74387: Cannot use Make conditionals
Date: Sun, 23 Feb 2025 14:34:43 -0700
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.

[Message part 3 (message/rfc822, inline)]
From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: bug-automake <at> gnu.org
Subject: Cannot nest Make conditionals inside Automake conditionals
Date: Sun, 17 Nov 2024 13:07:52 +0900
[Message part 4 (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 7 (text/plain, inline)]
Thanks for maintaining Automake!

-- 
Maxim

This bug report was last modified 142 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.