configure.in: add --disable-libblkid option

Add an option to switch between the private (in-tree) libblkid and
public (in-system installed) library.  The private version is still
enabled by default.

If --disable-libblkid is specified the findfs(8) program, which is a
variant of tune2fs, is also not built or installed.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/configure b/configure
index cf1bc1b..4dee536 100755
--- a/configure
+++ b/configure
@@ -687,6 +687,14 @@
 LDFLAG_DYNAMIC
 PRIVATE_LIBS_CMT
 TEST_IO_CMT
+PKG_CONFIG
+LIBBLKID
+DEPLIBBLKID
+STATIC_LIBBLKID
+DEPSTATIC_LIBBLKID
+PROFILED_LIBBLKID
+DEPPROFILED_LIBBLKID
+BLKID_CMT
 DEBUGFS_CMT
 IMAGER_CMT
 RESIZER_CMT
@@ -786,7 +794,8 @@
 LDFLAGS
 LIBS
 CPPFLAGS
-CPP'
+CPP
+PKG_CONFIG'
 
 
 # Initialize some variables set by options.
@@ -1369,6 +1378,7 @@
   --enable-jbd-debug  	  enable journal debugging
   --enable-blkid-debug    enable blkid debugging
   --disable-testio-debug  disable the use of the test I/O manager for debugging
+  --disable-libblkid	  do not build private blkid library
   --disable-debugfs   	  disable support of debugfs program
   --disable-imager   	  disable support of e2image program
   --disable-resizer   	  disable support of e2resize program
@@ -1404,6 +1414,7 @@
   CPPFLAGS    C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
   CPP         C preprocessor
+  PKG_CONFIG  path to pkg-config utility
 
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
@@ -3755,7 +3766,7 @@
 fi
 LIB_EXT=.a
 STATIC_LIB_EXT=.a
-PROFILE_LIB_EXT=.a
+PROFILED_LIB_EXT=.a
 
 # Check whether --with-ldopts was given.
 if test "${with_ldopts+set}" = set; then
@@ -4042,6 +4053,254 @@
 fi
 
 
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+        if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+  { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5
+echo "${ECHO_T}$PKG_CONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+  ac_pt_PKG_CONFIG=$PKG_CONFIG
+  # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }
+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  case $ac_pt_PKG_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+  { echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5
+echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6; }
+else
+  { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+fi
+
+  if test "x$ac_pt_PKG_CONFIG" = x; then
+    PKG_CONFIG=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&5
+echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools
+whose name does not start with the host triplet.  If you think this
+configuration is useful to you, please write to autoconf@gnu.org." >&2;}
+ac_tool_warned=yes ;;
+esac
+    PKG_CONFIG=$ac_pt_PKG_CONFIG
+  fi
+else
+  PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+        _pkg_min_version=0.9.0
+        { echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5
+echo $ECHO_N "checking pkg-config is at least version $_pkg_min_version... $ECHO_C" >&6; }
+        if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+                { echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6; }
+        else
+                { echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6; }
+                PKG_CONFIG=""
+        fi
+
+fi
+LIBBLKID=
+DEPLIBBLKID=
+STATIC_LIBBLKID=
+DEPSTATIC_LIBBLKID=
+PROFILED_LIBBLKID=
+DEPPROFILED_LIBBLKID=
+BLKID_CMT=
+# Check whether --enable-libblkid was given.
+if test "${enable_libblkid+set}" = set; then
+  enableval=$enable_libblkid; if test "$enableval" = "no"
+then
+	if test -z "$PKG_CONFIG"; then
+		{ { echo "$as_me:$LINENO: error: pkg-config not installed; please install it." >&5
+echo "$as_me: error: pkg-config not installed; please install it." >&2;}
+   { (exit 1); exit 1; }; }
+	fi
+
+	{ echo "$as_me:$LINENO: checking for blkid_get_cache in -lblkid" >&5
+echo $ECHO_N "checking for blkid_get_cache in -lblkid... $ECHO_C" >&6; }
+if test "${ac_cv_lib_blkid_blkid_get_cache+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lblkid $LIBBLKID $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char blkid_get_cache ();
+int
+main ()
+{
+return blkid_get_cache ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_blkid_blkid_get_cache=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_blkid_blkid_get_cache=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_blkid_blkid_get_cache" >&5
+echo "${ECHO_T}$ac_cv_lib_blkid_blkid_get_cache" >&6; }
+if test $ac_cv_lib_blkid_blkid_get_cache = yes; then
+  LIBBLKID=`$PKG_CONFIG --libs blkid`;
+		 STATIC_LIBBLKID=`$PKG_CONFIG --static --libs blkid`
+else
+  { { echo "$as_me:$LINENO: error: external blkid library not found" >&5
+echo "$as_me: error: external blkid library not found" >&2;}
+   { (exit 1); exit 1; }; }
+fi
+
+	BLKID_CMT=#
+	{ echo "$as_me:$LINENO: result: Disabling private blkid library" >&5
+echo "${ECHO_T}Disabling private blkid library" >&6; }
+else
+	LIBBLKID='$(LIB)/libblkid'$LIB_EXT
+	DEPLIBBLKID=$LIBBLKID
+	STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT
+	DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID
+	PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT
+	DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID
+	cat >>confdefs.h <<\_ACEOF
+#define CONFIG_BUILD_FINDFS 1
+_ACEOF
+
+	{ echo "$as_me:$LINENO: result: Enabling private blkid library" >&5
+echo "${ECHO_T}Enabling private blkid library" >&6; }
+fi
+
+else
+  LIBBLKID='$(LIB)/libblkid'$LIB_EXT
+DEPLIBBLKID=$LIBBLKID
+STATIC_LIBBLKID='$(LIB)/libblkid'$STATIC_LIB_EXT
+DEPSTATIC_LIBBLKID=$STATIC_LIBBLKID
+PROFILED_LIBBLKID='$(LIB)/libblkid'$PROFILED_LIB_EXT
+DEPPROFILED_LIBBLKID=$PROFILED_LIBBLKID
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_BUILD_FINDFS 1
+_ACEOF
+
+{ echo "$as_me:$LINENO: result: Enabling private blkid library by default" >&5
+echo "${ECHO_T}Enabling private blkid library by default" >&6; }
+
+fi
+
+
+
+
+
+
+
+
 # Check whether --enable-debugfs was given.
 if test "${enable_debugfs+set}" = set; then
   enableval=$enable_debugfs; if test "$enableval" = "no"
@@ -16286,6 +16545,14 @@
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
 TEST_IO_CMT!$TEST_IO_CMT$ac_delim
+PKG_CONFIG!$PKG_CONFIG$ac_delim
+LIBBLKID!$LIBBLKID$ac_delim
+DEPLIBBLKID!$DEPLIBBLKID$ac_delim
+STATIC_LIBBLKID!$STATIC_LIBBLKID$ac_delim
+DEPSTATIC_LIBBLKID!$DEPSTATIC_LIBBLKID$ac_delim
+PROFILED_LIBBLKID!$PROFILED_LIBBLKID$ac_delim
+DEPPROFILED_LIBBLKID!$DEPPROFILED_LIBBLKID$ac_delim
+BLKID_CMT!$BLKID_CMT$ac_delim
 DEBUGFS_CMT!$DEBUGFS_CMT$ac_delim
 IMAGER_CMT!$IMAGER_CMT$ac_delim
 RESIZER_CMT!$RESIZER_CMT$ac_delim
@@ -16371,7 +16638,7 @@
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 84; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 92; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5