GNU bug report logs - #60535
[PATCH] depend2: switch echo|sed to automatic vars

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: automake-patches; Reported by: Mike Frysinger <vapier@HIDDEN>; Keywords: help pending patch; dated Wed, 4 Jan 2023 02:08:02 UTC; Maintainer for automake-patches is automake-patches@HIDDEN.
Added tag(s) pending and help. Request was from Karl Berry <karl@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 60535 <at> debbugs.gnu.org:


Received: (at 60535) by debbugs.gnu.org; 12 Jan 2023 23:33:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 12 18:33:47 2023
Received: from localhost ([127.0.0.1]:48855 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pG74t-0006d6-Ab
	for submit <at> debbugs.gnu.org; Thu, 12 Jan 2023 18:33:47 -0500
Received: from freefriends.org ([96.88.95.60]:42836)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <karl@HIDDEN>) id 1pG74r-0006cz-Sy
 for 60535 <at> debbugs.gnu.org; Thu, 12 Jan 2023 18:33:46 -0500
X-Envelope-From: karl@HIDDEN
Received: from freefriends.org (freefriends.org [96.88.95.60])
 by freefriends.org (8.14.7/8.14.7) with ESMTP id 30CNXiEQ028315
 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); 
 Thu, 12 Jan 2023 16:33:45 -0700
Received: (from apache@localhost)
 by freefriends.org (8.14.7/8.14.7/Submit) id 30CNXhcZ028314;
 Thu, 12 Jan 2023 16:33:43 -0700
Date: Thu, 12 Jan 2023 16:33:43 -0700
Message-Id: <202301122333.30CNXhcZ028314@HIDDEN>
From: Karl Berry <karl@HIDDEN>
To: vapier@HIDDEN
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
In-Reply-To: <Y7+AVbcSZVZoNudU@vapier>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60535
Cc: nbowler@HIDDEN, 60535 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Well, stated more positively, my concern is about not replacing a bunch
of (granted) complicated old code with a bunch of complicated new code,
i.e., creating new-and-different maintainer and portability hassles, for
the sake of (what nowadays feels to me like) a micro-optimization. Let's
not underestimate the value of stable code that is known to work.

From Nick's and your previous discussion about the non-portability of
the make variables and the (what looks to me like) rather complicated
workarounds, I have my doubts that any replacement will work without a
few rounds of portability and bug fixes. With yet more complications
resulting.

I've never used those make variables myself, nor have I ever touched any
of this dependency code in Automake, and could certainly be overstating
the case. Nevertheless, that's my concern.

That said, if your replacement code passes all the tests on NetBSD,
dmake, whatever else is known to be problematic (I doubt we have to care
about Ultrix though), I guess it would be safe enough. --thanks, karl.




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at 60535 <at> debbugs.gnu.org:


Received: (at 60535) by debbugs.gnu.org; 12 Jan 2023 03:37:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 11 22:37:04 2023
Received: from localhost ([127.0.0.1]:44363 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pFoOm-0005g1-0V
	for submit <at> debbugs.gnu.org; Wed, 11 Jan 2023 22:37:04 -0500
Received: from woodpecker.gentoo.org ([140.211.166.183]:47654
 helo=smtp.gentoo.org) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vapier@HIDDEN>) id 1pFoOj-0005fX-NT
 for 60535 <at> debbugs.gnu.org; Wed, 11 Jan 2023 22:37:02 -0500
Received: by smtp.gentoo.org (Postfix, from userid 559)
 id 476BC335D8E; Thu, 12 Jan 2023 03:36:55 +0000 (UTC)
Date: Wed, 11 Jan 2023 22:36:53 -0500
From: Mike Frysinger <vapier@HIDDEN>
To: Karl Berry <karl@HIDDEN>
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
Message-ID: <Y7+AVbcSZVZoNudU@vapier>
References: <CADyTPExn47Fa6W=WY0jiNbBnmz2bNr-+d6O9Xf=q3Cue3Ramdg@HIDDEN>
 <202301052347.305NlUIZ020838@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="uIyIBzZ6y9xwmQG+"
Content-Disposition: inline
In-Reply-To: <202301052347.305NlUIZ020838@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60535
Cc: nbowler@HIDDEN, 60535 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


--uIyIBzZ6y9xwmQG+
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline

On 05 Jan 2023 16:47, Karl Berry wrote:
> Please excuse my curmudgeonness, but it's not clear to me that avoiding
> sed is worth these hassles in working around the implementation-specific
> bugs in the automatic variables. Especially if we have to invoke a shell
> and various commands anyway, how about keeping things as they are? -k

i don't quite buy the argument of "we've got a lot of per-object overhead,
so what's a little bit more".  we should be trying to minimize overhead of
generated code as much as possible.  forking a subshell to fork sed just to
munge a string that we can have make itself generate is pure overhead.

