From nobody Thu Apr 25 17:43:42 2024 X-Original-To: questions@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VQNWN2hY9z5JCfM for ; Thu, 25 Apr 2024 17:43:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VQNWN1SBdz4R78 for ; Thu, 25 Apr 2024 17:43:44 +0000 (UTC) (envelope-from kevans@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714067024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noS9DnYfWebhNX4BMYN5Qke7nnuJxxLnE++NRqbBNNU=; b=marqsXp70vZtzpTW5wBFTaltwXDxgOmoHJq6EmxcT41F2g6dBPs7I0+wFZhgQpgh0HSfNs DarohQTQ+5Pg4nCCUya7nPJvIjyDU/C4Xr3Mgwq8RjdWJ3KEdYwQlxWwh6nFqeljwq6vMg T11ocbl1Mstd8e53UuOvzUjRDKOd3PoVBQk8RcL35LtxxUjoEMC1YL2qVwIhPunREj9Ekz 3mDaEyAO7Bm0TPf0oGUsUnVbbCH3EpCwPiBG5KXrQk6UAv8fNUoEN5IIHa7JBIwQbxHKbn INM5DWENFx/YtKwDejMSTBC6BJnSlVw7rbLXPVvHGEuigopGoXCOIADV2EEBvg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1714067024; a=rsa-sha256; cv=none; b=CFvu5qXNxAWVIJCeXyBS1TvBGWMKTGmQo9n1XRmRa2Xpkw/LuPk3VkL3VeC8bkuC+lvTBP D4WwpEAogL81pEBAdn3QNqMAZeJpeNaGVcxJd7WL5VarYpfSFw94h4qebmfIFItTlXsGgr FQ7cIQ1dPkwHIsuJ3KYau65Zwp2agzWJrz+HRlK3CmhqSCtw21S6337ZlbNHJ+3kuIPuby aKl4v/dophQfhKptb5Qj0Y08IEp6us1HinehbLKRoA0hnyhsnAMCh7cQs0kArkmfNrn5o5 vKO6ORHi2kWIeW3/E3A/n8VzKGS4vhzmamqUP0BFLTlnS5nfOErJ/iHZo+nRmA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1714067024; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=noS9DnYfWebhNX4BMYN5Qke7nnuJxxLnE++NRqbBNNU=; b=TTIhhhgqHu7jCHIFmA5S8LOYxAUH2dt6CcjVQ7m4PxiwD1gMQ0YqjNjnWMe3tsJliui5Re kC9PHAeZZjSMDzRBK7Uxf3lnz3HG9xWsitIrqgpdShlZ06qUbaPGcxl5x3lo/1podKuxBq L1+Ek4y9PISarlfkb4fr4lq1eg0EykLIv5cIoROZ7h1CTT/NqO0rUTqSOwfiEtubdu/xvx tLpn25xhYQC8hORR5YUWv+UqTWdvaEpyaI5ykkPkQdG9/MrlGlhy4wCkKWkOVupUauyrbX 8toeToUiupqIgYhX6tzCN1lXDwtEVN+84k4r3jfSrSLq2QaHpojfXz1DrDnB/A== Received: from [10.9.4.95] (unknown [209.182.120.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: kevans/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4VQNWM6ybQzfjS for ; Thu, 25 Apr 2024 17:43:43 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Message-ID: <493f8ca1-75e1-4ae6-8641-5998c53457cb@FreeBSD.org> Date: Thu, 25 Apr 2024 12:43:42 -0500 List-Id: User questions List-Archive: https://lists.freebsd.org/archives/freebsd-questions List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: freebsd-questions@freebsd.org Sender: owner-freebsd-questions@FreeBSD.org MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bsd sed / make vs bsd sed / make To: questions@freebsd.org References: Content-Language: en-US From: Kyle Evans In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/25/24 12:36, Tomek CEDRO wrote: > Hello world :-) > > Are there any SED and MAKE experts around? :-) > > There is a piece of Makefile within NuttX RTOS simulator code that > creates the linker scripts. I would like to fix the upstream so it > builds out of the box on FreeBSD (*BSD). > > sed -e '/====/,/====/!d;//d' -e 's/__executable_start/_stext/g' \ > -e 's/^\(\s\+\)\(\.init_array\)/\1\2 : { }\n\1.sinit/g' \ > -e 's/^\(\s\+\)\(\.fini_array\)/\1\2 : { }\n\1.einit/g' \ > -e 's/__init_array_start/_sinit/g' -e 's/__init_array_end/_einit/g' \ > -e 's/__fini_array_start/_sfini/g' -e > 's/__fini_array_end/_efini/g' >nuttx.ld > Everything about this is cursed. IMO you should propose switching these to EREs (-E) and fixing all of the escaped things as appropriate for that switch, then substituting [[:space:]] in for \s to make them compliant expressions. > > It does not work with BSD sed but when I replace this with gsed all works fine. > > BSD sed complalins about trailinig backslash: > > sed: 1: "s/^\(\s\+\)\(\.init_arr ...": RE error: trailing backslash (\) > > Is there a way to fix that part so it works both with GNU sed and BSD > sed? The easiest way would be adding ${SEDCMD} set to "gsed" on BSD > and "sed" for the others (macOS also seems to use gnu sed). > The ports infrastructure also has a BINARY_ALIAS that can be used to install gsed as sed for just this build, assuming nothing that uses these 'enhanced' expressions hardcodes a path to sed. Thanks, Kyle Evans