- Introduce preliminary WAF build system support for libmapistore
authorjkerihuel <jkerihuel@71d39326-ef09-db11-b2a4-00e04c779ad1>
Wed, 16 Feb 2011 23:04:06 +0000 (23:04 +0000)
committerjkerihuel <jkerihuel@71d39326-ef09-db11-b2a4-00e04c779ad1>
Wed, 16 Feb 2011 23:04:06 +0000 (23:04 +0000)
- Remove libmapi/libmapi.h references within libmapistore

- Add a WAF_BUILD_INC macros to config.mk.in so waf and autoconf
  requirements with regards to includes gets similar

- Change libmapistore includes

git-svn-id: https://svn.openchange.org/openchange@2670 71d39326-ef09-db11-b2a4-00e04c779ad1

19 files changed:
trunk/Makefile
trunk/buildtools/waf [new file with mode: 0755]
trunk/config.mk.in
trunk/mapiproxy/libmapistore/Makefile [new file with mode: 0644]
trunk/mapiproxy/libmapistore/configure [new file with mode: 0755]
trunk/mapiproxy/libmapistore/database/mapistoredb.c
trunk/mapiproxy/libmapistore/database/mapistoredb_conf.c
trunk/mapiproxy/libmapistore/database/mapistoredb_namedprops.c
trunk/mapiproxy/libmapistore/indexing/mapistore_indexing.c
trunk/mapiproxy/libmapistore/mapistore.h
trunk/mapiproxy/libmapistore/mapistore_indexing.c
trunk/mapiproxy/libmapistore/mapistore_interface.c
trunk/mapiproxy/libmapistore/mapistore_ldb_wrap.c
trunk/mapiproxy/libmapistore/mapistore_namedprops.c
trunk/mapiproxy/libmapistore/mapistore_private.h
trunk/mapiproxy/libmapistore/mapistore_processing.c
trunk/mapiproxy/libmapistore/mapistore_tdb_wrap.c
trunk/mapiproxy/libmapistore/wscript [new file with mode: 0644]
trunk/pyopenchange/pymapistore.h

index b95ca2b8893c57b1dcb04ff80433b13d89469d86..ae5d9f89215b92c2cc17fef56615fdaa22f72027 100644 (file)
@@ -103,11 +103,11 @@ re:: clean install
 
 .c.o:
        @echo "Compiling $<"
-       @$(CC) $(CFLAGS) -c $< -o $@
+       @$(CC) $(WAF_BUILD_INC) $(CFLAGS) -c $< -o $@
 
 .c.po:
        @echo "Compiling $< with -fPIC"
-       @$(CC) $(CFLAGS) -fPIC -c $< -o $@
+       @$(CC) $(WAF_BUILD_INC) $(CFLAGS) -fPIC -c $< -o $@
 
 .cpp.o:
        @echo "Compiling $< with -fPIC"
@@ -1544,12 +1544,12 @@ $(pythonscriptdir)/openchange/ocpf.$(SHLIBEXT): pyopenchange/pyocpf.c                           \
 $(pythonscriptdir)/openchange/mapistore.$(SHLIBEXT):   pyopenchange/pymapistore.c                              \
                                                        mapiproxy/libmapistore.$(SHLIBEXT).$(PACKAGE_VERSION)
        @echo "Linking $@"
-       @$(CC) $(CFLAGS) $(DSOOPT) $(LDFLAGS) -o $@ $^ `$(PYTHON_CONFIG) --cflags --libs` $(LIBS)
+       @$(CC) $(WAF_BUILD_INC) $(CFLAGS) $(DSOOPT) $(LDFLAGS) -o $@ $^ `$(PYTHON_CONFIG) --cflags --libs` $(LIBS)
 
 $(pythonscriptdir)/openchange/mapistoredb.$(SHLIBEXT): pyopenchange/pymapistoredb.c                            \
                                                        mapiproxy/libmapistore.$(SHLIBEXT).$(PACKAGE_VERSION)
        @echo "Linking $@"