but you're appealing to avoiding hassle.  to that end, i'll point out the
current depdir logic is already in an unhealthy state: we're generating
similar logic 3 times with automake-processed conditionals depending on 3
runtime settings:
?!GENERIC?              %VERBOSE%%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%`test -f '%SOURCE%' || echo '$(srcdir)/'`%SOURCE%
?!GENERIC?              %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
?GENERIC??!SUBDIROBJ?   %VERBOSE%%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE%
?GENERIC??!SUBDIROBJ?   %SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
?GENERIC??SUBDIROBJ?    %VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
?GENERIC??SUBDIROBJ?    %COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE% &&\
?GENERIC??SUBDIROBJ?    $(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po

this directly translates to overhead in the generated Makefile.in:
.c.o:
@am__fastdepCC_TRUE@                $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCC_TRUE@                $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCC_TRUE@                $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@   $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@   DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@               $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<

switching to make variables will allow us to collapse these.  i'm fairly
confident i can at least collapse the last 5 lines ?GENERIC? into 2 lines.
-mike

--uIyIBzZ6y9xwmQG+
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmO/gFAACgkQQWM7n+g3
9YFfCg//QPSbrfaNkDMUEMW6ggzKb6Eaaet0h1MfmTqR51o3/tBSNK+dDyICSWNE
d+laLGBSQq0KUikaB9kGypl65Ju68MNQbyYiX2tVgYGBKBbldZWGcqqUqkaplaxL
u4BSLmSnTONU3HOaWRmz6UpGxDcCxqZ0gD/VA5ZuN09GM8pRgbG7/qK5jqERBA/v
HDakCvQyF6/jSdPYkFZ1KsBSZ6wFwrtKyv3stwX1hstWfHoFxclFE7j0IQcCO17U
R03v2tfcCBvfNs7pVaCb2EFLEQC1nphc3vvhDwXMxRi8zVTbd1EQ6BGmvPvtmFAM
SG4QrIWu62XhHQXdK7beMH6fX39BfW9tHkBcVhCQyzK+seshwg3DaG27QLxUjKLK
CLp8e481cVhbQnQZuzSryIBfdI+JiTuSLokqCoQ4Eq6gVZO7t+BvJ6NKWHqAI+li
p2GBsrXi/SdplxijNS/gq7GTjBOfDhEa+radTItavYq2UY0v0qcx09Si6hYAlmWZ
f36p5MULU3Z9CVtuJ53x84TsmkYTkCToCSNH9s2b8WhIPcIOJ6Hy7turG8466duG
2ve0ZsA/XNAY8r0JTvubvGGOX2uKi9w+y2ScBT8j9KqQCjXLK5vSilPwWvD2ioMZ
pqfLx2KO7sgLNw6pgcsM+LHTefsvUhKb7AqMKHzkLtaFRzqxIZg=
=bZRe
-----END PGP SIGNATURE-----

--uIyIBzZ6y9xwmQG+--




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 6 Jan 2023 04:58:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 23:58:48 2023
Received: from localhost ([127.0.0.1]:53478 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pDeoa-0007og-C2
	for submit <at> debbugs.gnu.org; Thu, 05 Jan 2023 23:58:48 -0500
Received: from lists.gnu.org ([209.51.188.17]:42180)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zack@HIDDEN>) id 1pDeoY-0007oY-DQ
 for submit <at> debbugs.gnu.org; Thu, 05 Jan 2023 23:58:46 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <zack@HIDDEN>) id 1pDeoY-0006IO-2E
 for automake-patches@HIDDEN; Thu, 05 Jan 2023 23:58:46 -0500
Received: from wout3-smtp.messagingengine.com ([64.147.123.19])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <zack@HIDDEN>) id 1pDeoV-0001oH-Mx
 for automake-patches@HIDDEN; Thu, 05 Jan 2023 23:58:45 -0500
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.west.internal (Postfix) with ESMTP id 3E8E83200A67
 for <automake-patches@HIDDEN>; Thu,  5 Jan 2023 23:58:39 -0500 (EST)
Received: from imap45 ([10.202.2.95])
 by compute1.internal (MEProxy); Thu, 05 Jan 2023 23:58:39 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owlfolio.org; h=
 cc:content-type:date:date:from:from:in-reply-to:in-reply-to
 :message-id:mime-version:references:reply-to:sender:subject
 :subject:to:to; s=fm1; t=1672981118; x=1673067518; bh=+ww4Lcq/u8
 Jfp5H1fjVUWMpoA12LIZtTwDSBKFvYBBo=; b=f4uz9UgpW92uTwcA57M03R0WrL
 rPLQPaJc9seJGEN/TArNlakrZP2Y2CcbPw/UtIpcgdq9c7awDBzcLUJQDpQ3BGuM
 nOr39zLYCNzd2oO+2zjB+ovdj3wQ/6Nsz8AY+yEzUfmWmm9lJvGD8EfwyDG70cvG
 oG0TZFCNDYuQpeXLtBMQqTJVEzOXpu1XbNOmdcE05gAZpq522mP/sugxGcR2SVs4
 i5qxv24ow45564VoJ5iah90a05YsiNbfgmibixvABl4ZoCtTCah0IF4ztHuvEkpy
 HySzVfyyG/yo3SCTpdoH25BhtuqZXReNo0XWu22MqyRzwsAEhP+Iv24pKrxQ==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-type:date:date:feedback-id
 :feedback-id:from:from:in-reply-to:in-reply-to:message-id
 :mime-version:references:reply-to:sender:subject:subject:to:to
 :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
 fm2; t=1672981118; x=1673067518; bh=+ww4Lcq/u8Jfp5H1fjVUWMpoA12L
 IZtTwDSBKFvYBBo=; b=GHdKgSi5+f1dzFkXx/oFLkbfKpwbCWoSim9Wj0IjEqyw
 nCAd0FmPZXekTHkq+3sI1s0H0x5D0XBePmyIEyJ16ZoRLY1uHRQ8UwkJAiG/6J2p
 QNVyjEi1IqtU0U+ionoKbVcC5zO4pz55F7R2HhQnQ+Ijif+miIAAsgfmk2AiSQdA
 1CucCJqBOkckL1R3ohfW+Ss8vb7+TxGxH9yUT20O24/G6SKS9cT8vBWgGnj/soOC
 SfoLn9KSK3ilt8SThP7P8naBTmsbm/irJ2QKhSs5BpNpZ4b3k8ywpTM2PdAN6n9R
 2HCBhS9dsakH8gW8Zh1rT8KfEh6ZtVGdPOEaJPbF2g==
X-ME-Sender: <xms:fqq3YwYMpTSGASnY3LWbnWdQni6tG39bmP2nf2peYxEOIDQLmzdizQ>
 <xme:fqq3Y7aekURm1KfqYd7zR4v9Zcyq0Qm2bHtGpmk5Mm-kbe8obCnchQHNqfp1WVjsy
 5927QXjy2hZE32WLsI>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrjeelgdejkecutefuodetggdotefrodftvf
 curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu
 uegrihhlohhuthemuceftddtnecunecujfgurhepofgfggfkjghffffhvffutgesthdtre
 dtreertdenucfhrhhomhepfdgkrggtkhcuhggvihhnsggvrhhgfdcuoeiirggtkhesohif
 lhhfohhlihhordhorhhgqeenucggtffrrghtthgvrhhnpefhuefhveeuffetfffgjeetgf
 ekkeehfedtfeelgfehffffveehkeelfefgheffudenucevlhhushhtvghrufhiiigvpedt
 necurfgrrhgrmhepmhgrihhlfhhrohhmpeiirggtkhesohiflhhfohhlihhordhorhhg
