> On 29 Mar 2025, at 15:28, Jakub Jelinek <ja...@redhat.com> wrote:
>
> On Sat, Mar 29, 2025 at 03:18:20PM +0000, Iain Sandoe wrote:
>> Hi Jakub
>>
>> Thanks for doing this...
>>
>>> On 28 Mar 2025, at 14:39, Jakub Jelinek <ja...@redhat.com> wrote:
>>>
>>> +cobol/charmaps.cc cobol/valconv.cc: cobol/%.cc: $(LIB_SOURCE)/%.cc
>>> + -l='ec\|common-defs\|io\|gcobolio\|libgcobol\|gfileio\|charmaps'; \
>>> + l=$$l'\|valconv\|exceptl'; \
>>> + sed -e '/^#include/s,"\('$$l'\)\.h","../../libgcobol/\1.h",' $^ > $@
>>
>> .. however, this does not work with the BSD sed on Darwin (although it does
>> with GNU sed on Darwin).
>>
>> The issue appears to be that alternation is an ERE addition from my reading
>> of
>> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03
>> (the Darwin BRE sed works fine when there is only one match in the
>> sub-expression,
>> but fails as soon as any alternate is added).
>>
>> Darwin’s sed (and at least x86_64 / aarch64 Linux sed) work fine with the
>> updated patch
>> to use an ERE instead. Do you think this is an acceptable update? (it is
>> still POSIX sed).
>
> I'm not sure if sed -E is portable enough (sure, I know it is in POSIX, but
> that is not enough).
> How about just
> sed -e '/^#include/s,"\([^"]*.h\)","../../libgcobol/\1",' $& > $@
This, unfortunately, works too well (with s/&/^) .. because it also processes
#include “config.h”
which then points to a non-existent file. I think we want to include config
for both FE and
library (so we cannot get around it by indenting the config.h include - well we
could, but …)
trying to think of variations on this theme.
Iain
> ?
> I mean, both charmaps.cc and valconv.cc use #include <> for system headers
> and #include "" for local headers and we want to adjust all of the latter
> and none of the former?
>
>> diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in
>> index 990d51a8578..bbf1c9ef30e 100644
>> --- a/gcc/cobol/Make-lang.in
>> +++ b/gcc/cobol/Make-lang.in
>> @@ -88,9 +88,8 @@ cobol1_OBJS = \
>> # so that the .h files can be found.
>>
>> cobol/charmaps.cc cobol/valconv.cc: cobol/%.cc: $(LIB_SOURCE)/%.cc
>> - -l='ec\|common-defs\|io\|gcobolio\|gfileio\|charmaps'; \
>> - l=$$l'\|valconv\|exceptl'; \
>> - sed -e '/^#include/s,"\('$$l'\)\.h","../../libgcobol/\1.h",' $^ > $@
>> + -l='ec|common-defs|io|gcobolio|gfileio|charmaps|valconv|exceptl'; \
>> + sed -E -e '/^#include/s,"('$$l')\.h","../../libgcobol/\1.h",' $^ > $@
>>
>> LIB_SOURCE_H=$(wildcard $(LIB_SOURCE)/*.h)
>>
>
> Jakub
>