On Thu, Jul 08, 2004 at 05:32:37PM -0300, Cesar Eduardo Barros wrote:
> log4cxx is including a copy of the autoconf-generated config_auto.h even
> when compiling another program which also uses autoconf, causing
> conflicts. However, only LOG4CXX_EXPORT is really needed. I made this
> quick patch to fix it.
>
> This patch reuses the LOG4CXX define used for almost the same purpose on
> config_msvc.h (to determine if we're compiling log4cxx itself or a
> program which uses log4cxx).
I didn't notice some headers were using the defines from config_auto.h
(HAVE_*, MUST_* and UNICODE). So, the simple solution above didn't work
when I tried to use the DOM configurator.
This patch renames these defines on all headers and adds a sed-generated
copy of config_auto.h prepending LOG4CXX_ to all these defines and
removing the bogus PACKAGE_*, VERSION and STDC_HEADERS ones when not
being included within the log4cxx sources.
Tested compiling in the source directory, but should work with a
separate object directory too.
configure.in | 3 +
include/log4cxx/Makefile.am | 2 -
include/log4cxx/config.h | 6 +++
include/log4cxx/config_msvc.h | 4 +-
include/log4cxx/config_msvc_log4cxx.h | 46 +++++++++++++++++++++++++++
include/log4cxx/db/odbcappender.h | 6 +--
include/log4cxx/helpers/condition.h | 6 +--
include/log4cxx/helpers/criticalsection.h | 8 ++--
include/log4cxx/helpers/event.h | 6 +--
include/log4cxx/helpers/gnomexml.h | 4 +-
include/log4cxx/helpers/msxml.h | 4 +-
include/log4cxx/helpers/mutex.h | 6 +--
include/log4cxx/helpers/semaphore.h | 10 ++---
include/log4cxx/helpers/tchar.h | 8 ++--
include/log4cxx/helpers/thread.h | 4 +-
include/log4cxx/helpers/threadspecificdata.h | 6 +--
include/log4cxx/net/smtpappender.h | 4 +-
include/log4cxx/net/syslogappender.h | 2 -
include/log4cxx/xml/domconfigurator.h | 4 +-
19 files changed, 97 insertions(+), 42 deletions(-)
diff -Naur log4cxx-0.9.7.orig/configure.in log4cxx-0.9.7/configure.in
--- log4cxx-0.9.7.orig/configure.in 2004-05-10 17:59:02.000000000 -0300
+++ log4cxx-0.9.7/configure.in 2004-07-08 19:39:04.000000000 -0300
@@ -18,7 +18,7 @@
AC_SUBST(LT_VERSION)
-AM_CONFIG_HEADER(include/log4cxx/config_auto.h)
+AC_CONFIG_HEADERS([include/log4cxx/config_auto.h],[cat
"${ac_abs_top_builddir}/include/log4cxx/config_auto.h" | sed -e
's/\(HAVE_\|MUST_\|UNICODE\)/LOG4CXX_\1/;s/^\(.*PACKAGE.*\|.*VERSION.*\|.*STDC_HEADERS.*\)$/\/*
\1 *\//' > "${ac_abs_top_builddir}/include/log4cxx/config_auto_log4cxx.h"])
AH_VERBATIM([HAVE_NO_EXPLICIT_EXPORTS],
[/* no explicit exports */
@@ -334,6 +334,7 @@
;;
esac
+CPPFLAGS="-DLOG4CXX $CPPFLAGS"
# Create files
# ----------------------------------------------------------------------------
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/Makefile.am
log4cxx-0.9.7/include/log4cxx/Makefile.am
--- log4cxx-0.9.7.orig/include/log4cxx/Makefile.am 2004-05-10
09:38:23.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/Makefile.am 2004-07-08 19:51:22.000000000
-0300
@@ -1,4 +1,4 @@
SUBDIRS = helpers net nt spi varia xml config db
log4cxxincdir = $(includedir)/log4cxx
log4cxxinc_HEADERS= $(top_srcdir)/include/log4cxx/*.h
-
+DISTCLEANFILES = config_auto_log4cxx.h
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/config.h
log4cxx-0.9.7/include/log4cxx/config.h
--- log4cxx-0.9.7.orig/include/log4cxx/config.h 2004-05-11 14:14:19.000000000
-0300
+++ log4cxx-0.9.7/include/log4cxx/config.h 2004-07-08 19:20:35.000000000
-0300
@@ -2,9 +2,15 @@
#define _LOG4CXX_CONFIG_H
#ifdef _MSC_VER
+#ifdef LOG4CXX
#include <log4cxx/config_msvc.h>
+#endif
+#include <log4cxx/config_msvc_log4cxx.h>
#else
+#ifdef LOG4CXX
#include <log4cxx/config_auto.h>
#endif
+#include <log4cxx/config_auto_log4cxx.h>
+#endif
#endif //_LOG4CXX_CONFIG_H
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/config_msvc.h
log4cxx-0.9.7/include/log4cxx/config_msvc.h
--- log4cxx-0.9.7.orig/include/log4cxx/config_msvc.h 2004-05-10
09:38:26.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/config_msvc.h 2004-07-08 19:21:24.000000000
-0300
@@ -2,7 +2,7 @@
#define PACKAGE "log4cxx"
/* Version number of package */
-#define VERSION "0.9.6"
+#define VERSION "0.9.7"
/* Define to 1 if you have the `ftime' function. */
#define HAVE_FTIME 1
@@ -25,6 +25,7 @@
/* XML support */
#define HAVE_XML 1
+/*
typedef __int64 int64_t;
#ifdef WIN32
@@ -44,3 +45,4 @@
#endif
#define _WIN32_WINNT 0x0400
+*/
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/config_msvc_log4cxx.h
log4cxx-0.9.7/include/log4cxx/config_msvc_log4cxx.h
--- log4cxx-0.9.7.orig/include/log4cxx/config_msvc_log4cxx.h 1969-12-31
21:00:00.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/config_msvc_log4cxx.h 2004-07-08
19:21:31.000000000 -0300
@@ -0,0 +1,46 @@
+/* Name of package */
+/* #define PACKAGE "log4cxx" */
+
+/* Version number of package */
+/* #define VERSION "0.9.7" */
+
+/* Define to 1 if you have the `ftime' function. */
+#define LOG4CXX_HAVE_FTIME 1
+
+/* ODBC support through Microsoft ODBC. */
+#define LOG4CXX_HAVE_MS_ODBC 1
+
+/* thread support through Microsoft threads. */
+#define LOG4CXX_HAVE_MS_THREAD 1
+
+/* XML support through Microsoft XML. */
+#define LOG4CXX_HAVE_MS_XML 1
+
+/* ODBC support */
+#define LOG4CXX_HAVE_ODBC 1
+
+/* thread support */
+#define LOG4CXX_HAVE_THREAD 1
+
+/* XML support */
+#define LOG4CXX_HAVE_XML 1
+
+typedef __int64 int64_t;
+
+#ifdef WIN32
+#pragma warning(disable : 4250 4251 4786 4290)
+#endif
+
+#ifdef LOG4CXX_STATIC
+#define LOG4CXX_EXPORT
+// cf. file msvc/static/static.cpp
+#pragma comment(linker, "/include:?ForceSymbolReferences@@YAXXZ")
+#else // DLL
+#ifdef LOG4CXX
+ #define LOG4CXX_EXPORT __declspec(dllexport)
+#else
+ #define LOG4CXX_EXPORT __declspec(dllimport)
+#endif
+#endif
+
+#define _WIN32_WINNT 0x0400
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/db/odbcappender.h
log4cxx-0.9.7/include/log4cxx/db/odbcappender.h
--- log4cxx-0.9.7.orig/include/log4cxx/db/odbcappender.h 2004-05-10
09:40:56.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/db/odbcappender.h 2004-07-08
19:48:16.000000000 -0300
@@ -19,14 +19,14 @@
#include <log4cxx/config.h>
-#ifdef HAVE_ODBC
+#ifdef LOG4CXX_HAVE_ODBC
#include <log4cxx/helpers/exception.h>
#include <log4cxx/appenderskeleton.h>
#include <log4cxx/spi/loggingevent.h>
#include <list>
-#ifdef HAVE_MS_ODBC
+#ifdef LOG4CXX_HAVE_MS_ODBC
#include <windows.h>
#endif
@@ -268,5 +268,5 @@
} // namespace db
}; // namespace log4cxx
-#endif // HAVE_ODBC
+#endif // LOG4CXX_HAVE_ODBC
#endif // _LOG4CXX_NET_SOCKET_APPENDER_H
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/condition.h
log4cxx-0.9.7/include/log4cxx/helpers/condition.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/condition.h 2004-05-10
09:41:03.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/condition.h 2004-07-08
19:48:17.000000000 -0300
@@ -22,7 +22,7 @@
#include <log4cxx/helpers/mutex.h>
#include <log4cxx/helpers/semaphore.h>
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
#include <pthread.h>
#endif
@@ -45,9 +45,9 @@
void wait(Mutex& mutex, long timeOut);
protected:
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
pthread_cond_t condition;
-#elif defined(HAVE_MS_THREAD)
+#elif defined(LOG4CXX_HAVE_MS_THREAD)
/// Number of waiting threads.
long volatile waiters;
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/criticalsection.h
log4cxx-0.9.7/include/log4cxx/helpers/criticalsection.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/criticalsection.h
2004-05-10 09:41:03.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/criticalsection.h 2004-07-08
19:48:17.000000000 -0300
@@ -19,9 +19,9 @@
#include <log4cxx/config.h>
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
#include <pthread.h>
-#elif defined(HAVE_MS_THREAD)
+#elif defined(LOG4CXX_HAVE_MS_THREAD)
#include <windows.h>
#endif
@@ -38,9 +38,9 @@
void unlock();
unsigned long getOwningThread();
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
pthread_mutex_t mutex;
-#elif defined(HAVE_MS_THREAD)
+#elif defined(LOG4CXX_HAVE_MS_THREAD)
CRITICAL_SECTION mutex;
#endif
unsigned long owningThread;
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/event.h
log4cxx-0.9.7/include/log4cxx/helpers/event.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/event.h 2004-05-10
09:41:08.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/event.h 2004-07-08
19:48:17.000000000 -0300
@@ -20,7 +20,7 @@
#include <log4cxx/config.h>
#include <log4cxx/helpers/exception.h>
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
#include <pthread.h>
#endif
@@ -86,12 +86,12 @@
void wait();
protected:
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
pthread_cond_t condition;
pthread_mutex_t mutex;
bool state;
bool manualReset;
-#elif defined(HAVE_MS_THREAD)
+#elif defined(LOG4CXX_HAVE_MS_THREAD)
void * event;
#endif
}; // class Event
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/gnomexml.h
log4cxx-0.9.7/include/log4cxx/helpers/gnomexml.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/gnomexml.h 2004-05-10
09:41:11.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/gnomexml.h 2004-07-08
19:48:17.000000000 -0300
@@ -19,7 +19,7 @@
#include <log4cxx/config.h>
-#ifdef HAVE_LIBXML2
+#ifdef LOG4CXX_HAVE_LIBXML2
#include <log4cxx/helpers/xml.h>
#include <log4cxx/helpers/objectimpl.h>
@@ -128,5 +128,5 @@
} // namespace helpers
}; // namespace log4cxx
-#endif // HAVE_LIBXML2
+#endif // LOG4CXX_HAVE_LIBXML2
#endif // _LOG4CXX_HELPERS_MSXML_H
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/msxml.h
log4cxx-0.9.7/include/log4cxx/helpers/msxml.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/msxml.h 2004-05-10
09:41:15.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/msxml.h 2004-07-08
19:48:18.000000000 -0300
@@ -19,7 +19,7 @@
#include <log4cxx/config.h>
-#ifdef HAVE_MS_XML
+#ifdef LOG4CXX_HAVE_MS_XML
#include <log4cxx/helpers/xml.h>
#include <log4cxx/helpers/objectimpl.h>
@@ -127,5 +127,5 @@
} // namespace helpers
}; // namespace log4cxx
-#endif // HAVE_MS_XML
+#endif // LOG4CXX_HAVE_MS_XML
#endif // _LOG4CXX_HELPERS_MSXML_H
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/mutex.h
log4cxx-0.9.7/include/log4cxx/helpers/mutex.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/mutex.h 2004-05-10
09:41:16.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/mutex.h 2004-07-08
19:48:18.000000000 -0300
@@ -20,7 +20,7 @@
#include <log4cxx/config.h>
#include <log4cxx/helpers/exception.h>
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
#include <pthread.h>
#endif
@@ -44,9 +44,9 @@
void unlock();
protected:
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
pthread_mutex_t mutex;
-#elif defined(HAVE_MS_THREAD)
+#elif defined(LOG4CXX_HAVE_MS_THREAD)
void * mutex;
#endif
};
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/semaphore.h
log4cxx-0.9.7/include/log4cxx/helpers/semaphore.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/semaphore.h 2004-05-10
09:41:24.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/semaphore.h 2004-07-08
19:48:18.000000000 -0300
@@ -20,7 +20,7 @@
#include <log4cxx/config.h>
#include <log4cxx/helpers/exception.h>
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
#include <semaphore.h>
#endif
@@ -32,13 +32,13 @@
{
};
-#ifdef HAVE_MS_THREAD
+#ifdef LOG4CXX_HAVE_MS_THREAD
class Condition;
#endif
class LOG4CXX_EXPORT Semaphore
{
-#ifdef HAVE_MS_THREAD
+#ifdef LOG4CXX_HAVE_MS_THREAD
friend class Condition;
#endif
public:
@@ -49,9 +49,9 @@
void post();
protected:
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
sem_t semaphore;
-#elif defined (HAVE_MS_THREAD)
+#elif defined (LOG4CXX_HAVE_MS_THREAD)
void * semaphore;
#endif
};
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/tchar.h
log4cxx-0.9.7/include/log4cxx/helpers/tchar.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/tchar.h 2004-05-10
09:54:50.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/tchar.h 2004-07-08
19:48:54.000000000 -0300
@@ -74,7 +74,7 @@
}
}
-#ifdef MUST_UNDEF_T
+#ifdef LOG4CXX_MUST_UNDEF_T
#undef _T
#endif
@@ -96,7 +96,7 @@
#define A2W(src) Convert::ansiToUnicode((wchar_t *)_dst, src)
#endif
-#ifdef UNICODE
+#ifdef LOG4CXX_UNICODE
#include <wctype.h>
#ifndef _T
@@ -135,7 +135,7 @@
#define ttol(s) wcstol(s, 0, 10)
#define itot _itow
#define tcscmp wcscmp
-#else // Not UNICODE
+#else // Not LOG4CXX_UNICODE
#include <ctype.h>
#ifndef _T
@@ -172,7 +172,7 @@
#define ttol atol
#define itot itoa
#define tcscmp strcmp
-#endif // UNICODE
+#endif // LOG4CXX_UNICODE
#define _MinInc size_t(512)
#define _MaxInc size_t(100 * 1024)
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/thread.h
log4cxx-0.9.7/include/log4cxx/helpers/thread.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/thread.h 2004-05-10
09:41:32.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/thread.h 2004-07-08
19:48:19.000000000 -0300
@@ -131,9 +131,9 @@
protected:
/** Thread descriptor */
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
pthread_t thread;
-#elif defined(HAVE_MS_THREAD)
+#elif defined(LOG4CXX_HAVE_MS_THREAD)
void * thread;
#endif
RunnablePtr runnable;
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/helpers/threadspecificdata.h
log4cxx-0.9.7/include/log4cxx/helpers/threadspecificdata.h
--- log4cxx-0.9.7.orig/include/log4cxx/helpers/threadspecificdata.h
2004-05-10 09:41:32.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/helpers/threadspecificdata.h 2004-07-08
19:48:19.000000000 -0300
@@ -19,7 +19,7 @@
#include <log4cxx/config.h>
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
#include <pthread.h>
#endif
@@ -36,9 +36,9 @@
void SetData(void * data);
protected:
-#ifdef HAVE_PTHREAD
+#ifdef LOG4CXX_HAVE_PTHREAD
pthread_key_t key;
-#elif defined(HAVE_MS_THREAD)
+#elif defined(LOG4CXX_HAVE_MS_THREAD)
void * key;
#endif
};
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/net/smtpappender.h
log4cxx-0.9.7/include/log4cxx/net/smtpappender.h
--- log4cxx-0.9.7.orig/include/log4cxx/net/smtpappender.h 2004-05-10
09:59:26.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/net/smtpappender.h 2004-07-08
19:48:19.000000000 -0300
@@ -19,7 +19,7 @@
#include <log4cxx/config.h>
-#ifdef HAVE_SMTP
+#ifdef LOG4CXX_HAVE_SMTP
#include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/cyclicbuffer.h>
@@ -270,5 +270,5 @@
} // namespace net
}; // namespace log4cxx
-#endif // HAVE_SMTP
+#endif // LOG4CXX_HAVE_SMTP
#endif // _LOG4CXX_NET_SMTP_H
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/net/syslogappender.h
log4cxx-0.9.7/include/log4cxx/net/syslogappender.h
--- log4cxx-0.9.7.orig/include/log4cxx/net/syslogappender.h 2004-05-10
09:41:39.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/net/syslogappender.h 2004-07-08
19:48:20.000000000 -0300
@@ -20,7 +20,7 @@
#include <log4cxx/appenderskeleton.h>
#include <log4cxx/helpers/syslogwriter.h>
-#ifndef HAVE_SYSLOG
+#ifndef LOG4CXX_HAVE_SYSLOG
#endif
namespace log4cxx
diff -Naur log4cxx-0.9.7.orig/include/log4cxx/xml/domconfigurator.h
log4cxx-0.9.7/include/log4cxx/xml/domconfigurator.h
--- log4cxx-0.9.7.orig/include/log4cxx/xml/domconfigurator.h 2004-05-10
09:42:04.000000000 -0300
+++ log4cxx-0.9.7/include/log4cxx/xml/domconfigurator.h 2004-07-08
19:48:20.000000000 -0300
@@ -19,7 +19,7 @@
#include <log4cxx/config.h>
-#ifdef HAVE_XML
+#ifdef LOG4CXX_HAVE_XML
#include <log4cxx/helpers/tchar.h>
#include <log4cxx/helpers/objectptr.h>
@@ -220,5 +220,5 @@
} // namespace xml
}; // namespace log4cxx
-#endif // HAVE_XML
+#endif // LOG4CXX_HAVE_XML
#endif // _LOG4CXX_XML_DOM_CONFIGURATOR_H
--
Cesar Eduardo Barros
[EMAIL PROTECTED]
[EMAIL PROTECTED]