-       @$(CC) $(CFLAGS) $(DSOOPT) $(LDFLAGS) -o $@ $^ `$(PYTHON_CONFIG) --cflags --libs` $(LIBS)
+       @$(CC) $(WAF_BUILD_INC) $(CFLAGS) $(DSOOPT) $(LDFLAGS) -o $@ $^ `$(PYTHON_CONFIG) --cflags --libs` $(LIBS)
 
 pyopenchange/pymapi_properties.c:              \
        libmapi/conf/mapi-properties            \
diff --git a/trunk/buildtools/waf b/trunk/buildtools/waf
new file mode 100755 (executable)
index 0000000..29628d5
Binary files /dev/null and b/trunk/buildtools/waf differ
index ff9a7f88504384ad5c706dd2d1d06016881de9f6..3e714507fa63e884cefa95de6b2a4962d5a9d5e9 100644 (file)
@@ -40,6 +40,8 @@ CFLAGS=@CFLAGS@ @COMPILER_OPTIONS_C@ @ASSERT_DEFINITION@ @SUBUNIT_CFLAGS@                             \
        -DLZFU_DATADIR=\"$(datadir)/mapitest/lzfu\"                                                     \
        -DHAVE_ICAL_0_46=@have_libical_0_46@
 
+WAF_BUILD_INC=-Imapiproxy/libmapistore -Imapiproxy/libmapistore/indexing/gen_ndr
+
 # This value should be determined by configure at some point
 SHLIBEXT=so
 PACKAGE_VERSION=@PACKAGE_VERSION@
