Hi, I intend to commit the following patches. They clean up and extend the logchar configuration. All configuration of the LOG4CXX_LOGCHAR_IS_... and the LOGCHAR_IS_WCHAR macros is now done by the build/configure scripts, so that no dependencies need to be calculated in the include file. I think that this is more straightforward and easier to maintain, especially if new logchar types like CFSTRING will be added in the future (the patches already prepare the CFSTRING type).
I have started to summarize the logchar configuration in the log4cxx wiki: http://wiki.apache.org/logging-log4cxx/GeneralBuildInstructions#preview Thanks, Andreas LOGCXX-43: ========= Index: include/log4cxx/log4cxx.h.in =================================================================== --- include/log4cxx/log4cxx.h.in (Revision 332794) +++ include/log4cxx/log4cxx.h.in (Arbeitskopie) @@ -24,12 +24,9 @@ */ +#define LOG4CXX_LOGCHAR_IS_CFSTRING @LOGCHAR_IS_CFSTRING@ #define LOG4CXX_LOGCHAR_IS_UTF8 @LOGCHAR_IS_UTF8@ -#if LOG4CXX_LOGCHAR_IS_UTF8 -#define LOG4CXX_LOGCHAR_IS_WCHAR 0 -#else -#define LOG4CXX_LOGCHAR_IS_WCHAR 1 -#endif +#define LOG4CXX_LOGCHAR_IS_WCHAR @LOGCHAR_IS_WCHAR@ #define LOG4CXX_HAS_WCHAR_T @HAS_WCHAR_T@ Index: configure.in =================================================================== --- configure.in (Revision 332794) +++ configure.in (Arbeitskopie) @@ -271,14 +271,6 @@ AC_SUBST(LIBS_XML) AC_SUBST(CPPFLAGS_XML) -#for UNICODE -AC_MSG_CHECKING(for UTF-16 Unicode support) -AC_ARG_ENABLE(unicode, - AC_HELP_STRING(--enable-unicode, [UTF-16 Unicode support (default=no)]), - AC_DEFINE(UNICODE, 1, UTF-16 Unicode support.) - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no)) - #for ODBCAppender AC_MSG_CHECKING(for ODBC support) AC_ARG_WITH(ODBC, @@ -369,6 +361,54 @@ CPPFLAGS="-DLOG4CXX $CPPFLAGS" +#for wchar_t +AC_MSG_CHECKING([for wchar_t]) +AC_COMPILE_IFELSE(AC_LANG_SOURCE(wchar_t* w;), [have_wchar_t=yes], [have_wchar_t=no]) +AC_MSG_RESULT($have_wchar_t) + +if test "$have_wchar_t" = "yes" +then + AC_SUBST(HAS_WCHAR_T, 1) +else + AC_SUBST(HAS_WCHAR_T, 0) +fi + +#determine logchar type +AC_MSG_CHECKING([logchar type]) +AC_ARG_WITH(logchar, + AC_HELP_STRING(--with-logchar=TYPE, [type for logchar. + Accepted TYPE variants: utf-8, wchar_t, cfstring (default=utf-8)]), + [ac_with_logchar=$withval], + [ac_with_logchar=utf-8]) + +case "$ac_with_logchar" in + utf-8) + AC_MSG_RESULT(utf-8) + AC_SUBST(LOGCHAR_IS_UTF8, 1) + AC_SUBST(LOGCHAR_IS_WCHAR, 0) + AC_SUBST(LOGCHAR_IS_CFSTRING, 0) + ;; + + wchar_t) + AC_MSG_RESULT(wchar_t) + AC_SUBST(LOGCHAR_IS_UTF8, 0) + AC_SUBST(LOGCHAR_IS_WCHAR, 1) + AC_SUBST(LOGCHAR_IS_CFSTRING, 0) + ;; + + cfstring) + AC_MSG_RESULT(cfstring) + AC_SUBST(LOGCHAR_IS_UTF8, 0) + AC_SUBST(LOGCHAR_IS_WCHAR, 0) + AC_SUBST(LOGCHAR_IS_CFSTRING, 1) + ;; + + *) + AC_MSG_RESULT(???) + AC_MSG_ERROR(Invalid logchar type: $ac_with_logchar) + ;; +esac + # Create files # ---------------------------------------------------------------------------- Index: build.xml =================================================================== --- build.xml (Revision 332794) +++ build.xml (Arbeitskopie) @@ -52,8 +52,7 @@ <property name="optimize" value="none"/> <property name="lib.type" value="shared"/> <property name="has.wchar_t" value="1"/> -<!-- utf-8 will be used if -Dhas.wchar_t=0 or -Dlogchar=utf-8 --> -<property name="logchar" value="wchar_t"/> + <property name="apache.mirror" value="http://apache.mirrors.pair.com"/> <property name="cppunit.mirror" value="http://unc.dl.sourceforge.net/sourceforge"/> @@ -109,6 +108,10 @@ -Doptimize=[speed|size|none] -Dversion=n.n.n -Dlib.type=[shared|static] +-Dapr.dir=PATH +-Daprutil.dir=PATH +-Dhas.wchar_t=[0|1] (default=1) +-Dlogchar=[utf-8|wchar_t|cfstring] (default=wchar_t) </echo> </target> @@ -153,6 +156,10 @@ <property name="project.type" value="msvc6"/> <property name="project.dir" value="msvc"/> <property name="compiler" value="msvc"/> + + <!-- Default value for logchar on windows --> + <property name="logchar" value="wchar_t"/> + <condition property="is-bcc" value="true"> <or> <equals arg1="${compiler}" arg2="bcc"/> @@ -169,6 +176,9 @@ <property name="project.dir" value="xcode"/> <property name="has-iconv" value="true"/> + <!-- Default value for logchar on mac --> + <property name="logchar" value="wchar_t"/> + <condition property="mac_osx_wchar_not_supported_yet" value="true"> <equals arg1="${has.wchar_t}" arg2="1"/> </condition> @@ -193,6 +203,10 @@ <property name="project.dir" value="cbx"/> <property name="compiler" value="g++"/> <property name="lib-suffix" value=""/> + + <!-- Default value for logchar on Unix --> + <property name="logchar" value="utf-8"/> + <condition property="has-expat" value="true"> <not><isset property="is-mac"/></not> </condition> @@ -239,13 +253,14 @@ <istrue value="${debug}"/> </condition> - <condition property="is-utf8" value="true"> - <or> - <not><equals arg1="${has.wchar_t}" arg2="1"/></not> - <equals arg1="${logchar}" arg2="utf-8"/> - </or> + <condition property="logchar_type" value="utf-8"> + <not><equals arg1="${has.wchar_t}" arg2="1"/></not> </condition> + <condition property="logchar_type" value="${logchar}"> + <equals arg1="${has.wchar_t}" arg2="1"/> + </condition> + <condition property="debug.release" value="debug"> <isset property="is-debug"/> </condition> @@ -370,23 +385,42 @@ </target> +<target name="configure" depends="init, + unix-configure, + win-configure"> + <echo message="Configuring with has.wchar_t=${has.wchar_t}"/> + <echo message="Configuring with logchar_type=${logchar_type}" /> -<target name="configure" depends="unix-configure, - win-configure"> <condition property="logchar_is_utf8" value="1"> - <isset property="is-utf8"/> + <equals arg1="${logchar_type}" arg2="utf-8"/> </condition> <property name="logchar_is_utf8" value="0"/> + <condition property="logchar_is_cfstring" value="1"> + <equals arg1="${logchar_type}" arg2="cfstring"/> + </condition> + <property name="logchar_is_cfstring" value="0"/> + + <condition property="logchar_is_wchar" value="1"> + <equals arg1="${logchar_type}" arg2="wchar_t"/> + </condition> + <property name="logchar_is_wchar" value="0"/> + <replaceregexp file="${include.dir}/log4cxx/log4cxx.h" - match="#define LOG4CXX_LOGCHAR_IS_UTF8.*" - replace="#define LOG4CXX_LOGCHAR_IS_UTF8 ${logchar_is_utf8}"/> + match="@LOGCHAR_IS_CFSTRING@" + replace="${logchar_is_cfstring}"/> <replaceregexp file="${include.dir}/log4cxx/log4cxx.h" + match="@LOGCHAR_IS_UTF8@" + replace="${logchar_is_utf8}"/> + + <replaceregexp file="${include.dir}/log4cxx/log4cxx.h" + match="@LOGCHAR_IS_WCHAR@" + replace="${logchar_is_wchar}"/> + + <replaceregexp file="${include.dir}/log4cxx/log4cxx.h" match="#define LOG4CXX_HAS_WCHAR_T.*" replace="#define LOG4CXX_HAS_WCHAR_T ${has.wchar_t}"/> - - </target> <target name="get-apr-module">