X-ME-Proxy: <xmx:fqq3Y69vwCHU7TH1Nx_Ada7rCEW48LnNuyxxvufdoOqnhIcsAj2KTg>
 <xmx:fqq3Y6ozfj8stbf8qJs_TyjMTBgWLcHTIj9r0QxbvCXGm4KaScVzqQ>
 <xmx:fqq3Y7p_IrTSHy5IjuCxtRe_LydXvoRKKRbskJbprqsJXeOdvV4MNg>
 <xmx:fqq3Y42x7E4SsUCCSizr1ZA4tkOc54S2jGg7nxtlq4abI-v83b9srA>
Feedback-ID: i876146a2:Fastmail
Received: by mailuser.nyi.internal (Postfix, from userid 501)
 id 7B783272007A; Thu,  5 Jan 2023 23:58:38 -0500 (EST)
X-Mailer: MessagingEngine.com Webmail Interface
User-Agent: Cyrus-JMAP/3.7.0-alpha0-1185-g841157300a-fm-20221208.002-g84115730
Mime-Version: 1.0
Message-Id: <3546f63a-27f3-4e3f-adec-6a70079cb519@HIDDEN>
In-Reply-To: <202301052347.305NlUIZ020838@HIDDEN>
References: <20230104020646.22620-1-vapier@HIDDEN>
 <202301052347.305NlUIZ020838@HIDDEN>
Date: Thu, 05 Jan 2023 23:56:11 -0500
From: "Zack Weinberg" <zack@HIDDEN>
To: automake-patches@HIDDEN
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
Content-Type: text/plain
Received-SPF: pass client-ip=64.147.123.19; envelope-from=zack@HIDDEN;
 helo=wout3-smtp.messagingengine.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
 RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.6 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.6 (--)

On Thu, Jan 5, 2023, at 6:47 PM, Karl Berry wrote:
> Please excuse my curmudgeonness, but it's not clear to me that avoiding
> sed is worth these hassles in working around the implementation-specific
> bugs in the automatic variables.

It seems to me that this would be worth doing *if* we could get it to the
point where gmake (and any other implementation with similar optimizations)
didn't need to invoke a shell for the command at all.  I thought the rules
for that were documented but I can't find them at the moment, and I got lost
in gmake's job.c's maze of #ifdefs; anyone know what they are?

It might also be worth doing if we could guarantee that `sed` would not be
used by *any* rules, as that would be a solid step in the direction of
removing `sed` from the set of shell utilities potentially needed at build time
for a generic package (of course, if the package's own build logic uses sed,
there's nothing we can do about that).  ISTR there are several existing automake
rules with complex embedded shell scripts that use sed, though.

zw




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at 60535 <at> debbugs.gnu.org:


Received: (at 60535) by debbugs.gnu.org; 5 Jan 2023 23:47:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 18:47:36 2023
Received: from localhost ([127.0.0.1]:53285 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pDZxQ-0007k6-4L
	for submit <at> debbugs.gnu.org; Thu, 05 Jan 2023 18:47:36 -0500
Received: from freefriends.org ([96.88.95.60]:50332)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <karl@HIDDEN>) id 1pDZxO-0007ju-39
 for 60535 <at> debbugs.gnu.org; Thu, 05 Jan 2023 18:47:34 -0500
X-Envelope-From: karl@HIDDEN
Received: from freefriends.org (freefriends.org [96.88.95.60])
 by freefriends.org (8.14.7/8.14.7) with ESMTP id 305NlWAH020839
 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); 
 Thu, 5 Jan 2023 16:47:32 -0700
Received: (from apache@localhost)
 by freefriends.org (8.14.7/8.14.7/Submit) id 305NlUIZ020838;
 Thu, 5 Jan 2023 16:47:30 -0700
Date: Thu, 5 Jan 2023 16:47:30 -0700
Message-Id: <202301052347.305NlUIZ020838@HIDDEN>
From: Karl Berry <karl@HIDDEN>
To: nbowler@HIDDEN
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
In-Reply-To: <CADyTPExn47Fa6W=WY0jiNbBnmz2bNr-+d6O9Xf=q3Cue3Ramdg@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60535
Cc: 60535 <at> debbugs.gnu.org, vapier@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Please excuse my curmudgeonness, but it's not clear to me that avoiding
sed is worth these hassles in working around the implementation-specific
bugs in the automatic variables. Especially if we have to invoke a shell
and various commands anyway, how about keeping things as they are? -k




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at 60535 <at> debbugs.gnu.org:


Received: (at 60535) by debbugs.gnu.org; 5 Jan 2023 23:00:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 18:00:55 2023
Received: from localhost ([127.0.0.1]:53266 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pDZEF-0006dw-3e
	for submit <at> debbugs.gnu.org; Thu, 05 Jan 2023 18:00:55 -0500
Received: from mail-vs1-f53.google.com ([209.85.217.53]:37396)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nbowler@HIDDEN>) id 1pDZEB-0006dh-2L
 for 60535 <at> debbugs.gnu.org; Thu, 05 Jan 2023 18:00:52 -0500
Received: by mail-vs1-f53.google.com with SMTP id k4so35589110vsc.4
 for <60535 <at> debbugs.gnu.org>; Thu, 05 Jan 2023 15:00:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=draconx-ca.20210112.gappssmtp.com; s=20210112;
 h=cc:to:subject:message-id:date:from:references:in-reply-to
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=z7bFklCW2o7KKoIWQdCuVCyKlcFTZbfHASMD0WteKRg=;
 b=zh0WsmCGBoz14TfJRuE+F55mobJmFnNja7YPZ33qoRuZa6Y75Dm6wH/S7iqJ6ZP1RC
 4Ox0wSbDwbuDW97ZIOXxrn9HGqW5gqkSzBHPDmFd01ZOrbHpZjqV4oIo/BPyTW2o2nSn
 e4dXhMxgOCp1s6rDQsthplZ+b5nrHoGNkYaQakwxVrAFyf+L/eHszuHGIAW1dtDknxmp
 brbgbUjw6Nah0igFYC7MjafmnmoPUHIHXSegGW+T9Dbu3CcIAvJhwXp7d6V/+/Tnvbg/
 Il86HVx00EcStjBhtUoRg46mhsMc8yjbqFMFw/+7I6cv9aoN4oRHbPrZ+yPf1Gplgi7J
 HJoA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:from:references:in-reply-to
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=z7bFklCW2o7KKoIWQdCuVCyKlcFTZbfHASMD0WteKRg=;
 b=0P7KYaKoFBJ0gRkb0tjrHkh7tf5LKomYxxqX17kHLO9frH8F/pWAHBbVN7SQICMHQn
 TVjtr2gkgSG0qgnOkKD4qzQd2zMcstP7sgTq+WpFBL+k8gd87QsJSQGSq8jbd3Sb83aq
 3dKNlTxrF+Sz8AzwoAmpt4dJK+/vLhVKgxSd/sAlAnGLx8aC4EWNKYFHghRreYikqQ2G
 mNE9dFNjiddVBCi+G1dZ/UgFTagNLMu0QQDPIR3oNGayecXuLLIDDp9n5WaS7Ab98hUm
 l+Fmydtt4e/V/HJTwjlny93Pu6EgEGreT1ifuMe7b1TLjqcv/+Gc8mGMRcawtQPL1gQ1
 CsRw==
