Improve ELF shared library handling

Pass in -rpath-link option to the linker so that blkid will build
correctly on systems that don't have libcom_err.so.2 installed.

Fix debugfs to only try to link with -ldl when building without shared
libraries; with ELF shared libraries, the library which requires -ldl
(libss.so) can required the library dependency itself.

Fix how we build tune2fs.static so that we use @LDFLAG_STATIC@, via
$(LDFLAGS_STATIC), instead of hard-coding the use of -static.

Addresses-Sourceforge-Bug: #2088537

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/configure.in b/configure.in
index fcca2ac..7ec6945 100644
--- a/configure.in
+++ b/configure.in
@@ -211,6 +211,8 @@
 dnl This needs to be before all of the --enable-*-shlibs options
 dnl
 E2_PKG_CONFIG_STATIC=--static
+LDFLAG_DYNAMIC=
+PRIVATE_LIBS_CMT=
 dnl
 dnl handle --enable-elf-shlibs
 dnl
@@ -232,6 +234,8 @@
 	esac]
 	BINARY_TYPE=elfbin
 	LIB_EXT=.so
+	PRIVATE_LIBS_CMT=#
+	LDFLAG_DYNAMIC=['-Wl,-rpath-link,$(top_builddir)/lib']
 	AC_MSG_RESULT([Enabling ELF shared libraries])
 fi
 ,
@@ -322,6 +326,8 @@
 AC_SUBST(LIB_EXT)
 AC_SUBST(STATIC_LIB_EXT)
 AC_SUBST(PROFILED_LIB_EXT)
+AC_SUBST(LDFLAG_DYNAMIC)
+AC_SUBST(PRIVATE_LIBS_CMT)
 dnl
 dnl handle --enable-jbd-debug
 dnl
@@ -921,4 +927,3 @@
 done
 AC_OUTPUT($outlist)
 if test -f util/gen-tarball; then chmod +x util/gen-tarball; fi
-