Hi List,

I have been working lately on building/running OpenChange under FreeBSD.
It required a few changes both in Samba4 and OpenChange but I was
finally able to make openchange compiles properly and both mapiprofile
and openchangeclient to work (profile creation + fetchmail).


[0x1] Samba4 compilation (samba4-alpha6 release)
================================================

[*] samba4/lib/tevent/tevent.mk:50
FreeBSD doesn't like `$(PYTHON_CONFIG) --libs`. This needs to be
replaced with `$(PYTHON_CONFIG) --ldflags`

[*] samba4/source4/heimdal/lib/roken/rkpty.c:94
Add defined(__freebsd__) to the #if directive
        
[*] installed ndr.h header /usr/local/samba/include/ndr.h
Add the following snipset after the includes directives. FreeBSD doesn't
provide comparison_fn_t. The following just defines it, ugly ... but fix
the problem.
        
        #ifndef comparison_fn_t
        typedef int (*__compar_fn_t) (__const void *, __const void *);
        typedef __compar_fn_t comparison_fn_t;
        #endif 
        

[0x2] OpenChange compilation (trunk)
====================================

A preliminary hack/patch in order to compile openchange under FreeBSD is
available in attachment.

[*] libpopt not in library search path
FreeBSD installs libpopt in /usr/local so we need to add this path to
CFLAGS and LDFLAGS in order AC_CHECK_LIB test to work.
        
[*] getline() stdio.h function is missing on FreeBSD. 
I abused the system by checking for the getline library (which I know is
completely wrong). We'll probably need to either change getline call or
rewrite an implementation for it.

[*] FreeBSD 7.0 flex version is 2.5.4.
Installing /usr/ports/textproc/flex (2.5.35) and overwriting the PATH
variable so /usr/local/bin/flex is used instead of default /usr/bin/flex
fixes the issue. Maybe we should check for flex version in configure
script?

[*] time.h daylight extern int doesn't exist on FreeBSD
Defining it locally fixes the problem. However I'm not convinced this
workaround wouldn't have unwilling side effects.

[*] libocpf/lex.l doesn't require comparison_fn_t to be defined

[*] O_DIRECTORY open flag doesn't exist on FreeBSD (used in
utils/openchangeclient.c)
I added some if defined FreeBSD + check for directory with opendir.

[*] utils/mapiprofile.c is using sighandler_t which is not defined on
FreeBSD. I added the typedef + casted signal pointer on function to
sig_t.

[*] Finally - this must be me - but I was unable to make ldconfig
automatically symbolic links for /usr/local/lib/*.so
-> /usr/local/lib/*.so.0 and had to create these links manually :/


Cheers,
Julien.

-- 
Julien Kerihuel
[email protected]
OpenChange Project Manager

GPG Fingerprint: 0B55 783D A781 6329 108A  B609 7EF6 FE11 A35F 1F79

Index: config.mk.in
===================================================================
--- config.mk.in	(revision 1149)
+++ config.mk.in	(working copy)
@@ -42,11 +42,14 @@
 CFLAGS+=-Duint_t="unsigned int" 
 
 cflag...@samba_cflags@ @LDB_CFLAGS@ @TALLOC_CFLAGS@
-lib...@samba_libs@ @LDB_LIBS@ @TALLOC_LIBS@
+lib...@samba_libs@ @LDB_LIBS@ @TALLOC_LIBS@ @GETLINE_LIBS@
 
 # Assign CFLAGS to CXXFLAGS
 cxxfla...@cflags@ -I. @SAMBA_CFLAGS@ @LDB_CFLAGS@ @TALLOC_CFLAGS@
 
+# FreeBSD libraries
+getline_li...@getline_libs@
+
 # OPENCHANGE LIBRARIES
 oc_i...@oc_idl@
 oc_li...@oc_libs@
Index: configure.ac
===================================================================
--- configure.ac	(revision 1149)
+++ configure.ac	(working copy)
@@ -110,7 +110,29 @@
 fi[]
 ])
 
+dnl ############################################################################
+dnl Check for particular build options - operating system dependent
+dnl ############################################################################
+AC_ARG_ENABLE([freebsd],
+	AS_HELP_STRING([--enable-freebsd], [compile for freebsd [[yes]]]),
+	[
+		case "${enableval}" in
+		     yes) BUILD_FOR_FREEBSD=yes ;;
+		     no) BUILD_FOR_FREEBSD=no;;
+		     *) AC_MSG_ERROR(bad value ${enableval} for --enable-freebsd) ;;
+		esac
+	], [BUILD_FOR_FREEBSD=no])
+
 dnl ###########################################################################
+dnl FreeBSD installs its version of libpopt into /usr/local/, but does
+dnl not put that on the default library and header path.
+dnl ###########################################################################
+if test x"$BUILD_FOR_FREEBSD" = x"yes"; then
+   CFLAGS+=-I/usr/local/include
+   LIBS+=-L/usr/local/lib
+fi
+
+dnl ###########################################################################
 dnl libmapi and required dependencies
 dnl ###########################################################################
 
@@ -313,6 +335,8 @@
 	       enable_libpopt="no"
              ])
 
+enable_libpopt="yes"
+
 if test x"$enable_libpopt" = x"yes"; then
    	if test x"$enable_libmapiadmin" = x"yes"; then
 	   OC_RULE_ADD(openchangepfadmin, TOOLS)
@@ -348,13 +372,33 @@
 	       enable_libmagic="no"
  	     ])
 
+if test x"$BUILD_FOR_FREEBSD" = x"yes"; then
+AC_CHECK_LIB([getline], [getline], 
+        [
+		GETLINE_LIBS="-L/usr/local/lib -lgetline"
+		enable_libgetline="yes"
+        ],
+	[
+		AC_MSG_WARN([libgetline is missing - can't build exchange2mbox])
+		enable_libgetline="no"
+        ])
+fi
+AC_SUBST(GETLINE_LIBS)
+
+
 if test x"$enable_libmagic" = x"yes"; then
    	AC_CHECK_LIB([z], [gzopen], [], 
 		     [
 		       AC_MSG_ERROR([Z library not found, please install zlib-devel.], [1])
 		     ])
    	if test x"$enable_libpopt" = x"yes"; then
-	   OC_RULE_ADD(exchange2mbox, TOOLS)
+	   if test x"$BUILD_FOR_FREEBSD" = x"yes"; then
+	      if test x"$enable_libgetline" = x"yes"; then
+	      	OC_RULE_ADD(exchange2mbox, TOOLS)
+	      fi
+	   else
+		OC_RULE_ADD(exchange2mbox, TOOLS)
+	   fi
 	fi
 fi
 
Index: Makefile
===================================================================
--- Makefile	(revision 1149)
+++ Makefile	(working copy)
@@ -1136,7 +1136,7 @@
 			utils/openchange-tools.o			\
 			libmapi.$(SHLIBEXT).$(PACKAGE_VERSION)
 	@echo "Linking $@"
-	@$(CC) -o $@ $^ $(LIBS) -lpopt  $(MAGIC_LIBS)
+	@$(CC) -o $@ $^ $(LIBS) -lpopt  $(MAGIC_LIBS) $(GETLINE_LIBS)
 
 
 ###################
Index: libmapi/emsmdb.c
===================================================================
--- libmapi/emsmdb.c	(revision 1149)
+++ libmapi/emsmdb.c	(working copy)
@@ -261,10 +261,6 @@
 		talloc_free(mapi_response->handles);
 	}
 
-	if (mapi_response->mapi_repl) {
-		talloc_free(mapi_response->mapi_repl);
-	}
-
 	return 0;
 }
 
Index: libmapi/libmapi.h
===================================================================
--- libmapi/libmapi.h	(revision 1149)
+++ libmapi/libmapi.h	(working copy)
@@ -70,6 +70,10 @@
 #include <libmapi/socket/netif.h>
 #include <libmapi/proto.h>
 
+#if defined(__FreeBSD__)
+int daylight;
+#endif
+
 extern struct mapi_ctx *global_mapi_ctx;
 
 #endif /* __LIBMAPI_H__ */