X-Gm-Message-State: AFqh2kpUtrVlKPXYcNsh3NirJ1jPncMsHqvBq3Fp2HgFvzleb6U1Odj1
 X0g9B7/UM5DgV7f1O3USc8Evga0Im6vpR/nY45LtvPuHIB7CdMQJukk=
X-Google-Smtp-Source: AMrXdXs93qb7MWg4psNInzph3vl0CmpJUwie2+ewRz8geqOXo74Bcw2yuYz1witjbV2cFQNgByKbHPqOZI5omKpSGQ8=
X-Received: by 2002:a05:6102:149f:b0:3ce:896f:ed7b with SMTP id
 d31-20020a056102149f00b003ce896fed7bmr2094479vsv.61.1672959645333; Thu, 05
 Jan 2023 15:00:45 -0800 (PST)
MIME-Version: 1.0
Received: by 2002:a05:6130:1015:b0:559:9619:d862 with HTTP; Thu, 5 Jan 2023
 15:00:44 -0800 (PST)
X-Originating-IP: [24.53.241.20]
In-Reply-To: <Y7ZG2ztiPyfbcebg@vapier>
References: <20230104020646.22620-1-vapier@HIDDEN>
 <CADyTPExn47Fa6W=WY0jiNbBnmz2bNr-+d6O9Xf=q3Cue3Ramdg@HIDDEN>
 <Y7ZG2ztiPyfbcebg@vapier>
From: Nick Bowler <nbowler@HIDDEN>
Date: Thu, 5 Jan 2023 18:00:44 -0500
Message-ID: <CADyTPEywGmYhMr+08qF-sAi+2f4Cjcq1tzhgc9qEgk9KyXYZJA@HIDDEN>
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
To: Mike Frysinger <vapier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60535
Cc: 60535 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 2023-01-04, Mike Frysinger <vapier@HIDDEN> wrote:
[...]
> dmake is one implementation that fails, and your suggestion doesn't work
> :/.
> $ dmake foo/bar.o
> dmake:  Error: -- Incomplete macro expression [)' b='$(at_f:.o=)'; test
> x"$$a.o" = x"$(@F)" || a=$$b;\
>                 echo $$a]

It might also be worth considering that all of these issues go away
if we can arrange the rules to use plain $(*F) instead of doing suffix
substitution on $(@F).

I think this code is used in both suffix and target rules, and $(*F) is
only valid in the former, but perhaps Automake can just substitute the
appropriate literal string into generated target rules?

I'm not familiar with how Automake actually uses this code to generate
rules, so maybe this is not a workable idea.

Cheers,
  Nick




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at 60535 <at> debbugs.gnu.org:


Received: (at 60535) by debbugs.gnu.org; 5 Jan 2023 06:02:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 05 01:02:09 2023
Received: from localhost ([127.0.0.1]:50031 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pDJKL-0004im-A4
	for submit <at> debbugs.gnu.org; Thu, 05 Jan 2023 01:02:09 -0500
Received: from mail-vs1-f48.google.com ([209.85.217.48]:43843)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nbowler@HIDDEN>) id 1pDJKJ-0004iG-IL
 for 60535 <at> debbugs.gnu.org; Thu, 05 Jan 2023 01:02:08 -0500
Received: by mail-vs1-f48.google.com with SMTP id o63so32368164vsc.10
 for <60535 <at> debbugs.gnu.org>; Wed, 04 Jan 2023 22:02:07 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=draconx-ca.20210112.gappssmtp.com; s=20210112;
 h=cc:to:subject:message-id:date:from:references:in-reply-to
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=/ufVqGru3GTKKE4TzKneuc3DZ2U/tbbTa3ye2WnAHdw=;
 b=CjKfhlv4wFyCPh0xbiImIQ979eX8hbKglyQ3GZKdaMqQAcOAv1kesG882g+11Gxzsw
 JA2p0kRhH5EwmsRzqS6/NJLvYficCK3mY+/pcBOA84yrHLoyg7zgMIWBLHKJt/puy7B0
 PAk8YSo5YvTE1W99tQURAbZRsVIBkM9JqOMRWBIBx6FynC4G0IaWCSEOS/NqROrpnqPm
 m/p/I79X2VYtRY+TtnXzkbh97uHjaKzGYCDWRAbKkDerd+fobwo8joED04y4zIKEC27P
 QYbYgCl+GoB4AgyjJyctLjIB9JNshHxmZHrzQdOTCCospc+askdSRQcA7qrACH0TSBge
 Vq6w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:from:references:in-reply-to
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=/ufVqGru3GTKKE4TzKneuc3DZ2U/tbbTa3ye2WnAHdw=;
 b=PBKJyvwp3PzUu05mkexnqhCrtrQQPcK6wy0tNhhvSruJglkFBPJudBYkHU+ZxS8V7L
 pHt1gUn0RZDdIT6TrNK2MyO8cBpqzo+SCxz6Ej1AvkGbsUuAQuGJ05cxzPbdrnRSWwXp
 YfsSoeGzp9ihFIlS4pRlfViiYGSHFdWSp3i8+diqprQsPVg28wfPMNeplUyN5uYKsROH
 QK+uuUjTNUdDtwBfJO07ebK+ThdLqYRtTslGc/Swv6hhqhYX2lqNgvAjURywsVeaVa2z
 s8VLhr2gKWEkod37+vixrd6SSyoZ5vfYKYV2v5u2smEOoG/65J0gRWwvTdxAEM6SEGdI
 UtWQ==
