Subject: bug#74387: closed (Re: bug#74387: Cannot use Make conditionals)

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 23 Feb 2025 21:36:04 +0000

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 [email-masked].

-- 
74387: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=74387
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#74387: Cannot use Make conditionals
From: Karl Berry <[email-masked]>
To: [email-masked], [email-masked]
Date: Sun, 23 Feb 2025 14:34:43 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

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.

Subject: Cannot nest Make conditionals inside Automake conditionals
From: Maxim Cournoyer <[email-masked]>
To: [email-masked]
Date: Sun, 17 Nov 2024 13:07:52 +0900
List-Id: <debbugs-submit.debbugs.gnu.org>

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 <[email-masked]>
       and Alexandre Duret-Lutz <[email-masked]>.

[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.

Thanks for maintaining Automake!

-- 
Maxim