From 320b9654526f3a225cef071f927c7a4bcfec538f Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Fri, 30 Dec 2011 23:01:13 +0000
Subject: [PATCH] Call pkg-config less often

[[Imported from SVN: r5145]]
---
 m4/ipopt.m4 | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/m4/ipopt.m4 b/m4/ipopt.m4
index 5a5fe335..fb54366f 100644
--- a/m4/ipopt.m4
+++ b/m4/ipopt.m4
@@ -38,21 +38,22 @@ AS_IF([test x$with_ipopt != xno], [
 	AC_MSG_WARN([IPOpt not found in $IPOPTROOT])
     ])
 
-    AC_LANG_PUSH([C++])
 
-    LDFLAGS="$LDFLAGS -L$IPOPT_LIB_PATH"
+    IPOPT_LDFLAGS="`PKG_CONFIG_PATH=$IPOPT_LIB_PATH/pkgconfig $PKG_CONFIG --libs-only-L ipopt`"
+    LDFLAGS="$LDFLAGS $IPOPT_LDFLAGS"
     IPOPT_CPPFLAGS="-I$IPOPTROOT/include"
     CPPFLAGS="$CPPFLAGS $IPOPT_CPPFLAGS"
+    IPOPT_LIBS="`PKG_CONFIG_PATH=$IPOPT_LIB_PATH/pkgconfig $PKG_CONFIG --libs-only-l ipopt`"
+    LIBS="$LIBS $IPOPT_LIBS"
+
+    AC_LANG_PUSH([C++])
 
     # if header is found...
     AS_IF([test x$HAVE_IPOPT = x1], [
-       LIBS="$LIBS `PKG_CONFIG_PATH=$IPOPT_LIB_PATH/pkgconfig $PKG_CONFIG --libs ipopt`"
-
        AC_LINK_IFELSE(AC_LANG_PROGRAM(
 	    [#include "coin/IpIpoptApplication.hpp"],
 	    [Ipopt::SmartPtr<Ipopt::IpoptApplication> app = new Ipopt::IpoptApplication();]),
-	[IPOPT_LIBS="`PKG_CONFIG_PATH=$IPOPT_LIB_PATH/pkgconfig $PKG_CONFIG --libs-only-l ipopt`"
-	     IPOPT_LDFLAGS="`PKG_CONFIG_PATH=$IPOPT_LIB_PATH/pkgconfig $PKG_CONFIG --libs-only-L ipopt`"],
+	[],
 	[HAVE_IPOPT="0"
 	AC_MSG_WARN(IPOpt not found!)])
     ])
@@ -76,7 +77,9 @@ AS_IF([test x$HAVE_IPOPT = x1], [
   # set variable for summary
   with_ipopt="yes"
 ], [
+  unset IPOPT_LIBS
   AC_SUBST(IPOPT_LIBS, "")
+  unset IPOPT_LDFLAGS
   AC_SUBST(IPOPT_LDFLAGS, "")
   unset IPOPT_CPPFLAGS
   AC_SUBST(IPOPT_CPPFLAGS, "")
-- 
GitLab