X-Gm-Message-State: AFqh2kqZxeDRWN/DYaGoBX1Q/5A7Gv/fNumocmonq06XqBPABVKm/pCI
 nijf++duZaiGzjrcXulubBOViIUCWku0Rjg/wHyh8a9H2/mVlXJR
X-Google-Smtp-Source: AMrXdXv68QAeZEGmGnsOsgqEOjHY2YyK8gpBqbMZcfP7A7mihUcSCYO86SFi6FFl1GWoIraYVRQki1KqQiXZPuAVcPU=
X-Received: by 2002:a67:f84f:0:b0:3b2:eefc:4630 with SMTP id
 b15-20020a67f84f000000b003b2eefc4630mr6378197vsp.18.1672898521810; Wed, 04
 Jan 2023 22:02:01 -0800 (PST)
MIME-Version: 1.0
Received: by 2002:a05:6130:1015:b0:559:9619:d862 with HTTP; Wed, 4 Jan 2023
 22:02:01 -0800 (PST)
X-Originating-IP: [24.53.241.20]
In-Reply-To: <Y7ZG2ztiPyfbcebg@vapier>
References: <20230104020646.22620-1-vapier@HIDDEN>
 <CADyTPExn47Fa6W=WY0jiNbBnmz2bNr-+d6O9Xf=q3Cue3Ramdg@HIDDEN>
 <Y7ZG2ztiPyfbcebg@vapier>
From: Nick Bowler <nbowler@HIDDEN>
Date: Thu, 5 Jan 2023 01:02:01 -0500
Message-ID: <CADyTPEw6TpnUK6OT4MDyTFtLN5oRa6x6O6nhgR0b6Y26JNgyVg@HIDDEN>
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
To: Mike Frysinger <vapier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60535
Cc: 60535 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 2023-01-04, Mike Frysinger <vapier@HIDDEN> wrote:
> On 04 Jan 2023 21:10, Nick Bowler wrote:
[...]
>> maybe something like:
>>
>>   % cat >Makefile <<'EOF'
>> at_f = $(@F)
>> foo/bar.o:
>> 	a='$(@F:.o=)' b='$(at_f:.o=)'; test x"$$a.o" = x"$(@F)" || a=$$b;\
>> 	  echo $$a
>> EOF
>
> this is interesting.  we actually have some uses of this already in
> the tree.  no one seems to have complained though afaict.

Note that the NetBSD bug affects only substitutions on file/directory
variants like $(@F:a=b), there is no parse problem (that I know of)
with substitutions on the normal forms like $(@:a=b).

> automake-1.13+ has:
> lib/am/subdirs.am:AM_RECURSIVE_TARGETS +=
> $(am__recursive_targets:-recursive=)
>
> automake-1.9+ has:
> lib/am/texibuild.am:      for f in $@ $@-[0-9] $@-[0-9][0-9]
> $(@:.info=).i[0-9] $(@:.info=).i[0-9][0-9]; do \
>
> dmake is one implementation that fails, and your suggestion doesn't work
> :/.
> $ dmake foo/bar.o
> dmake:  Error: -- Incomplete macro expression [)' b='$(at_f:.o=)'; test
> x"$$a.o" = x"$(@F)" || a=$$b;\
>                 echo $$a]

Huh, I somehow have never noticed this problem with dmake.  So the
right-hand side cannot be empty on this one.

> how portable is $() ?  that seems to work in GNU make & dmake.

To expand to the empty string?  I expect that's probably fine, but not
sure about using a make variable on the RHS of a suffix substitution.
At least, this does not appear to work on ULTRIX (the substituted string
is output literally, not expanded at all).

I think my trick can be salvaged to work on all of these crazy
implementations by substituting no-op shell syntax instead:

  % cat >Makefile <<'EOF'
at_f = $(@F)
foo/bar.o:
	a='$(@F:.o='')' b='$(at_f:.o='')'; \
	  test x"$$a.o" = x"$(@F)" || a=$$b; \
	  echo $$a
EOF

Cheers,
  Nick




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at 60535 <at> debbugs.gnu.org:


Received: (at 60535) by debbugs.gnu.org; 5 Jan 2023 03:41:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 04 22:41:25 2023
Received: from localhost ([127.0.0.1]:49964 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pDH88-0000ob-V2
	for submit <at> debbugs.gnu.org; Wed, 04 Jan 2023 22:41:25 -0500
Received: from woodpecker.gentoo.org ([140.211.166.183]:45610
 helo=smtp.gentoo.org) by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vapier@HIDDEN>) id 1pDH87-0000oL-6L
 for 60535 <at> debbugs.gnu.org; Wed, 04 Jan 2023 22:41:23 -0500
Received: by smtp.gentoo.org (Postfix, from userid 559)
 id D2E7F340ECA; Thu,  5 Jan 2023 03:41:16 +0000 (UTC)
Date: Wed, 4 Jan 2023 22:41:15 -0500
From: Mike Frysinger <vapier@HIDDEN>
To: Nick Bowler <nbowler@HIDDEN>
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
Message-ID: <Y7ZG2ztiPyfbcebg@vapier>
References: <20230104020646.22620-1-vapier@HIDDEN>
 <CADyTPExn47Fa6W=WY0jiNbBnmz2bNr-+d6O9Xf=q3Cue3Ramdg@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
 protocol="application/pgp-signature"; boundary="uWHEKhueEBlG8FRR"
Content-Disposition: inline
In-Reply-To: <CADyTPExn47Fa6W=WY0jiNbBnmz2bNr-+d6O9Xf=q3Cue3Ramdg@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60535
Cc: 60535 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)


--uWHEKhueEBlG8FRR
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 04 Jan 2023 21:10, Nick Bowler wrote:
> Except for one minor detail, $(@F) and $(@D) are highly portable.  I
> expect they were in the very first POSIX.2 specs as they predate the
> earliest standards; I believe they first appeared in UNIX System V (ca.
> 1983) and were later added to BSD in 4.3BSD-Reno (ca. 1990).
>=20
> The only potential problem I am aware of with these features is one
> implementation (dmake) which does not follow the POSIX rule of excluding
> the trailing slash from the directory part, and (a bit more troublesome)
> will expand $(@D) to the empty string if the directory part is empty,
> instead of . as required by POSIX.  Usually this is not a major issue,
> as writing something like ./$(@D)/$(@F) is usually sufficient to avoid
> any problems with empty $(@D).