diff --git a/trunk/mapiproxy/libmapistore/Makefile b/trunk/mapiproxy/libmapistore/Makefile
new file mode 100644 (file)
index 0000000..b716182
--- /dev/null
@@ -0,0 +1,39 @@
+# simple makefile wrapper to run waf
+
+WAF=WAF_MAKE=1 PATH=buildtools:../../buildtools:$$PATH waf
+
+all:
+       $(WAF) build
+
+install:
+       $(WAF) install
+
+uninstall:
+       $(WAF) uninstall
+
+dist:
+       touch .tmplock
+       WAFLOCK=.tmplock $(WAF) dist
+
+distcheck:
+       touch .tmplock
+       WAFLOCK=.tmplock $(WAF) distcheck
+
+clean:
+       $(WAF) clean
+
+distclean:
+       $(WAF) distclean
+
+reconfigure: configure
+       $(WAF) reconfigure
+
+show_waf_options:
+       $(WAF) --help
+
+pydoctor:
+       $(WAF) pydoctor
+
+bin/%:: FORCE
+       $(WAF) --targets=`basename $@`
+FORCE:
diff --git a/trunk/mapiproxy/libmapistore/configure b/trunk/mapiproxy/libmapistore/configure
new file mode 100755 (executable)
index 0000000..1b03ab1
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+PREVPATH=`dirname $0`
+
+if [ -f $PREVPATH/../../buildtools/waf ]; then
+       WAF=../../buildtools/waf
+elif [ -f $PREVPATH/buildtools/bin/waf ]; then
+       WAF=./buildtools/waf
+else
+       echo "replace: Unable to find waf"
+       exit 1
+fi
+
+# using JOBS=1 gives maximum compatibility with
+# systems like AIX which have broken threading in python
+JOBS=1
+export JOBS
+
+cd . || exit 1
+$WAF configure "$@" || exit 1
+cd $PREVPATH
\ No newline at end of file
index 8a67a406cdb8081bec2b414bb87319f28b94ab34..a6cc1019c067274dc274b8a88796832bce0a6f90 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "mapiproxy/libmapistore/mapistore_errors.h"
-#include "mapiproxy/libmapistore/mapistore.h"
-#include "mapiproxy/libmapistore/mapistore_private.h"
-#include "mapiproxy/libmapistore/mapistore_common.h"
+#include <string.h>
+
+#include "mapistore_errors.h"
+#include "mapistore.h"
+#include "mapistore_private.h"
+#include "mapistore_common.h"
+
+#include <param.h>
 
 /**
    \file mapistoredb.c
index bec5fbf280ebcb801649d31ed4be3b90a91bf21e..88fab06d34251646c7a7bf4b7508ffa8961edfe0 100644 (file)
@@ -19,9 +19,9 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "mapiproxy/libmapistore/mapistore_errors.h"
-#include "mapiproxy/libmapistore/mapistore.h"
-#include "mapiproxy/libmapistore/mapistore_private.h"
+#include "mapistore_errors.h"
+#include "mapistore.h"
+#include "mapistore_private.h"
 
 /**
    \details Get accessor for netbiosname
index 8a8430c2c4aad9089f2eb033e2fbb7fbc030f136..ce561f6a1124bcc9222187d897b042911a39ab31 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "mapiproxy/libmapistore/mapistore_errors.h"
-#include "mapiproxy/libmapistore/mapistore.h"
-#include "mapiproxy/libmapistore/mapistore_private.h"
-#include "mapiproxy/libmapistore/mapistore_common.h"
+#include <string.h>
+
+#include "mapistore_errors.h"
+#include "mapistore.h"
+#include "mapistore_private.h"
+#include "mapistore_common.h"
 
 /**
    \file mapistoredb_namedprops.c
index 0471bd8bcb221acc7d2b9069c4574dfcd5c75383..209964b2ece506d74eedcb3e34de0059c3c3e8be 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <errno.h>
+#include <fcntl.h>
 #include <string.h>
 
-#include "mapiproxy/libmapistore/mapistore_errors.h"
-#include "mapiproxy/libmapistore/mapistore.h"
-#include "mapiproxy/libmapistore/mapistore_common.h"
-#include "mapiproxy/libmapistore/mapistore_private.h"
-#include "gen_ndr/ndr_mapistore_indexing_db.h"
+#include "mapistore_errors.h"
+#include "mapistore.h"
+#include "mapistore_common.h"
+#include "mapistore_private.h"
+#include "ndr_mapistore_indexing_db.h"
 
 #include <dlinklist.h>
 #include <tdb.h>
@@ -649,6 +651,8 @@ static enum MAPISTORE_ERROR mapistore_indexing_del_entry_r(struct mapistore_inde
        MAPISTORE_RETVAL_IF(!mictx, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
        MAPISTORE_RETVAL_IF(!mapistore_uri, MAPISTORE_ERR_NOT_INITIALIZED, NULL);
 
+       mem_ctx = talloc_named(NULL, 0, __FUNCTION__);
+
        key.dptr = (unsigned char *)talloc_asprintf(mem_ctx, MAPISTORE_INDEXING_URI, mapistore_uri);
        key.dsize = strlen((const char *)key.dptr);
 
index 764a546d844ec1671fc6fd6dd1d1c707ad5ae9e3..cce9900e9d0c3ca8b5262a4fa76405df29c0f8c6 100644 (file)
@@ -52,7 +52,8 @@
 #include <talloc.h>
 #include <util/debug.h>
 
-#include "libmapi/libmapi.h"
+/* #include "libmapi/libmapi.h" */
+#include "gen_ndr/exchange.h"
 
 #include "mapistore_defs.h"
 
index ace74d098f35f0211028de6fee390461ed45d0a8..314b9507f554fd14fc7aafb53995627672985d41 100644 (file)
 #define __STDC_FORMAT_MACROS   1
 #include <inttypes.h>
 
+#include <errno.h>
+#include <fcntl.h>
+
+#define _GNU_SOURCE    1
 #include <string.h>
 
 #include "mapistore_errors.h"
 #include "mapistore_common.h"
 #include "mapistore_private.h"
 #include <dlinklist.h>
-#include "libmapi/libmapi_private.h"
 
 #include <tdb.h>
 
