[Cleanup] Handle system dependent defines through autoheader & common-config.h
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2890 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/common/configure.ac b/common/configure.ac
index 198d664..f0b8a8a 100644
--- a/common/configure.ac
+++ b/common/configure.ac
@@ -10,6 +10,9 @@
AC_PROG_LIBTOOL
AC_LANG([C++])
+AC_CONFIG_HEADERS([common-config.h])
+CPPFLAGS="-DHAVE_COMMON_CONFIG_H $CPPFLAGS"
+
case "`(uname -sr) 2>/dev/null`" in
"SunOS 5"*)
SOLARIS=yes
@@ -42,13 +45,13 @@
dnl Checks for IRIX-specific Compression Library.
AC_SEARCH_LIBS([clQuerySchemeFromName])
AC_CHECK_LIB(cl, clQuerySchemeFromName,
- [AC_DEFINE(HAVE_CL)
+ [AC_DEFINE([HAVE_CL], 1, [Define if you have IRIX compression library])
IRIX_COMPRESS=yes])
AM_CONDITIONAL([IRIX_COMPRESS], [ test "x$IRIX_COMPRESS" = xyes ])
dnl Checks for IRIX-specific Digital Media libraries.
AC_CHECK_LIB(dmedia, dmICCreate,
- [AC_DEFINE(HAVE_DMEDIA)
+ [AC_DEFINE(HAVE_DMEDIA, 1, [Define if you have IRIX Digital Media library])
IRIX_MEDIA=yes])
AM_CONDITIONAL([IRIX_MEDIA], [ test "x$IRIX_MEDIA" = xyes ])
@@ -96,28 +99,11 @@
AC_SUBST(JPEG_INCLUDE)
AC_SUBST(JPEG_LIB)
-AC_CHECK_FUNC(vsnprintf,VSNPRINTF_DEFINE='-DHAVE_VSNPRINTF',VSNPRINTF_DEFINE=)
-AC_SUBST(VSNPRINTF_DEFINE)
+AC_CHECK_FUNCS_ONCE([vsnprintf strcasecmp strncasecmp])
-AC_CHECK_FUNC(strcasecmp,STRCASECMP_DEFINE='-DHAVE_STRCASECMP',
- STRCASECMP_DEFINE=)
-AC_SUBST(STRCASECMP_DEFINE)
-
-AC_CHECK_FUNC(strncasecmp,STRNCASECMP_DEFINE='-DHAVE_STRNCASECMP',
- STRNCASECMP_DEFINE=)
-AC_SUBST(STRNCASECMP_DEFINE)
-
-AC_MSG_CHECKING(for socklen_t)
-AC_TRY_COMPILE(
-[#include <sys/types.h>
- #include <sys/socket.h>],
-[socklen_t x;
-accept(0, 0, &x);],
-AC_MSG_RESULT(yes)
-SOCKLEN_T_DEFINE='-DVNC_SOCKLEN_T=socklen_t',
-AC_MSG_RESULT(using int)
-SOCKLEN_T_DEFINE='-DVNC_SOCKLEN_T=int')
-AC_SUBST(SOCKLEN_T_DEFINE)
+AC_CHECK_TYPES([socklen_t],
+ [AC_DEFINE([VNC_SOCKLEN_T], [socklen_t], [Use correct size])],
+ [AC_DEFINE([VNC_SOCKLEN_T], [int])])
AC_OUTPUT([Makefile
rdr/Makefile
diff --git a/common/network/Makefile.am b/common/network/Makefile.am
index 61d276b..c4bad93 100644
--- a/common/network/Makefile.am
+++ b/common/network/Makefile.am
@@ -4,5 +4,5 @@
libnetwork_la_SOURCES = $(HDRS) TcpSocket.cxx
-libnetwork_la_CPPFLAGS = -I$(top_srcdir) @SOCKLEN_T_DEFINE@
+libnetwork_la_CPPFLAGS = -I$(top_srcdir)
diff --git a/common/network/TcpSocket.cxx b/common/network/TcpSocket.cxx
index 5dd2428..777627b 100644
--- a/common/network/TcpSocket.cxx
+++ b/common/network/TcpSocket.cxx
@@ -16,6 +16,10 @@
* USA.
*/
+#ifdef HAVE_COMMON_CONFIG_H
+#include <common-config.h>
+#endif
+
#ifdef WIN32
//#include <io.h>
#include <winsock2.h>
@@ -42,10 +46,6 @@
#include <rfb/util.h>
#include <rfb/LogWriter.h>
-#ifndef VNC_SOCKLEN_T
-#define VNC_SOCKLEN_T int
-#endif
-
#ifndef INADDR_NONE
#define INADDR_NONE ((unsigned long)-1)
#endif
diff --git a/common/rfb/JpegEncoder.cxx b/common/rfb/JpegEncoder.cxx
index 7129192..2c47a60 100644
--- a/common/rfb/JpegEncoder.cxx
+++ b/common/rfb/JpegEncoder.cxx
@@ -16,6 +16,10 @@
* USA.
*/
+#ifdef HAVE_COMMON_CONFIG_H
+#include <common-config.h>
+#endif
+
#include <rfb/JpegEncoder.h>
#include <rdr/OutStream.h>
#include <rdr/Exception.h>
diff --git a/common/rfb/Logger.cxx b/common/rfb/Logger.cxx
index 6b9cfa3..8c90906 100644
--- a/common/rfb/Logger.cxx
+++ b/common/rfb/Logger.cxx
@@ -18,6 +18,10 @@
// -=- Logger.cxx - support for the Logger and LogWriter classes
+#ifdef HAVE_COMMON_CONFIG_H
+#include <common-config.h>
+#endif
+
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
diff --git a/common/rfb/Makefile.am b/common/rfb/Makefile.am
index 30c06d7..f2106d1 100644
--- a/common/rfb/Makefile.am
+++ b/common/rfb/Makefile.am
@@ -53,8 +53,7 @@
librfb_la_SOURCES += IrixDMJpegCompressor.cxx IrixDMIC_RawToJpeg.cxx
endif
-librfb_la_CPPFLAGS = -I$(top_srcdir) @JPEG_INCLUDE@ @VSNPRINTF_DEFINE@ \
- @STRCASECMP_DEFINE@ @STRNCASECMP_DEFINE@
+librfb_la_CPPFLAGS = -I$(top_srcdir) @JPEG_INCLUDE@
librfb_la_LIBADD = @JPEG_LIB@
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index 5745432..7950a1d 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -30,6 +30,10 @@
* is provided ``as is'' without express or implied warranty.
*/
+#ifndef HAVE_COMMON_CONFIG_H
+#include <common-config.h>
+#endif
+
#include <rfb/util.h>
// Provide strcasecmp() and/or strncasecmp() if absent on this system.
diff --git a/common/rfb/util.h b/common/rfb/util.h
index fa205f0..933df52 100644
--- a/common/rfb/util.h
+++ b/common/rfb/util.h
@@ -23,6 +23,10 @@
#ifndef __RFB_UTIL_H__
#define __RFB_UTIL_H__
+#ifdef HAVE_COMMON_CONFIG_H
+#include <common-config.h>
+#endif
+
#include <limits.h>
#include <string.h>