From 28d296d96d10e909fe33d86da996eec41dd02852 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Wed, 24 Feb 2010 17:38:14 +0000 Subject: [PATCH] Make more header inclusions conditional on whether they exist. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18715 57a11ea4-9604-0410-9ed3-97b8803252fd --- configure.in | 4 ++-- src/libqof/qof/guid.c | 14 ++++++++++---- src/libqof/qof/qoflog.c | 17 ++++++++++++++--- src/libqof/qof/qofsession.c | 8 +++++++- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/configure.in b/configure.in index d6dd69a8e4..61997fecca 100644 --- a/configure.in +++ b/configure.in @@ -105,7 +105,7 @@ AC_PROG_MAKE_SET AC_PROG_LN_S AC_HEADER_STDC -AC_CHECK_HEADERS(limits.h sys/times.h sys/wait.h) +AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h sys/wait.h) AC_CHECK_FUNCS(stpcpy memcpy timegm towupper) AC_CHECK_FUNCS(setenv,,[ AC_CHECK_FUNCS(putenv,,[ @@ -248,7 +248,7 @@ else AC_MSG_RESULT(no) fi -AC_CHECK_HEADERS(dlfcn.h dl.h utmp.h locale.h mcheck.h unistd.h wctype.h) +AC_CHECK_HEADERS(dirent.h dlfcn.h dl.h utmp.h locale.h mcheck.h unistd.h wctype.h) # Gnucash replaced dlopen/dlsym by the g_module functions; dlsym # is needed optionally in one place for BSD linkers, though. diff --git a/src/libqof/qof/guid.c b/src/libqof/qof/guid.c index 7de451e847..c549b2cf0d 100644 --- a/src/libqof/qof/guid.c +++ b/src/libqof/qof/guid.c @@ -29,7 +29,9 @@ # include #endif #include -#include +#ifdef HAVE_DIRENT_H +# include +#endif #include #include #include @@ -39,7 +41,9 @@ # include #endif #include -#include +#ifdef HAVE_UNISTD_H +# include +#endif #include "qof.h" #include "md5.h" @@ -373,7 +377,8 @@ guid_init(void) /* process and parent ids */ { - pid_t pid; +#ifdef HAVE_UNISTD_H + pid_t pid; pid = getpid(); md5_process_bytes(&pid, sizeof(pid), &guid_context); @@ -384,7 +389,8 @@ guid_init(void) md5_process_bytes(&pid, sizeof(pid), &guid_context); bytes += sizeof(pid); #endif - } +#endif + } /* user info */ { diff --git a/src/libqof/qof/qoflog.c b/src/libqof/qof/qoflog.c index f0195c0850..f47cd31573 100644 --- a/src/libqof/qof/qoflog.c +++ b/src/libqof/qof/qoflog.c @@ -30,14 +30,25 @@ #include #include #ifdef HAVE_UNISTD_H -#include +# include #else -#warning unistd required. +# ifdef __GNUC__ +# warning " required." +# endif #endif #include #include #include -#include +#ifdef HAVE_SYS_TIME_H +# include +#else +/* We simply define the struct timeval on our own here. */ +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* and microseconds */ +}; +/* include */ +#endif #undef G_LOG_DOMAIN #define G_LOG_DOMAIN "qof.log" diff --git a/src/libqof/qof/qofsession.c b/src/libqof/qof/qofsession.c index 37f6db6160..f195757610 100644 --- a/src/libqof/qof/qofsession.c +++ b/src/libqof/qof/qofsession.c @@ -37,7 +37,13 @@ #include #include #include -#include +#ifdef HAVE_UNISTD_H +# include +#else +# ifdef __GNUC__ +# warning " required." +# endif +#endif #include #include "qof.h"