+char *strcasestr(const char *, const char *);
+
 /**
    \details Search the indexing record matching the username
 
@@ -453,7 +458,7 @@ _PUBLIC_ enum MAPISTORE_ERROR mapistore_indexing_get_folder_list(struct mapistor
        flist->count = 0;
        
        tmp_uri = uri;
-       while ((substr = strcasestr(uri, "0x")) != NULL) {
+       while ((substr = (char *)strcasestr((const char *) uri, "0x")) != NULL) {
                folder = talloc_strndup(mstore_ctx, substr, 18);
                flist->folderID[flist->count] = strtoull(folder, NULL, 16);
                if (flist->folderID[flist->count] != fmid) {
index b8ecad3184293a5a39845505f168553c90b3aecf..a2ddb4204cf39c3b971bba304224d09eb8434645 100644 (file)
@@ -37,7 +37,6 @@
 #include "mapistore_backend.h"
 #include "mapistore_common.h"
 #include <dlinklist.h>
-#include "libmapi/libmapi_private.h"
 
 #include <string.h>
 
index ed5d389ed34dc365b8c0769602fc8b56bea8cfa9..66fa444c39a75a539182c0dc3ce204059254450e 100644 (file)
@@ -19,7 +19,7 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "config.h"
+/* #include "config.h" */
 #include <stdio.h>
 #include <string.h>
 
index 2636ce5af41ca3ccc100ea9dfe9977a930ce9dde..83d02f47381c25d51e630b5910916a69e4f61a8a 100644 (file)
@@ -23,7 +23,6 @@
 #include "mapistore.h"
 #include "mapistore_common.h"
 #include "mapistore_private.h"
-#include "libmapi/libmapi_private.h"
 #include <ldb.h>
 
 #include <sys/stat.h>
index 122218160336229b20ad23a7b99b8ccdb725f3a7..7e7f88a50672af1a1ffffc904adbfc9c336dfe80 100644 (file)
 
 #define        __STDC_FORMAT_MACROS    1
 #include <inttypes.h>
-
-#include "mapiproxy/libmapistore/indexing/gen_ndr/mapistore_indexing_db.h"
-
 #include <talloc.h>
 
+#include "mapistore_indexing_db.h"
+
 #ifndef        ISDOT
 #define ISDOT(path) ( \
                        *((const char *)(path)) == '.' && \
index cc7575e07155d7a5ea2aae597b5927472db38f2e..fbeae5342f0b35834337ad070a3c42f01736af02 100644 (file)
@@ -35,7 +35,6 @@
 #include "mapistore_common.h"
 #include "mapistore_private.h"
 #include <dlinklist.h>
-#include "libmapi/libmapi_private.h"
 
 #include <tdb.h>
 
index f635be305d2aa55d6439042f6c1daac57a13de6e..caa193d0634e3c765829c5e9cf4882a7bba53028 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-#include "config.h"
-#include <stdio.h>
-#include <string.h>
-
 #include "mapistore_errors.h"
 #include "mapistore.h"
 #include "mapistore_private.h"
 #include <dlinklist.h>
 
+#include <stdio.h>
+#include <string.h>
+
 static struct tdb_wrap *tdb_list;
 
 /* destroy the last connection to a tdb */
