make_relative: fix bug when last pathname part matches partially

with for example "/foo" and "/foobar", the result was "bar"
instead of "../foobar".
also fix potential endless loop when the same string is passed
twice.
print config file name
respect LDFLAGS