Subject: bug#8362: make install prefix inserted in source code with generated python files

From: Bogdan <[email-masked]>
Date: Tue, 21 Mar 2023 23:05:10 +0100

Hi all.

  A small contribution to the discussion.

  First of all, it's not an Automake defect that the user is allowed 
to override variables using the command line. This may be used e.g. 
for changing compile flags at 'make' time:

	make CFLAGS=-Wall

  Second, in the provided example, the 'install' target indeed depends 
on prog_PYTHON, while 'all' doesn't. Somebody made a decision to 
compile Python files at install time and not at compile time. Maybe 
because it is not known at compile time where the files will end up, 
or they have conflicting names, or for some other good reason.

  Third, and most important (I think) is that we need to note that 
"prog/x.py" is GENERATED, but is NOT marked so. Adding

	BUILT_SOURCES = prog/x.py

to Makefile.am fixes the issue immediately. So, sorry to say this, but 
it looks like this defect is invalid. The file prog/x.py is meant to 
be built/generated at build time and must be marked as being built.

  Another point is that one needs to 'touch' x.src each time to test, 
which also is signalling that something may be wrong. But, this may be 
just a side effect of the minimalistic example.

  By the way, if the real code also needs to substitute just 
"$(libexecdir)", which is known at configure time, it should actually 
be 'configure' which generates prog/x.py. This would probably stop 
this issue from appearing in the first place...

  If you really, really want to fix something in Automake, you can use 
the attached patch, it seems to fix the issue. But, this is something 
I don't recommend, because next we'll be adding each and every 
language/script group to the 'all' target and that's probably not the 
point. That's why I'm not formatting the patch as I should be.

-- 
Regards - Bogdan ('bogdro') D.                 (GNU/Linux & FreeDOS)
X86 assembly (DOS, GNU/Linux):    http://bogdro.evai.pl/index-en.php
Soft(EN): http://bogdro.evai.pl/soft  http://bogdro.evai.pl/soft4asm
www.Xiph.org  www.TorProject.org  www.LibreOffice.org  www.GnuPG.org

diff --git a/bin/automake.in b/bin/automake.in
index f249064d5..73865a67c 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -4610,6 +4610,8 @@ sub handle_all
     my @local_headers = ();
     push @local_headers, '$(BUILT_SOURCES)'
       if var ('BUILT_SOURCES');
+    push @local_headers, '$(prog_PYTHON)'
+      if var ('prog_PYTHON');
     foreach my $spec (@config_headers)
       {
 	my ($out, @ins) = split_config_file_spec ($spec);