You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Peter Koellner <pe...@mezzo.net> on 2000/10/15 05:46:42 UTC

ICUMsgLoader, configuration tips

well, the makefile does not stop on fatal errors, so after reinstalling the
original sources i found out that src/util/MsgLoader/ICU/ICUMsgLoader.cpp
wouldn't compile in the first place. That leads to Linux PlatformUtils missing
in libxerces.so.
first of all, the #include "resbund.h" does not work, since it
is under $ICUROOT/include/unicode/resbund.h, so it should read 
#include <unicode/resbund.h>.
then, the constructor contains an undefined variable tmpPath on getting a
ResourceBundle. next, loadMsg tries to get a message string from
ResourceBundle->getString passing a UnicodeString, which won't work because
getString takes a const char* as key string, at least in the ICU source release
i downloaded on the same day (1.6).

-------------------
here are a few hints about GNU building environments, to put that issue to
an end. maybe you guys might choose to change the source layout at some point
in the future, so here are a few things that might be done step by step.

1. sources
if there are platform dependent implementations, check for each if they can be
unified with other platforms. each copy of the same method makes modifying the
whole system more difficult. better use preprocessor switches as locally as
possible. if inventing compiler- or system-dependent definitions, first make
sure there is no standard covering that. then, build a SINGLE header file
containing preprocessor switches for each system flavor. this way you can see
exactly if there is really need for many different configurations. if there is
the need for different implementation files: there might be the need to not
only do operating systems seperately, but also host machine architectures, like
sparc-solaris, ix86-solaris, ix86-linux, sparc-linux, arm-linux with both
endiannesses... so it is better to isolate differences than to isolate
platforms.

2. gnu make
for entering subdirectories, instead of cd $(SUBDIR); $(MAKE) ...; cd .. use
$(MAKE) -C $(SUBDIR) ...
use ":" instead of "::" to declare compile targets. if possible, let automake
and libtool figure out how to build shared libraries and program targets.

3. configure

normally it is not needed to import or export compiler or linker flags
explicitly.

macros

AC_EXEEXT   checks for extension of executables on the platform. on unix,
normally empty. output variable EXEEXT

AC_OBJEXT checks for the object file extension. output in OBJEXT (equiv. $(TO)
now)

AC_BIG_ENDIAN  defines WORDS_BIG_ENDIAN if MSB last on platform

 you can check for command line option with AC_ARG_ENABLE and
AC_ARG_WITH macros. usage:

for --enable-FEATURE[=ARG] and disable-FEATURE:

AC_ARG_ENABLE(FEATURE, HELP-STRING, [ACTION-IF-GIVEN [,ACTION-IF-NOT-GIVEN]])

example:

configure --enable-threads=pthread (default="no")

AC_ARG_ENABLE(threads, [  --enable-threads=ARG  enables thread. ARG is pthread
or dce],,enable_threads="no")

remember to put [] (m4 delimiters) around multiple line values


AC_ARG_WITH example:

dnl test for ICU libraries
AC_ARG_WITH(icu,
dnl help text next
[  --with-icu-dir=DIR      icu unicode library. libs in DIR/lib.],
dnl action if --with-icu-dir or --without-icu-dir given on cmdline
[case "$withval" in
	n|no)	;;
	*)	AC_MSG_CHECKING(ICU libraries)
		icu_root=$withval
		AC_CHECK_LIB(icu-uc, getVersion, AC_DEFINE(HAVE_ICU), [
			LDFLAGS="$LDFLAGS -L$with_icu_dir/lib"
			LDLIBS="$LDLIBS -licu-uc -licudata"
			AC_MSG_RESULT("$LDFLAGS $LDLIBS")
		], AC_MSG_ERROR(not found))
		;;
esac],
dnl action if option not specified next
[
dnl do auto-check in known standard directories here
])

hope this is errorfree.

more complex:

THREADLIBS=""
if test "$enable_threads" = "yes"; then
	if test "$AIX" = "1"; then
		# POSIX threads are the default choice:
		# pthreads plural on AIX. check for pthread_attr_init instead
		# of pthread_create here... 
		# check for more AIX brokenness later...
		if test -z "$THREADLIBS"; then
			AC_CHECK_LIB(pthreads, pthread_attr_init,
				[THREADLIBS="-lpthreads"
				 AC_DEFINE(HAVE_POSIX_THREADS)])
		fi
	fi
	# normally POSIX threads are in -lpthread
	if test -z "$THREADLIBS"; then
		AC_MSG_CHECKING([for pthread_create in -lpthread])
		save_LIBS="$LIBS"
		LIBS="-lpthread $LIBS"
		AC_TRY_LINK([#include <pthread.h>],
				[pthread_create(0,0,0,0);],
				ok=yes,ok=no)
		LIBS="$save_LIBS"
		if test "$ok" = "yes"; then
			THREADLIBS="-lpthread"
			AC_DEFINE(HAVE_POSIX_THREADS)
		fi
		AC_MSG_RESULT(${ok})
	fi
	# (...) test for other thread libraries
fi

this was stolen from the fast fourier transformation package fftw-2.1.3
(www.fftw.org)

there should be documentation for automake and autoconf be available using
info autoconf
info automake

4. automake and libtool:
configure.in:

AC_INIT(util/XercesDefs.hpp)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(xerces, 1.3.0)
AM_CONFIG_HEADER(config.h)
AC_PREFIX_DEFAULT("/usr/local/xerces")

dnl check which c compiler is used
AC_PROG_CC
dnl check which c++ is used
AC_PROG_CXX
AM_PROG_LIBTOOL

AC_EXEEXT
AC_OBJEXT
(...)

5. installation

if you create custom toplevel directories, do NOT set the default installation
prefix to /usr or /usr/local. 

-- 
peter koellner <pe...@mezzo.net>
canbox mobile reaction forces ;-)

Re: ICUMsgLoader, configuration tips

Posted by Dean Roddey <dr...@charmedquark.com>.
As someone who has a lot of experience in portable code writing, I'd like to
put a little spin on some of what you are saying... What you are discussing
is the *technically* correct thing to do, but that's not alway the best
thing to do, mainly for two reasons:

1. In many cases, these different platform versions are maintained by
completely different people. They might not know squat about the other
variations. Therefore, its often less complex to not mix them, so that each
person can maintain their platform version in isolation.

2. Over use of conditional code makes breaks just as likely as having some
redundant code, particularly in light of #1 above. It is often impossible
for someone to modify heavily conditionalized code and be sure that they
didn't break another variant using the same file. The only way to confirm
this is via an emperical build of every variant, which they cannot do, thus
pushing the onus onto the XML team.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"It takes two buttocks to make friction"
    - African Proverb


----- Original Message -----
From: "Peter Koellner" <pe...@mezzo.net>
To: <xe...@xml.apache.org>
Sent: Saturday, October 14, 2000 8:46 PM
Subject: ICUMsgLoader, configuration tips


> well, the makefile does not stop on fatal errors, so after reinstalling
the
> original sources i found out that src/util/MsgLoader/ICU/ICUMsgLoader.cpp
> wouldn't compile in the first place. That leads to Linux PlatformUtils
missing
> in libxerces.so.
> first of all, the #include "resbund.h" does not work, since it
> is under $ICUROOT/include/unicode/resbund.h, so it should read
> #include <unicode/resbund.h>.
> then, the constructor contains an undefined variable tmpPath on getting a
> ResourceBundle. next, loadMsg tries to get a message string from
> ResourceBundle->getString passing a UnicodeString, which won't work
because
> getString takes a const char* as key string, at least in the ICU source
release
> i downloaded on the same day (1.6).
>