From 6899557f13de1cb1c4e32a3fae5a4832e85b8499 Mon Sep 17 00:00:00 2001
From: Saul Wold <sgw@linux.intel.com>
Date: Wed, 16 Aug 2017 11:16:30 +0800
Subject: [PATCH] use pkgconfig instead of npth config

Upstream-Status: Inappropriate [openembedded specific]

Signed-off-by: Saul Wold <sgw@linux.intel.com>

Rebase to 2.1.23
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 m4/npth.m4 | 53 ++++++++---------------------------------------------
 1 file changed, 8 insertions(+), 45 deletions(-)

diff --git a/m4/npth.m4 b/m4/npth.m4
index 619ed89..0cb354d 100644
--- a/m4/npth.m4
+++ b/m4/npth.m4
@@ -19,25 +19,10 @@ AC_DEFUN([_AM_PATH_NPTH_CONFIG],
   if test "x$npth_config_prefix" != x ; then
       NPTH_CONFIG="$npth_config_prefix/bin/npth-config"
   fi
+  AC_PATH_PROG(PKGCONFIG, pkg-config, no)
 
-  use_gpgrt_config=""
-  if test x"$GPGRT_CONFIG" != x -a "$GPGRT_CONFIG" != "no"; then
-    if $GPGRT_CONFIG npth --exists; then
-      NPTH_CONFIG="$GPGRT_CONFIG npth"
-      AC_MSG_NOTICE([Use gpgrt-config as npth-config])
-      use_gpgrt_config=yes
-    fi
-  fi
-  if test -z "$use_gpgrt_config"; then
-    AC_PATH_PROG(NPTH_CONFIG, npth-config, no)
-  fi
-
-  if test "$NPTH_CONFIG" != "no" ; then
-    if test -z "$use_gpgrt_config"; then
-      npth_version=`$NPTH_CONFIG --version`
-    else
-      npth_version=`$NPTH_CONFIG --modversion`
-    fi
+  if test "$PKGCONFIG" != "no" ; then
+    npth_version=`$PKGCONFIG --modversion npth`
   fi
   npth_version_major=`echo $npth_version | \
                sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'`
@@ -62,7 +47,7 @@ AC_DEFUN([AM_PATH_NPTH],
 
   AC_MSG_CHECKING(for NPTH - version >= $min_npth_version)
   ok=no
-  if test "$NPTH_CONFIG" != "no" ; then
+  if test "$PKGCONFIG" != "no" ; then
     req_major=`echo $min_npth_version | \
                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
     req_minor=`echo $min_npth_version | \
@@ -83,32 +68,9 @@ AC_DEFUN([AM_PATH_NPTH],
   fi
   if test $ok = yes; then
     AC_MSG_RESULT([yes ($npth_version)])
-  else
-    AC_MSG_RESULT(no)
-  fi
-  if test $ok = yes; then
-    # If we have a recent NPTH, we should also check that the
-    # API is compatible.
-    if test "$req_npth_api" -gt 0 ; then
-      if test -z "$use_gpgrt_config"; then
-        tmp=`$NPTH_CONFIG --api-version 2>/dev/null || echo 0`
-      else
-        tmp=`$NPTH_CONFIG --variable=api_version 2>/dev/null || echo 0`
-      fi
-      if test "$tmp" -gt 0 ; then
-        AC_MSG_CHECKING([NPTH API version])
-        if test "$req_npth_api" -eq "$tmp" ; then
-          AC_MSG_RESULT([okay])
-        else
-          ok=no
-          AC_MSG_RESULT([does not match. want=$req_npth_api got=$tmp])
-        fi
-      fi
-    fi
-  fi
-  if test $ok = yes; then
-    NPTH_CFLAGS=`$NPTH_CONFIG --cflags`
-    NPTH_LIBS=`$NPTH_CONFIG --libs`
+    NPTH_CFLAGS=`$PKGCONFIG --cflags npth`
+    NPTH_LIBS=`$PKGCONFIG --libs npth`
+    AC_MSG_WARN([[GOT HERE - $NPTH_LIBS ]])
     ifelse([$2], , :, [$2])
     if test -z "$use_gpgrt_config"; then
       npth_config_host=`$NPTH_CONFIG --host 2>/dev/null || echo none`
@@ -128,6 +90,7 @@ AC_DEFUN([AM_PATH_NPTH],
       fi
     fi
   else
+    AC_MSG_RESULT(no)
     NPTH_CFLAGS=""
     NPTH_LIBS=""
     ifelse([$3], , :, [$3])