diff --git a/trunk/mapiproxy/libmapistore/wscript b/trunk/mapiproxy/libmapistore/wscript
new file mode 100644 (file)
index 0000000..5468b02
--- /dev/null
@@ -0,0 +1,104 @@
+from waflib.Task import Task
+from waflib.TaskGen import extension
+import os
+
+APPNAME = 'mapistore'
+VERSION = '2.0'
+
+top = '.'
+out = 'build'
+
+def options(ctx):
+    ctx.load('compiler_c')
+    ctx.add_option('--datadir',type='string',default='',dest='datadir',help='read-only application data')
+
+def configure(conf):
+    conf.load('compiler_c')
+
+    conf.env.CPPFLAGS = ['-Wall', '-Werror', '-g3', '-fstrict-aliasing', '-Wp,-D_FORTIFY_SOURCE=2', 
+                         '-Wmissing-prototypes', '-Wstrict-prototypes']
+
+    prefix = conf.options.prefix
+    libdir = os.path.join(prefix, "lib")
+    mapistore_path = os.path.join(prefix, 'private/mapistore')
+
+    def getstr(varname):
+        return getattr(conf.options,varname,'')
+    
+    datadir=getstr('datadir')
+    if not datadir:datadir=os.path.join(prefix,'share')
+
+    conf.define('MAPISTORE_MAPPING_PATH', mapistore_path)
+    conf.define('MAPISTORE_DBPATH', os.path.join(mapistore_path, "mapistore.ldb"))
+    conf.define('MAPISTORE_LDIF', datadir)
+    conf.define('MAPISTORE_BACKEND_INSTALLDIR', os.path.join(libdir, "mapistore_backends"))
+    conf.define('MAPISTORE_DB_NAMEDPROPS_PATH', os.path.join(mapistore_path, "mapistore_named_properties.ldb"))
+
+    conf.check_cfg(atleast_pkgconfig_version='0.20')
+
+    conf.check_cfg(package='tdb',
+                  args=['tdb >= 0.25', '--cflags', '--libs'],
+                  uselib_store='TDB',
+                  msg="Checking for 'tdb 0.25'")
+
+    conf.check_cfg(package='talloc',
+                   args=['talloc >= 0.25', '--cflags', '--libs'],
+                   uselib_store='TALLOC',
+                   msg="Checking for 'talloc 0.25'")
+
+    conf.check_cfg(package='samba-hostconfig',
+                   args=['--cflags', '--libs'],
+                   uselib_store='SAMBA-HOSTCONFIG',
+                   msg="Checking for 'samba-hostconfig 0.25'")
+
+    try:
+       conf.find_program('pidl', var='PIDL')
+    except ctx.errors.ConfigurationError:
+       self.fatal("PIDL compiler not found")
+
+    print("prefix is " + conf.options.prefix)
+
+def post(ctx):
+        if ctx.cmd == 'install':
+            ctx.exec_command('/sbin/ldconfig')
+
+class idl(Task):
+    run_str = '${PIDL} --outputdir=indexing --header --ndr-parser -- ${SRC}'
+    color   = 'BLUE'
+    ext_out = ['.h', '.c']
+
+@extension('.idl')
+def process_idl(self, node):
+    ndr_node = node.change_ext('.c')
+
+    try:
+        ndr_node.name.index("ndr_")
+    except ValueError:
+        ndr_node.name = "ndr_" + ndr_node.name
+    h_node = node.change_ext('.h')
+    self.create_task('idl', node, [ndr_node, h_node])
+    self.source.append(ndr_node)
+
+def build(bld):
+    bld.shlib(
+        source = [
+            'indexing/mapistore_indexing_db.idl',
+            'mapistore_interface.c',
+            'mapistore_processing.c', 
+            'mapistore_backend.c',
+            'mapistore_backend_defaults.c',
+            'mapistore_backend_public.c', 
+            'mapistore_tdb_wrap.c',
+            'mapistore_ldb_wrap.c',
+            'mapistore_namedprops.c',
+            'mapistore_indexing.c',
+            'database/mapistoredb.c',
+            'database/mapistoredb_conf.c',
+            'database/mapistoredb_namedprops.c',
+            'indexing/mapistore_indexing.c',
+            ],
+        target = 'mapistore',
+        includes     = ['.', '../../', 'build/indexing'],
+        use    = ['TDB', 'TALLOC', 'SAMBA-HOSTCONFIG'])
+
+    bld.add_post_fun(post)
index 1c20e4aa6bffcbdbfc595a8ad43d33e52c8ab5ad..4135de04b4c45fe3cad4f3f42475278913ccebd5 100644 (file)
@@ -23,9 +23,9 @@
 #define        __PYMAPISTORE_H_
 
 #include <Python.h>
-#include "mapiproxy/libmapistore/mapistore_errors.h"
-#include "mapiproxy/libmapistore/mapistore.h"
-#include "mapiproxy/libmapistore/mapistore_private.h"
+#include "mapistore_errors.h"
+#include "mapistore.h"
+#include "mapistore_private.h"
 
 typedef struct {
        PyObject_HEAD