[vte] build: Fix overlinking



commit f320f72b9d386d5f98df3f08ed41dc6c260ca570
Author: Christian Persch <chpe gnome org>
Date:   Sat Nov 28 22:58:33 2015 +0100

    build: Fix overlinking
    
    Fix the PTY concifugre checks to only check for BSD openpt
    when we have UNIX98 PTY support. This prevents us from always
    linking to libutil.

 configure.ac    |   28 +++++++++++++++++++---------
 src/Makefile.am |    1 +
 src/pty.cc      |    3 +++
 3 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a90c393..9b2783a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -252,21 +252,31 @@ VTE_DEFAULT_TERM=xterm-256color
 AC_DEFINE_UNQUOTED(VTE_DEFAULT_TERM,"$VTE_DEFAULT_TERM",[The default value $TERM is set to.])
 
 # Check for headers.
-AC_CHECK_HEADERS(sys/select.h sys/syslimits.h sys/termios.h sys/wait.h stropts.h termios.h util.h wchar.h)
+AC_CHECK_HEADERS([sys/select.h sys/syslimits.h sys/termios.h sys/wait.h stropts.h termios.h util.h wchar.h 
pty.h])
 AC_HEADER_TIOCGWINSZ
 
-# Check for PTY handling functions.
-AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid getpt grantpt unlockpt posix_openpt ptsname ptsname_r 
tcgetattr tcsetattr])
+# Check for how to open a new PTY. We support posix_openpt and BSDs openpty
+
+LIBUTIL=
+AC_CHECK_FUNCS([posix_openpt grantpt unlockpt ptsname],[],[
+   # Try BSD
+   AC_SEARCH_LIBS([openpty],[util],[have_openpty=yes],
+   [AC_MSG_ERROR([have neither UNIX98 PTY nor BSD openpty])])
+
+   if test "$ac_cv_search_openpty" != "none required"; then
+     LIBUTIL="$ac_cv_search_openpty"
+   fi
+   AC_DEFINE(HAVE_OPENPTY,1,[Define if you have the openpty function.])
+])
+
+AC_SUBST([LIBUTIL])
+
+# Misc PTY handling functions
+AC_CHECK_FUNCS([cfmakeraw fork setsid setpgid getpgid ptsname_r tcgetattr tcsetattr])
 
 # Misc I/O routines.
 AC_CHECK_FUNCS([pread pwrite])
 
-# Pull in the right libraries for various functions which might not be
-# bundled into an exploded libc.
-AC_CHECK_FUNC(openpty,[have_openpty=1],AC_CHECK_LIB(util,openpty,[have_openpty=1; LIBS="$LIBS -lutil"]))
-if test x$have_openpty = x1 ; then
-       AC_DEFINE(HAVE_OPENPTY,1,[Define if you have the openpty function.])
-fi
 AC_CHECK_FUNC(floor,,AC_CHECK_LIB(m,floor,LIBS=["$LIBS -lm"]))
 AC_CHECK_FUNCS([ceil floor round])
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 62c1d2c..50250e1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -128,6 +128,7 @@ libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LDFLAGS = \
        $(AM_LDFLAGS)
 
 libvte_ VTE_API_MAJOR_VERSION@_ VTE_API_MINOR_VERSION@_la_LIBADD = \
+       $(LIBUTIL) \
        $(VTE_LIBS)
 
 # Try hard to avoid linking to libstd++ by using the C linker instead of the C++ linker
diff --git a/src/pty.cc b/src/pty.cc
index efdc076..948e0ba 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -54,6 +54,9 @@
 #ifdef HAVE_UTIL_H
 #include <util.h>
 #endif
+#ifdef HAVE_PTY_H
+#include <pty.h>
+#endif
 #ifdef HAVE_STROPTS_H
 #include <stropts.h>
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]