On Wed, Jun 8, 2022 at 4:43 PM David Laight <David.Laight@xxxxxxxxxx> wrote: > > From: Kevin Locke > > Sent: 07 June 2022 03:43 > > > > In 22f26f21774f8 awk was added to deduplicate *.mod files. > > Can't this be done with gmake's $(sort) function? > > $(sort list) > > Sorts the words of list in lexical order, removing duplicate words. > The output is a list of words separated by single spaces. $(sort ...) does two things, - sort the list alphabetically - deduplicate the elements in the list I want to do only deduplication without changing the order. > > ... > > # To make this rule robust against "Argument list too long" error, > > # ensure to add $(obj)/ prefix by a shell command. > > -cmd_mod = echo $(call real-search, $*.o, .o, -objs -y -m) | \ > > - $(AWK) -v RS='( |\n)' '!x[$$0]++ { print("$(obj)/"$$0) }' > $@ > > +cmd_mod = printf '%s\n' $(call real-search, $*.o, .o, -objs -y -m) | \ > > + $(AWK) '!x[$$0]++ { print("$(obj)/"$$0) }' > $@ > > I think the above only works because 'printf' is (usually) a > shell builtin - so the kernel's argv[] limit doesn't apply. > So the comment isn't really right. Is there any difference if 'printf' were not built-in? Right, for bash and dash, yes, 'printf' is built-in, and we do not need to be worried about "Argument list too long", but I am not sure if we are able to cover all the systems. > But I think: > > cmd_mod = $(addprefix $(obj)/,$(sort $(call real-search, $*.o, .o, -objs -y -m))) >$@ > > will have the required effect. I think 'echo' is missing here. As I noted above, I do not want to change the order. > Without forking and execing multiple processes. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) > -- Best Regards Masahiro Yamada