thanks ... i vaguely recall seeing a thread somewhere in the last year or
two talking about portable $(@D)/$(@F) issues somewhere which is how i
learned about these in the first place, but i can't seem to locate it, and
the syntax is not conducive to Google searches.  you don't happen to know
what i'm remembering ?  or have a link to some docs about how portable
these vars are ?  i thought it'd be useful to include them in our docs
and/or manual somewhere.

i can build & install dmake easily since someone is maintaining it in GH:
	https://github.com/jimjag/dmake
i'll throw some bugs at them :)

> It's worth noting that $(?F), $(?D), $(%F) and $(%D) were never added
> to BSD and as a result are missing from many BSD derivatives.  However,
> these variables are of limited utility and are unlikely to be missed.

that'll be good to note in our docs too

> The $(x:a=3Db) suffix substitutions are of identical vintage, and as
> far as I know every make supporting file/directory variables also,
> in principle, supports suffix substitution too.  However, there are
> many bugs in real-world implementations of this feature.
>=20
> Of particular relevance to this patch: older versions of NetBSD make,
> while they do support suffix substitution, fail to correctly parse
> $(@F:.o=3D):
>=20
>   % cat >Makefile <<'EOF'
> foo/bar.o:
> 	echo $(@F:.o=3D)
> EOF
>   % make
>   echo bar.o.o=3D)
>   Syntax error: ")" unexpected
>   *** Error code 2
>=20
> NetBSD make was widely adopted by other systems, so this particular
> issue may actually be found elsewhere.  This bug was present as recently
> as NetBSD 7.2 (ca. 2018).  Furthermore, old versions of FreeBSD (before
> they ditched their own make in favour of NetBSD's version) also fail to
> correctly handle $(@F:.o=3D), but in a different way.
>=20
> The good news is that these problems can be worked around pretty easily
> simply by using another variable:
>=20
>   % cat >Makefile <<'EOF'
> at_f =3D $(@F)
> foo/bar.o:
> 	echo $(at_f:.o=3D)
> EOF
>   % make
>   echo bar
>   bar
>=20
> But this workaround trips over a different suffix substitution bug on
> ULTRIX, which would otherwise work just fine with plain $(@F:.o=3D).
> Maybe ULTRIX is not worth worrying about these days, but nevertheless,
> it is not too hard to detect and work around both problems in pure
> shell, which should still work to avoid the additional forks/sed,
> maybe something like:
>=20
>   % cat >Makefile <<'EOF'
> at_f =3D $(@F)
> foo/bar.o:
> 	a=3D'$(@F:.o=3D)' b=3D'$(at_f:.o=3D)'; test x"$$a.o" =3D x"$(@F)" || a=
=3D$$b;\
> 	  echo $$a
> EOF

this is interesting.  we actually have some uses of this already in
the tree.  no one seems to have complained though afaict.

automake-1.13+ has:
lib/am/subdirs.am:AM_RECURSIVE_TARGETS +=3D $(am__recursive_targets:-recurs=
ive=3D)

automake-1.9+ has:
lib/am/texibuild.am:      for f in $@ $@-[0-9] $@-[0-9][0-9] $(@:.info=3D).=
i[0-9] $(@:.info=3D).i[0-9][0-9]; do \

dmake is one implementation that fails, and your suggestion doesn't work :/.
$ dmake foo/bar.o
dmake:  Error: -- Incomplete macro expression [)' b=3D'$(at_f:.o=3D)'; test=
 x"$$a.o" =3D x"$(@F)" || a=3D$$b;\
                echo $$a]

how portable is $() ?  that seems to work in GNU make & dmake.
$ cat Makefile
DEPDIR =3D ./$(@D)/depdir/$(@F:.o=3D$())
foo/bar.o:
	@echo $(DEPDIR)
$ dmake
=2E/foo//depdir/bar
-mike

--uWHEKhueEBlG8FRR
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmO2RtsACgkQQWM7n+g3
9YFcRg//VbESwjBO1w6pzuJbC4J1Se8N+S7csYCCh1k8M4FPjiIm4C+84+IGWIuX
R5G9LWZMzh7CvyJWrKpaHQzWDST5+wTNphByImezYwmf42YgrnV4Jf0+WNh4XgSa
PVmp062f9FFu6egMWr9NkwyuJMX//LAd9KVUR7kccez/te60bczvZlUskGdFxmaZ
1dvY10Ys9KT+gdpf/f9Ga6AdM4tUflX5+ciHhOMfZAqPk4Ff4PMv9qPKYG5JErjP
MoqNizVxeWoTUFyILXvyB5wKHQWxI8sJfEp1HmDwrNrq0q9B3+jHp01b26yAo0ZT
1c7Yt/0kJxximinI6BgPjSzn5pBdUVkpSuV4G3uVT1K4FJWZEUH42+v7rJGZ5pOz
eHYkP9dC9LTsb7+01SznmsvQkmWhTHZKagv/YQ3sxq1eh9zRvbLXt6mrOsVuRi7A
oF0Gok4nMwPU7AW3OxJ9qyGPqOG28olVQxNCbRS0EbUR3XnQVQNbnd4/hTYmxIpc
CsPJ+jb2Bfq/0dx0ruf2B7aP5wM/c0fdAM1w/wYMT7+9dDt23AOrAyt168MoE7hO
46ln8k4y1KS7/b2s0esQ04hz0F5bpkSI6LDMifcJR8j4NjEOkxvjhCSvD0WN8K54
mEJytGwcnCsqbnn90GddIIurhJPqb32FW0KRd5JnvXw24PeitDs=
=Jj5E
-----END PGP SIGNATURE-----

--uWHEKhueEBlG8FRR--




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at 60535 <at> debbugs.gnu.org:


Received: (at 60535) by debbugs.gnu.org; 5 Jan 2023 02:11:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jan 04 21:11:09 2023
Received: from localhost ([127.0.0.1]:49955 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pDFil-0006jH-HS
	for submit <at> debbugs.gnu.org; Wed, 04 Jan 2023 21:11:09 -0500
Received: from mail-vs1-f50.google.com ([209.85.217.50]:36461)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <nbowler@HIDDEN>) id 1pDFif-0006if-TX
 for 60535 <at> debbugs.gnu.org; Wed, 04 Jan 2023 21:11:06 -0500
