On Fri, 12 Feb 2021 at 14:45, Dave Chinner <david@xxxxxxxxxxxxx> wrote: > > So there's a rule like this generated: > > bitmap.lo: bitmap.c ../include/xfs.h ../include/xfs/linux.h \ > ../include/xfs/xfs_types.h ../include/xfs/xfs_fs_compat.h \ > ../include/xfs/xfs_fs.h ../include/platform_defs.h avl64.h \ > ../include/list.h bitmap.h > > The sed expression is: > > $(SED) -e 's,^\([^:]*\)\.o,\1.lo,' > > Which means it is supposed to match from the start of line to a ".o", > and store everything up to the ".o" in register 1. > > And the problem is that it is matching a ".o" in the middle of a > string. > > So existing behaviour: > > $ echo "foo.o/bitmap.o: bitmap.c ../include/xfs.h ../include/xfs/linux.h" | sed -e 's,^\([^:]*\)\.o,\1.lo,' > foo.o/bitmap.lo: bitmap.c ../include/xfs.h ../include/xfs/linux.h > $ > > Looks correct until the dependency line is split and the first entry > in the split line is something like "foo.o/uuid.h" > > Your modified version: > > $ echo "bitmap.o: bitmap.c ../include/xfs.h ../include/xfs/linux.h" | sed -e 's,^\([^:]*\)\.o$$,\1.lo,' > bitmap.o: bitmap.c ../include/xfs.h ../include/xfs/linux.h > $ > > Doesn't work for the case we actually need the substitution for. > > So, really, I think we need to match against the full target > specification rather than just ".o". > > Something like > > $SED -e 's,^\([^:]*\)\.o: ,\1.lo: ,' > > $ echo "foo.o/bitmap: bitmap.c ../include/xfs.h ../include/xfs/linux.h" | sed -e 's,^\([^:]*\)\.o: ,\1.lo: ,' > foo.o/bitmap: bitmap.c ../include/xfs.h ../include/xfs/linux.h > $ echo "foo.o/bitmap.o: bitmap.c ../include/xfs.h ../include/xfs/linux.h" | sed -e 's,^\([^:]*\)\.o: ,\1.lo: ,' > foo.o/bitmap.lo: bitmap.c ../include/xfs.h ../include/xfs/linux.h Thanks. I just tried your suggestion. Looks like it's working for my situation. I'll submit a v2 of the patch. Regards, -Markus