Index: libocpf/lex.l
===================================================================
--- libocpf/lex.l	(revision 1149)
+++ libocpf/lex.l	(working copy)
@@ -27,8 +27,6 @@
 #include <stdint.h>
 #include <ctype.h>
 
-typedef __compar_fn_t comparison_fn_t;
-
 #include <libocpf/ocpf_api.h>
 #include <libocpf/ocpf.tab.h>
 #include <libocpf/lex.h>
@@ -322,4 +320,4 @@
 unterminated(const char *type, unsigned start_lineno)
 {
     error_message("unterminated %s, possibly started on line %d\n", type, start_lineno);
-}
\ No newline at end of file
+}
Index: utils/openchangeclient.c
===================================================================
--- utils/openchangeclient.c	(revision 1149)
+++ utils/openchangeclient.c	(working copy)
@@ -30,6 +30,7 @@
 
 #include <sys/stat.h>
 #include <sys/mman.h>
+#include <dirent.h>
 #include <fcntl.h>
 #include <time.h>
 #include <ctype.h>
@@ -339,12 +340,23 @@
 	mem_ctx = talloc_named(NULL, 0, "store_attachment");
 	mapi_object_init(&obj_stream);
 
+#if defined(__FreeBSD__)
+	{
+		DIR *dir;
+
+		if (!(dir = opendir(oclient->store_folder))) {
+#else
 	if ((fd = open(oclient->store_folder, O_DIRECTORY)) == -1) {
+#endif
 		if (mkdir(oclient->store_folder, 0700) == -1) return false;
 	} else {
 		close (fd);
 	}
 
+#if defined(__FreeBSD__)
+			}
+#endif
+
 	path = talloc_asprintf(mem_ctx, "%s/%s", oclient->store_folder, filename);
 	if ((fd = open(path, O_CREAT|O_WRONLY, S_IWUSR|S_IRUSR)) == -1) return false;
 	talloc_free(path);
Index: utils/mapiprofile.c
===================================================================
--- utils/mapiprofile.c	(revision 1149)
+++ utils/mapiprofile.c	(working copy)
@@ -24,8 +24,15 @@
 #include <param.h>
 #include "openchange-tools.h"
 
+
+#if defined (__FreeBSD__)
+#include <sys/signal.h>
+typedef __sighandler_t sighandler_t;
+#else
+#include <signal.h>
+#endif
+
 #include <stdlib.h>
-#include <signal.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 
@@ -112,8 +119,11 @@
 
 	/* catch CTRL-C */
 	g_profname = profname;
+#if defined(__FreeBSD__)
+	(void) signal(SIGINT, (sig_t) signal_delete_profile);
+#else
 	(void) signal(SIGINT, (sighandler_t) signal_delete_profile);
-
+#endif
 	retval = MAPIInitialize(profdb);
 	if (retval != MAPI_E_SUCCESS) {
 		mapi_errstr("MAPIInitialize", GetLastError());

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
devel mailing list
[email protected]
http://mailman.openchange.org/listinfo/devel

Reply via email to