Received: by mail-vs1-f50.google.com with SMTP id h27so23115547vsq.3
 for <60535 <at> debbugs.gnu.org>; Wed, 04 Jan 2023 18:11:01 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=draconx-ca.20210112.gappssmtp.com; s=20210112;
 h=cc:to:subject:message-id:date:from:references:in-reply-to
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=8vE71FLzynCVOfeoDu2JBwHgzT7CAD6Kj7+6aAWUzDg=;
 b=WioCXeiWYkv2crgntFW0JMOpOXYV4JZ6ow5C/sK/UXk2nOqq8GJdQXsS5k0zst36vB
 4ysaWwB4JEQBhc0M547rcgaOhlsH4Xg3RjpJVo+oNFxDIog7N7yeh7G0aWNUT63zbbb9
 djj3ZELHHnk+GRvnUdKbt5nSBVfAVZyFX8Gy6hmh3AOiBbv0/HC7AyybsxX6OltkP+5Z
 zeHI9+Js/T6hD894KEg+kzNbXHgXgwXRo/pdLyATiBGNdpA5y7SnH724uwyc0srrMX4G
 2zPhf624wIDPeNe9ZaFkpVfT8oM04UOoPqqpQhEVJ3m/pIso8QD5kwlIHTLhfCo79oBY
 WdTQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:from:references:in-reply-to
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=8vE71FLzynCVOfeoDu2JBwHgzT7CAD6Kj7+6aAWUzDg=;
 b=ii3dUdyS1NJ5ZqgS+QBX6BSu6aOHDCGl2bmo054mR/rztINComUGdj2PHtAosOzJ/C
 850gu/3azhdjCGdpJYNaJwFeDxqdOdK+qDPWa1yHw7+O6AhEiMRZiljJM1G3q7xP6Owk
 9AtFvXcldwUVhes9jyEL6YSAmo5hhZtuIujW7b0NCE/7D6SkCiAll9SL6sqJsThYt3AO
 hRl1WL4+Sw75eBxUarNRUnNIL3tPPbHeFqKRGjpJHJRs+mCctpix9ssXr9RHm7xYVU8d
 N8OJ/hD1aUczaT08H/h5tw5ggM7tbdhgRUB3IavCSL2ME4KxIfEVCT+JGZKEI6OhuTKw
 fy1Q==
X-Gm-Message-State: AFqh2kpDQugRrhnCXpwV9eXAwDditaMYzFGHX2WnRP52Jb01EpDGPS+H
 EJJkl+tAmLYgelShQWS0Zq4w5Ro3aVqVTy42uW8yTzUIC7iEogYU
X-Google-Smtp-Source: AMrXdXuvnPcrFxAJhLcw02Jr04LNHnZ8AzFiDNmE8AQzBfEtA95/ESBtM++u/ev+8VT0Eo3L1kmgkeqmAKbEk/Awo1M=
X-Received: by 2002:a67:b205:0:b0:3b0:eec8:ce04 with SMTP id
 b5-20020a67b205000000b003b0eec8ce04mr6800494vsf.16.1672884656126; Wed, 04 Jan
 2023 18:10:56 -0800 (PST)
MIME-Version: 1.0
Received: by 2002:ab0:5bda:0:b0:47d:bf4d:494 with HTTP; Wed, 4 Jan 2023
 18:10:55 -0800 (PST)
X-Originating-IP: [24.53.241.20]
In-Reply-To: <20230104020646.22620-1-vapier@HIDDEN>
References: <20230104020646.22620-1-vapier@HIDDEN>
From: Nick Bowler <nbowler@HIDDEN>
Date: Wed, 4 Jan 2023 21:10:55 -0500
Message-ID: <CADyTPExn47Fa6W=WY0jiNbBnmz2bNr-+d6O9Xf=q3Cue3Ramdg@HIDDEN>
Subject: Re: [bug#60535] [PATCH] depend2: switch echo|sed to automatic vars
To: Mike Frysinger <vapier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60535
Cc: 60535 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

On 2023-01-03, Mike Frysinger <vapier@HIDDEN> wrote:
> The echo|sed is used to split the dirname & filename so it can insert
> $(DEPDIR) in the middle, and then chop the trailing object suffix.  In
> the generic case, %OBJ% is $@, so we can leverage the POSIX vars $(@D)
> and $(@F) to do the pathname splitting and insert $(DEPDIR) in between.
> For chopping the object suffix, we can use the $(xxx:...=...) syntax.
> This avoids invoking sed completely.

I think this is a generally good idea.

> These dirname/filename vars have been in POSIX since at least 2004.

Except for one minor detail, $(@F) and $(@D) are highly portable.  I
expect they were in the very first POSIX.2 specs as they predate the
earliest standards; I believe they first appeared in UNIX System V (ca.
1983) and were later added to BSD in 4.3BSD-Reno (ca. 1990).

The only potential problem I am aware of with these features is one
implementation (dmake) which does not follow the POSIX rule of excluding
the trailing slash from the directory part, and (a bit more troublesome)
will expand $(@D) to the empty string if the directory part is empty,
instead of . as required by POSIX.  Usually this is not a major issue,
as writing something like ./$(@D)/$(@F) is usually sufficient to avoid
any problems with empty $(@D).

It's worth noting that $(?F), $(?D), $(%F) and $(%D) were never added
to BSD and as a result are missing from many BSD derivatives.  However,
these variables are of limited utility and are unlikely to be missed.

The $(x:a=b) suffix substitutions are of identical vintage, and as
far as I know every make supporting file/directory variables also,
in principle, supports suffix substitution too.  However, there are
many bugs in real-world implementations of this feature.

Of particular relevance to this patch: older versions of NetBSD make,
while they do support suffix substitution, fail to correctly parse
$(@F:.o=):

  % cat >Makefile <<'EOF'
foo/bar.o:
	echo $(@F:.o=)
EOF
  % make
  echo bar.o.o=)
  Syntax error: ")" unexpected
  *** Error code 2

