From 894c61951e52e4d99c5c65f09d13a9640af5fc4e Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Sun, 14 Sep 2008 17:52:08 +0000 Subject: [PATCH] improved handling of Funambol client library source configure checks out the right source automatically. Subversion and git are supported. When given an existing directory with sources, out-of-tree compilation is used instead of making a copy first. git-svn-id: https://zeitsenke.de/svn/SyncEvolution/trunk@744 15ad00c4-1369-45f4-8270-35d70d36bdcd --- HACKING | 67 ++++++---------------- configure-pre.in | 136 ++++++++++++++++++++++++++++++-------------- src/Makefile-gen.am | 17 +++--- 3 files changed, 120 insertions(+), 100 deletions(-) diff --git a/HACKING b/HACKING index ccbfccad..9b03f799 100644 --- a/HACKING +++ b/HACKING @@ -1,45 +1,21 @@ Checking out the Source ----------------------- -SyncEvolution is hosted at sf.net. If you want to work -on the code, just let me know what your SF account is -and I can provide access to the developers CVS. The -anonymous CVS mirrors the sources automatically, but -sometimes is lacking a bit behind. Before using sources -checked out from CVS, invoke "sh autogen.sh" with -appropriate autotools packages installed. +SyncEvolution is hosted on estamos.de. Anonymous access is +via + svn checkout http://www.estamos.de/svn/SyncEvolution/trunk -The most recent version of the Sync4j C++ client library -is available from CVS, checkout the "3x" module from the CVS at - http://forge.objectweb.org/projects/sync4j -You'll need the files in 3x/client-api/native. +Before using sources checked out from Subversion, invoke "sh +autogen.sh" with appropriate autotools packages installed. -Also note that some of the patches in the -3x/client-api/native/.patches directory might be needed for -SyncEvolution to compile and work correctly. See -3x/client-api/native/README for more information about those patches -and SyncEvolution's NEWS file for some information which client -library is compatible. - -The recommended way to make that library available is by -installing it into its own directory with shared libraries disabled: - configure --prefix= --disable-shared; make; make install -and then pointing the configure of SyncEvolution towards it: - configure --with-sync4j= --disable-shared -Shared versions of the libraries are not recommended at the moment -because the client libraries API is not expected to be stable. - -Alternatively SyncEvolution can work with a source snapshot of -the client library directly: - configure --with-sync4j-src= -where points towards the contents of the 3x/client-api/native -directory. This mode is required to generate source distributions -because those are meant to contain a copy of the client library -code. +When running the configure script, it will check out the source of a +suitable Funambol client library which will be compiled +automatically. There are configure options for using a precompiled +Funambol client library or non-default sources - see the "funambol" +configure options for details. For doing development work the recommended configure line is: - configure --with-sync4j-src= \ - SYNCEVOLUTION_CXXFLAGS="-Wall -Werror -Wno-unknown-pragmas" \ + configure SYNCEVOLUTION_CXXFLAGS="-Wall -Werror -Wno-unknown-pragmas" \ --enable-unit-tests In contrast to CXXFLAGS, SYNCEVOLUTION_CXXFLAGS adds these flags only @@ -53,11 +29,11 @@ Working with the Code --------------------- The code follows the code formatting of the Funambol -Sync4j C++ client library. Just emulate the existing +C++ client library. Just emulate the existing code when possible. Exceptions derived from std::exception are used to report -errors, but not in code which is called from inside the Sync4j +errors, but not in code which is called from inside the client library because that library does not handle exceptions for compatibility reasons. In that case special case must be taken to not forget that an error occurred (EvolutionSyncSource::m_hasFailed). @@ -121,7 +97,7 @@ using ScheduleWorld as example: "make valgrind" runs the same tests inside valgrind [http://www.valgrind.org]. A suppression file is used to hide errors inside system libraries which -are not caused by SyncEvolution or Sync4j C++ +are not caused by SyncEvolution or Funambol C++ library code. Most likely the suppressions will only work on Debian GNU/Linux 3.1 ("Sarge") - feel free to add more for your system. @@ -147,17 +123,10 @@ Building a Release - compile binary .tar.gz packages for different Evolution versions; done automatically by runtests.py on estamos.de (= Debian 3.0), using different Garnome installations, and with special configure options to ensure maximum - portability (LDFLAGS=-W,--as-needed --enable-static-cxx) + portability (LDFLAGS=-Wl,--as-needed --enable-static-cxx) - compile .deb for Maemo -- add new .debs/.zip to www.estamos.de/download: - - distribution "stable" - - for ITOS2008 also "chinook" -- upload new files to sf.net -- remove files from www.estamos.de so that downloads access sf.net - update entries on the web about the release: - http://maemo.org/downloads/product/OS2006/syncevolution/ - http://maemo.org/downloads/product/OS2007/syncevolution/ - http://www.modmyiphone.com/ (?) + http://maemo.org/downloads/product/OS2008/syncevolution/ http://www.estamos.de/blog/wp-admin http://www.estamos.de/projects/SyncEvolution/Roadmap.html http://freshmeat.net/projects/syncevolution/ @@ -192,7 +161,7 @@ Compiling for iPhone AddressBook framework must be added to iphone-dev/include/install-headers.sh.in Compile with curl-config in the PATH: - PATH=/usr/local/iphone/bin/:$PATH ~/projects/sync4jevolution/configure --host=arm-apple-darwin --with-sync4j-src=/home/patrick/projects/native CXXFLAGS=-O0 --disable-ecal --disable-ebook --enable-addressbook --prefix=/usr + PATH=/usr/local/iphone/bin/:$PATH ~/projects/SyncEvolution/trunk/configure --host=arm-apple-darwin --with-funambol-src=/home/patrick/projects/native CXXFLAGS=-O0 --disable-ecal --disable-ebook --enable-addressbook --prefix=/usr PATH=/usr/local/iphone/bin/:$PATH make all Build a package with: @@ -202,7 +171,7 @@ Compiling for Mac OS X ---------------------- Configuring for development: - /configure --with-sync4j-src= \ + /configure --with-funambol-src= \ --enable-addressbook \ SYNCEVOLUTION_CXXFLAGS="-Wall -Werror -Wno-unknown-pragmas" \ LDFLAGS="-framework Addressbook -framework CoreServices" \ diff --git a/configure-pre.in b/configure-pre.in index db1e177e..cf36b8ee 100644 --- a/configure-pre.in +++ b/configure-pre.in @@ -1,15 +1,17 @@ dnl Invoke autogen.sh to produce a configure script. AC_INIT(src/syncevolution.cpp) -AM_INIT_AUTOMAKE(syncevolution, 0.8) +AM_INIT_AUTOMAKE(syncevolution, 0.8-trunk) +define([FUNAMBOLSRC_REPO], [https://core.forge.funambol.org/svn/core/tags/r_tested/3x/client-api/native]) +define([FUNAMBOLSRC_REVISION], [28731]) AM_CONFIG_HEADER(config.h) AC_LIBTOOL_DLOPEN dnl default device type (see AC_DEFINE below) DEVICE_TYPE=desktop -# command used to configure client library, including options -CLIENT_CONFIGURE=$PWD/src/client-api/build/autotools/configure +# options to be used when configuring client library +CLIENT_CONFIGURE_OPTIONS= AC_ARG_WITH(funambol, AS_HELP_STRING([--with-funambol=], @@ -21,16 +23,43 @@ AC_ARG_WITH(sync4j, [alias for --with-funambol]), [FUNAMBOL="$withval"]) +if test -e "$srcdir/src/client-api"; then + FUNAMBOLSRC_DEF="$srcdir/src/client-api" +else + FUNAMBOLSRC_DEF="FUNAMBOLSRC_REPO" +fi + AC_ARG_WITH(funambol-src, - AS_HELP_STRING([--with-funambol-src=], - [specifies location of the Funambol '3x/client-api/native' source code]), - [FUNAMBOLSRC="$withval"]) + AS_HELP_STRING([--with-funambol-src=], + [Specifies location of the Funambol 'client-api/native' source code. + Use this instead of --with-funambol when the client library is to + be compiled as part of the SyncEvolution compilation. In release + versions of SyncEvolution, a copy of the client library is bundled + under 'src/client-api' and compiled unless something else is + specified. --with-funambol-src can be given a path to sources + checked out already, a Subversion repository URL or a git repository + URL. When given a repository URL, then the configure script + will checkout the sources into 'src/client-api-copy' or + update that working copy if the directory already exists. + Default: bundled source in src/client-api (in released SyncEvolution sources), + FUNAMBOLSRC_REPO otherwise.]), + [FUNAMBOLSRC="$withval"], [FUNAMBOLSRC="$FUNAMBOLSRC_DEF"]) AC_ARG_WITH(sync4j-src, AS_HELP_STRING([--with-sync4j-src=], [alias for --with-funambol-src]), [FUNAMBOLSRC="$withval"]) +AC_ARG_WITH(funambol-username, + AS_HELP_STRING([--with-funambol-username=], + [username to use when checking out --with-funambol-src sources from Subversion, default 'guest']), + [USERNAME="$withval"], [USERNAME="guest"]) + +AC_ARG_WITH(funambol-revision, + AS_HELP_STRING([--with-funambol-revision=], + [Identifies which source revision to use from --with-funambol-src repository, empty string stands for latest. Default: FUNAMBOLSRC_REVISION]), + [REVISION="$withval"], [REVISION="FUNAMBOLSRC_REVISION"]) + AC_ARG_ENABLE(shared, AS_HELP_STRING([--enable-shared], [build backends as dynamically loadable modules]), @@ -80,11 +109,11 @@ AC_SUBST(CPPUNIT_LDFLAGS) AC_SUBST(CPPUNIT_TESTS) if test $enable_unit_tests == "yes"; then - CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-unit-tests" + CLIENT_CONFIGURE_OPTIONS="$CLIENT_CONFIGURE_OPTIONS --enable-unit-tests" AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code]) fi if test $enable_integration_tests == "yes"; then - CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-integration-tests" + CLIENT_CONFIGURE_OPTIONS="$CLIENT_CONFIGURE_OPTIONS --enable-integration-tests" AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable unit tests outside of the library's source code]) fi @@ -94,9 +123,10 @@ if test $enable_static_cxx == "yes"; then fi AC_SUBST(CORE_LDADD_DEP) -# preserve src/client-api by default +# preserve src/client-api by default, +# always CLEAN_CLIENT_SRC= -FUNAMBOL_LIB=$PWD/src/client-api.build/src/libfunambol.la +FUNAMBOL_LIB=$PWD/src/build-client-api/src/libfunambol.la AC_SUBST(CLEAN_CLIENT_SRC) @@ -133,48 +163,68 @@ if test "x$use_mac_ta" = "xyes"; then AC_SUBST(CURL_LDFLAGS) fi - +# absolute patch to source of Funambol client library +CLIENT_API_SRC=no-client-api-source +AC_SUBST(CLIENT_API_SRC) if test ! "$FUNAMBOL"; then if test "$FUNAMBOLSRC"; then - # make a copy of the sources, remove it during maintainer-clean and distclean - CLEAN_CLIENT_SRC=client-api + # default: checkout a copy of the sources, remove it during maintainer-clean and distclean + CLEAN_CLIENT_SRC=client-api-copy + CLIENT_API_SRC=$PWD/src/client-api-copy - AC_MSG_NOTICE( [updating the content of src/client-api from $FUNAMBOLSRC] ) - mkdir -p src/client-api - if cp --help 2>/dev/null | grep >/dev/null -e "--update"; then - # GNU cp - cp_opts="--update --archive" - else - cp_opts="-r" - fi + AC_MSG_NOTICE( [updating the content of $CLIENT_API_SRC from $FUNAMBOLSRC] ) + case "$FUNAMBOLSRC" in + *://*) protocol="`echo $FUNAMBOLSRC | sed -e 's;://.*;;'`";; + *) protocol="file";; + esac - if cp $cp_opts $FUNAMBOLSRC/* src/client-api; then - ( cd src/client-api/build/autotools && ( test -f configure || sh autogen.sh ) ) - else - AC_MSG_ERROR( [copying $FUNAMBOLSRC into src/client-api failed] ) - fi - find src/client-api/build/autotools/win* -name output | xargs rm -rf - find src/client-api/build/autotools/include/* src/client-api/build/autotools/src/* -type d | xargs rm -rf - find src/client-api -name "*~*" -o -name ".#*" -o -name "*.orig" -o -name "stamp-*" -o -name "*.o" -o -name "*.lo" -o -name .libs -o -name autom4te.cache -o -name config.status | xargs rm -rf - else - if test ! -d src/client-api; then - if test -d $srcdir/src/client-api; then - mkdir -p src - case $srcdir in - /*) ln -s $srcdir/src/client-api src/client-api;; - *) ln -s $PWD/$srcdir/src/client-api src/client-api;; + mkdir -p src + case $protocol in + file) + # use existing copy of the sources + CLEAN_CLIENT_SRC= + case "$FUNAMBOLSRC" in + /*) CLIENT_API_SRC="$FUNAMBOLSRC";; + *) CLIENT_API_SRC="$PWD/$FUNAMBOLSRC";; esac - fi - fi + ;; + *svn*|*http*) + if test -d $CLIENT_API_SRC ; then + ( set -x; cd $CLIENT_API_SRC && svn --username=$USERNAME switch -r "${REVISION:-HEAD}" "$FUNAMBOLSRC" ) || AC_ERROR([updating from $FUNAMBOLSRC failed]) + else + (set -x; svn --username=$USERNAME checkout -r "${REVISION:-HEAD}" "$FUNAMBOLSRC" $CLIENT_API_SRC ) || AC_ERROR([checking out $FUNAMBOLSRC failed]) + fi + ;; + *git*) + if test -d $CLIENT_API_SRC ; then + ( set -x; cd $CLIENT_API_SRC && git pull ) || AC_ERROR([updating from $FUNAMBOLSRC failed]) + else + ( set -x; git clone "$FUNAMBOLSRC" $CLIENT_API_SRC ) || AC_ERROR([checking out $FUNAMBOLSRC failed]) + fi + if test "$REVISION"; then + ( set -x; cd $CLIENT_API_SRC && git checkout "$REVISION" ) + fi + ;; + esac + else + # use existing copy of the sources; beware of + # out-of-tree compilation + case $srcdir in + /*) CLIENT_API_SRC="$srcdir/src/client-api";; + *) CLIENT_API_SRC="$PWD/$srcdir/src/client-api";; + esac fi - if test -f src/client-api/build/autotools/configure; then - chmod u+x src/client-api/build/autotools/configure src/client-api/build/autotools/config.sub src/client-api/build/autotools/config.guess + ( cd $CLIENT_API_SRC/build/autotools && ( test -f configure || sh autogen.sh ) ) + + if test -f $CLIENT_API_SRC/build/autotools/configure; then + CLIENT_CONFIGURE="$CLIENT_API_SRC/build/autotools/configure" + chmod u+x $CLIENT_API_SRC/build/autotools/configure $CLIENT_API_SRC/build/autotools/config.sub $CLIENT_API_SRC/build/autotools/config.guess # use local copy of the sources, with dependencies # to trigger building the client library - FUNAMBOL_SUBDIR=$PWD/src/client-api.build - FUNAMBOL_DEP=$PWD/src/client-api.build/src/libfunambol.la + FUNAMBOL_SUBDIR=$PWD/src/build-client-api + FUNAMBOL_DEP=$PWD/src/build-client-api/src/libfunambol.la FUNAMBOL_CFLAGS="-I$FUNAMBOL_SUBDIR/include/posix -I$FUNAMBOL_SUBDIR/include/common -I$FUNAMBOL_SUBDIR/include -I$FUNAMBOL_SUBDIR/test" FUNAMBOL_LIBS="-L$FUNAMBOL_SUBDIR/src -lfunambol" @@ -194,7 +244,7 @@ if test ! "$FUNAMBOL"; then # to check with autoconf for the right flags... FUNAMBOL_LIB_SHARED_FLAGS="-DPIC -fPIC" fi - if (set -x; mkdir -p $FUNAMBOL_SUBDIR && cd $FUNAMBOL_SUBDIR && $CLIENT_CONFIGURE --build=$build_alias --host=$host_alias --target=$target_alias --disable-shared --with-transport-agent=curl CFLAGS="$CFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" CXXFLAGS="$CXXFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" $cxx_lib_args); then true; else + if (set -x; mkdir -p $FUNAMBOL_SUBDIR && cd $FUNAMBOL_SUBDIR && $CLIENT_CONFIGURE $CLIENT_CONFIGURE_OPTIONS --build=$build_alias --host=$host_alias --target=$target_alias --disable-shared --with-transport-agent=curl CFLAGS="$CFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" CXXFLAGS="$CXXFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" $cxx_lib_args); then true; else AC_MSG_ERROR( [configuring client library failed] ) fi else diff --git a/src/Makefile-gen.am b/src/Makefile-gen.am index a8b45147..542566c3 100644 --- a/src/Makefile-gen.am +++ b/src/Makefile-gen.am @@ -7,6 +7,12 @@ AM_CPPFLAGS = $(SUBDIRS:%=-I$(srcdir)/%) @BACKEND_CPPFLAGS@ @FUNAMBOL_CFLAGS@ # the Funambol C++ client library SYNCEVOLUTION_CXXFLAGS = @SYNCEVOLUTION_CXXFLAGS@ +# set to directory name if the client API sources need to be removed +CLEAN_CLIENT_SRC=@CLEAN_CLIENT_SRC@ + +# set to absolute path of client API sources which need to be compiled +CLIENT_API_SRC=@CLIENT_API_SRC@ + bin_PROGRAMS = syncevolution bin_SCRIPTS = synccompare SYNCSOURCES = @SYNCSOURCES@ @@ -90,8 +96,8 @@ BUILT_SOURCES = $(FUNAMBOL_SUBDIR)/all $(CLIENT_LIB_TEST_FILES) # include client library in distribution dist-hook: - [ ! "$(FUNAMBOL_SUBDIR)" ] || cp -r client-api $(distdir) - find $(distdir) -name .libs -o -name "*~" -o -name ".*" -o -name "*.o" -o -name "*.lo" -o -name CVS -o -name autom4te.cache | xargs rm -rf + [ ! "$(FUNAMBOL_SUBDIR)" ] || mkdir -p $(distdir)/client-api && cp -r $(CLIENT_API_SRC)/* $(distdir)/client-api + find $(distdir) -name .libs -o -name "*~" -o -name ".*" -o -name "*.o" -o -name "*.lo" -o -name CVS -o -name .svn -o -name .git -o -name autom4te.cache | xargs rm -rf clean-local: testclean rm -rf testcases @@ -103,7 +109,7 @@ testclean: distclean-local: rm -rf $(FUNAMBOL_SUBDIR) - rm -rf @CLEAN_CLIENT_SRC@ # "client-api", only set when it was created by configure + rm -rf $(CLEAN_CLIENT_SRC) # With --disable-shared autotools links against libfunambol.a which does not # pull any of the test suites into the test binary, so they would not be @@ -162,11 +168,6 @@ $(FUNAMBOL_SUBDIR)/%.h : $(FUNAMBOL_SUBDIR)/% : [ ! "$(FUNAMBOL_SUBDIR)" ] || ( cd ${@D} && $(MAKE) ${@F} ) -# compare the local copy of the C++ client library against -# the files where it was copied from -client-api-diff : - diff -r -c -x CVS -x config.guess -x config.sub -x depcomp -x install-sh -x ltmain.sh -x missing -x aclocal.m4 -x configure -x '.#*' -x '*~' -x '*.in' -x autom4te.cache $(FUNAMBOLSRC) client-api - # special target for testing with valgrind valgrind : test valgrind --leak-check=yes --suppressions=valgrind.supp ./test