Branch: r14.0.x

b71166c6 2015-06-14 13:30:17 Slávek Banko
Fix openpty detection with libutil.h

Signed-off-by: Slávek Banko <slavek.banko@...>
(cherry picked from commit e75569be1b7bf138685d0e4941daf111e6f51ba3)
M CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca577fe..55f61c8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -472,20 +472,16 @@
 
 set( CMAKE_REQUIRED_LIBRARIES util )
 if( HAVE_PTY_H )
-  check_c_source_runs("
-      #include <pty.h>
-      int main(int argc, char* argv) {
-        int master_fd, slave_fd;
-        int result;
-        result = openpty(&master_fd, &slave_fd, 0, 0, 0);
-        return 0;
-    }"
-    HAVE_OPENPTY
-  )
+  set( USE_OPENPTY_H pty.h )
 elseif( HAVE_UTIL_H )
+  set( USE_OPENPTY_H util.h )
+elseif( HAVE_LIBUTIL_H )
+  set( USE_OPENPTY_H libutil.h )
+endif( )
+if( USE_OPENPTY_H )
   check_c_source_runs("
-      #include <util.h>
-      int main(int argc, char* argv) {
+      #include <${USE_OPENPTY_H}>
+      int main(int argc, char* argv[]) {
         int master_fd, slave_fd;
         int result;
         result = openpty(&master_fd, &slave_fd, 0, 0, 0);
d8091396 2015-06-14 13:30:24 Slávek Banko
Fix several issues on freebsd

Signed-off-by: Slávek Banko <slavek.banko@...>
(cherry picked from commit e469e42c76000b70aebaf838f5a3c4ded184b0e3)
M tdecore/kpty.cpp
M tdeprint/cups/cupsdconf2/cupsddialog.cpp
M tdeprint/cups/kmcupsmanager.cpp
M tdeui/ksconfig.cpp
diff --git a/tdecore/kpty.cpp b/tdecore/kpty.cpp
index 727166d..42abd1a 100644
--- a/tdecore/kpty.cpp
+++ b/tdecore/kpty.cpp
@@ -68,10 +68,13 @@
 #include <unistd.h>
 #include <grp.h>
 
-#if defined(HAVE_LIBUTIL_H) && (!defined(__FreeBSD__) || __FreeBSD_version < 900007)
+#if defined(HAVE_LIBUTIL_H)
 # include <libutil.h>
-# define USE_LOGIN
-#elif defined(HAVE_UTIL_H)
+# if (!defined(__FreeBSD__) || __FreeBSD_version < 900007)
+#   define USE_LOGIN
+# endif
+#endif
+#if defined(HAVE_UTIL_H)
 # include <util.h>
 # define USE_LOGIN
 #endif
@@ -305,7 +308,7 @@
   if (d->masterFd >= 0)
     return true;
 
-#if defined(__OpenBSD__)
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
   char cpty[16];
 
   if (openpty(&d->masterFd, &d->slaveFd, cpty, NULL, &d->winSize) == 0) {
@@ -580,7 +583,7 @@
 // private
 bool KPty::chownpty(bool grant)
 {
-#if !defined(__OpenBSD__)
+#if !defined(__OpenBSD__) && !defined(__FreeBSD__)
   TDEProcess proc;
   proc << locate("exe", BASE_CHOWN) << (grant?"--grant":"--revoke") << TQString::number(d->masterFd);
   return proc.start(TDEProcess::Block) && proc.normalExit() && !proc.exitStatus();
diff --git a/tdeprint/cups/cupsdconf2/cupsddialog.cpp b/tdeprint/cups/cupsdconf2/cupsddialog.cpp
index 1800aaa..066d509 100644
--- a/tdeprint/cups/cupsdconf2/cupsddialog.cpp
+++ b/tdeprint/cups/cupsdconf2/cupsddialog.cpp
@@ -71,7 +71,7 @@
 
 int getServerPid()
 {
-#if defined(__OpenBSD__)
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
 	TQProcess *proc = new TQProcess();
 	proc->addArgument("pgrep");
 	proc->addArgument("cupsd");
diff --git a/tdeprint/cups/kmcupsmanager.cpp b/tdeprint/cups/kmcupsmanager.cpp
index 5271dcd..ee1c627 100644
--- a/tdeprint/cups/kmcupsmanager.cpp
+++ b/tdeprint/cups/kmcupsmanager.cpp
@@ -102,7 +102,7 @@
 {
 	TQString	d = cupsInstallDir();
 	if (d.isEmpty()) {
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
 		d = "/usr/local";
 #else
 		d = "/usr";
@@ -110,7 +110,7 @@
 	}
 	d.append("/share/cups/model");
 	// raw foomatic support
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
 	d.append(":/usr/local/share/foomatic/db/source");
 #else
 	d.append(":/usr/share/foomatic/db/source");
@@ -640,7 +640,7 @@
 {
 	TQStringList	comps = TQStringList::split('/', drname, false);
 	TQString	tmpFile = locateLocal("tmp", "foomatic_" + kapp->randomString(8));
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
 	TQString	PATH = getenv("PATH") + TQString::fromLatin1(":/usr/local/bin:/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin");
 #else
 	TQString	PATH = getenv("PATH") + TQString::fromLatin1(":/usr/sbin:/usr/local/sbin:/opt/sbin:/opt/local/sbin");
@@ -959,7 +959,7 @@
 	{
 		TQString	path = cupsInstallDir();
 		if (path.isEmpty()) {
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
 			path = "/usr/local/share/cups";
 #else
 			path = "/usr/share/cups";
diff --git a/tdeui/ksconfig.cpp b/tdeui/ksconfig.cpp
index ddae27e..2348829 100644
--- a/tdeui/ksconfig.cpp
+++ b/tdeui/ksconfig.cpp
@@ -188,7 +188,7 @@
   setDictionary    ( kc->readEntry("KSpell_Dictionary") );
   setDictFromList  ( kc->readNumEntry("KSpell_DictFromList", false) );
   setEncoding ( kc->readNumEntry ("KSpell_Encoding", KS_E_UTF8) );
-#ifdef __OpenBSD__
+#if defined(__OpenBSD__) || defined(__FreeBSD__)
   setClient ( kc->readNumEntry ("KSpell_Client", KS_CLIENT_ASPELL) );
 #else
   setClient ( kc->readNumEntry ("KSpell_Client", KS_CLIENT_ISPELL) );