mk: eliminate duplicates from libraries list
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 21 Mar 2016 11:33:57 +0000 (13:33 +0200)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Tue, 22 Mar 2016 19:42:47 +0000 (20:42 +0100)
Duplicates in LDLIBS can cause link failures from multiply defined
symbols, ensure all libraries are only mentioned once. Can't use
sorting for duplicate elimination as order is critical so awk one-liner
is used.

Signed-off-by: Panu Matilainen <pmatilai@redhat.com>
mk/rte.app.mk

index a1cd9a3..b2ed9e2 100644 (file)
@@ -174,6 +174,10 @@ _LDLIBS-y += --no-whole-archive
 
 LDLIBS += $(_LDLIBS-y) $(CPU_LDLIBS) $(EXTRA_LDLIBS)
 
+# Eliminate duplicates without sorting
+LDLIBS := $(shell echo $(LDLIBS) | \
+       awk '{for (i = 1; i <= NF; i++) { if (!seen[$$i]++) print $$i }}')
+
 .PHONY: all
 all: install