- sed -r '/^-l(pthread|nl)/! s,(^-l)(.*),\1:lib\2.a,'
+ sed -r "/^-l($deps)/! s,(^-l)(.*),\1:lib\2.a," | # explicit .a
+ sed -n '/^-[Ll]/p' | # extra link options may break with make
+ tac |
+ awk "/^-l:$lib.a/&&c++ {next} 1" | # drop first duplicates of main lib
+ tac