NetBSD make was widely adopted by other systems, so this particular
issue may actually be found elsewhere.  This bug was present as recently
as NetBSD 7.2 (ca. 2018).  Furthermore, old versions of FreeBSD (before
they ditched their own make in favour of NetBSD's version) also fail to
correctly handle $(@F:.o=), but in a different way.

The good news is that these problems can be worked around pretty easily
simply by using another variable:

  % cat >Makefile <<'EOF'
at_f = $(@F)
foo/bar.o:
	echo $(at_f:.o=)
EOF
  % make
  echo bar
  bar

But this workaround trips over a different suffix substitution bug on
ULTRIX, which would otherwise work just fine with plain $(@F:.o=).
Maybe ULTRIX is not worth worrying about these days, but nevertheless,
it is not too hard to detect and work around both problems in pure
shell, which should still work to avoid the additional forks/sed,
maybe something like:

  % cat >Makefile <<'EOF'
at_f = $(@F)
foo/bar.o:
	a='$(@F:.o=)' b='$(at_f:.o=)'; test x"$$a.o" = x"$(@F)" || a=$$b;\
	  echo $$a
EOF

Cheers,
  Nick




Information forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 4 Jan 2023 02:07:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 03 21:07:05 2023
Received: from localhost ([127.0.0.1]:47198 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pCtBJ-0003v1-0u
	for submit <at> debbugs.gnu.org; Tue, 03 Jan 2023 21:07:05 -0500
Received: from lists.gnu.org ([209.51.188.17]:52622)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <vapier@HIDDEN>) id 1pCtBE-0003uZ-1a
 for submit <at> debbugs.gnu.org; Tue, 03 Jan 2023 21:07:03 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <vapier@HIDDEN>) id 1pCtB9-0003vv-GQ
 for automake-patches@HIDDEN; Tue, 03 Jan 2023 21:06:57 -0500
Received: from smtp.gentoo.org ([2001:470:ea4a:1:5054:ff:fec7:86e4])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_CHACHA20_POLY1305:256)
 (Exim 4.90_1) (envelope-from <vapier@HIDDEN>) id 1pCtB5-0006KK-NB
 for automake-patches@HIDDEN; Tue, 03 Jan 2023 21:06:53 -0500
Received: by smtp.gentoo.org (Postfix, from userid 559)
 id 6E248335C8E; Wed,  4 Jan 2023 02:06:49 +0000 (UTC)
From: Mike Frysinger <vapier@HIDDEN>
To: automake-patches@HIDDEN
Subject: [PATCH] depend2: switch echo|sed to automatic vars
Date: Tue,  3 Jan 2023 21:06:46 -0500
Message-Id: <20230104020646.22620-1-vapier@HIDDEN>
X-Mailer: git-send-email 2.39.0
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2001:470:ea4a:1:5054:ff:fec7:86e4;
 envelope-from=vapier@HIDDEN; helo=smtp.gentoo.org
X-Spam_score_int: -41
X-Spam_score: -4.2
X-Spam_bar: ----
X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

The echo|sed is used to split the dirname & filename so it can insert
$(DEPDIR) in the middle, and then chop the trailing object suffix.  In
the generic case, %OBJ% is $@, so we can leverage the POSIX vars $(@D)
and $(@F) to do the pathname splitting and insert $(DEPDIR) in between.
For chopping the object suffix, we can use the $(xxx:...=...) syntax.
This avoids invoking sed completely.

These dirname/filename vars have been in POSIX since at least 2004.
https://pubs.opengroup.org/onlinepubs/009695399/utilities/make.html
> Each of the internal macros has an alternative form. When an
> uppercase 'D' or 'F' is appended to any of the macros, the
> meaning shall be changed to the directory part for 'D' and
> filename part for 'F'. The directory part is the path prefix
> of the file without a trailing slash; for the current directory,
> the directory part is '.'.

* lib/am/depend2.am: Change echo|sed logic to make variables.
---
 lib/am/depend2.am | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/am/depend2.am b/lib/am/depend2.am
index 507fa40b54a0..87546f9d8274 100644
--- a/lib/am/depend2.am
+++ b/lib/am/depend2.am
@@ -42,7 +42,7 @@ if %FASTDEP%
 ?!GENERIC?	%SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
 ?GENERIC??!SUBDIROBJ?	%VERBOSE%%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE%
 ?GENERIC??!SUBDIROBJ?	%SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??SUBDIROBJ?	%VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+?GENERIC??SUBDIROBJ?	%VERBOSE%depbase='$(@D)/$(DEPDIR)/$(@F:.o=)';\
 ?GENERIC??SUBDIROBJ?	%COMPILE% -MT %OBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJ% %SOURCEFLAG%%SOURCE% &&\
 ?GENERIC??SUBDIROBJ?	$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
 else !%FASTDEP%
@@ -69,7 +69,7 @@ if %FASTDEP%
 ?!GENERIC?	%SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
 ?GENERIC??!SUBDIROBJ?	%VERBOSE%%COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'`
 ?GENERIC??!SUBDIROBJ?	%SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
-?GENERIC??SUBDIROBJ?	%VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+?GENERIC??SUBDIROBJ?	%VERBOSE%depbase='$(@D)/$(DEPDIR)/$(@F:.obj=)';\
 ?GENERIC??SUBDIROBJ?	%COMPILE% -MT %OBJOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %OBJOBJ% %SOURCEFLAG%`$(CYGPATH_W) '%SOURCE%'` &&\
 ?GENERIC??SUBDIROBJ?	$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Po
 else !%FASTDEP%
@@ -98,7 +98,7 @@ if %FASTDEP%
 ?!GENERIC?	%SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Plo
 ?GENERIC??!SUBDIROBJ?	%VERBOSE%%LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCEFLAG%%SOURCE%
 ?GENERIC??!SUBDIROBJ?	%SILENT%$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Plo
-?GENERIC??SUBDIROBJ?	%VERBOSE%depbase=`echo %OBJ% | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+?GENERIC??SUBDIROBJ?	%VERBOSE%depbase='$(@D)/$(DEPDIR)/$(@F:.lo=)';\
 ?GENERIC??SUBDIROBJ?	%LTCOMPILE% -MT %LTOBJ% -MD -MP -MF %DEPBASE%.Tpo %-c% -o %LTOBJ% %SOURCEFLAG%%SOURCE% &&\
 ?GENERIC??SUBDIROBJ?	$(am__mv) %DEPBASE%.Tpo %DEPBASE%.Plo
 else !%FASTDEP%
-- 
2.39.0





Acknowledgement sent to Mike Frysinger <vapier@HIDDEN>:
New bug report received and forwarded. Copy sent to automake-patches@HIDDEN. Full text available.
Report forwarded to automake-patches@HIDDEN:
bug#60535; Package automake-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 25 Nov 2023 21:45:01 UTC

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