****************************************************************************** * * * Compiling a minimal Cyrus-SASL on Windows using MinGW * * * ****************************************************************************** 1. Prerequisites - MinGW (5.1.4) - MSYS (latest build) 2. Preparing the build environment Download cyrus-sasl-2.1.23.tar.gz from CMU. Open an MSYS and extract the tar archive: # tar xpzf cyrus-sasl-2.1.23.tar.gz cd into the source directory: # cd cyrus-sasl-2.1.23 3. Configure the build For dynamic libraries (i.e. *.dlls): # LDFLAGS="-lws2_32 -lgdi32 $LDFLAGS" \ ./configure --prefix=/c/sasl2 --with-configdir=/c/sasl2/etc \ --disable-sample --disable-alwaystrue --disable-checkapop --disable-otp \ --disable-gssapi --disable-gss_mutexes --disable-ntlm \ --enable-login \ --without-dbpath --without-dblib \ --without-bdb-libdir --without-bdb-incdir --without-gdbm \ --without-pam --without-saslauthd \ --without-authdaemond --without-pwcheck \ --without-openssl --without-des --without-opie \ --without-ldap --without-mysql --without-pgsql --without-sqlite \ --without-dmalloc --without-sfio If you want to change the location of the plugin .dlls, you can povide an additional --with-plugindir=DIR For static libraries you have to add --enable-static --disable-shared --disable-staticdlopen 4. Patching 4.1 ./Makefile --- cyrus-sasl-2.1.23/Makefile.orig 2009-08-19 16:25:33 +0000 +++ cyrus-sasl-2.1.23/Makefile 2009-08-19 16:25:56 +0000 @@ -243,7 +243,8 @@ INSTALLOSX = #INSTALLOSX = install-exec-local-osx -SUBDIRS = include sasldb plugins lib utils doc man $(PWC) $(SAM) $(JAV) $(SAD) +#SUBDIRS = include sasldb plugins lib utils doc man $(PWC) $(SAM) $(JAV) $(SAD) +SUBDIRS = include sasldb plugins lib EXTRA_DIST = config cmulocal win32 mac dlcompat-20010505 NTMakefile INSTALL.TXT framedir = /Library/Frameworks/SASL2.framework 4.2. ./config.h --- cyrus-sasl-2.1.23.orig/config.h 2009-08-20 09:35:12 +0000 +++ cyrus-sasl-2.1.23/config.h 2009-08-19 16:41:39 +0000 @@ -46,6 +46,8 @@ #ifndef CONFIG_H #define CONFIG_H +#define WINVER WindowsXP +#define _WIN32_WINNT 0x0501 /* Runtime config file location */ #define CONFIGDIR "/c/sasl2" @@ -92,6 +94,7 @@ /* Do we have a getaddrinfo? */ /* #undef HAVE_GETADDRINFO */ +#define HAVE_GETADDRINFO 1 /* Define to 1 if you have the `getdomainname' function. */ /* #undef HAVE_GETDOMAINNAME */ @@ -101,6 +104,7 @@ /* Do we have a getnameinfo() function? */ /* #undef HAVE_GETNAMEINFO */ +#define HAVE_GETNAMEINFO 1 /* Define to 1 if you have the `getpwnam' function. */ /* #undef HAVE_GETPWNAM */ @@ -210,6 +214,7 @@ /* Do we have a socklen_t? */ /* #undef HAVE_SOCKLEN_T */ +#define HAVE_SOCKLEN_T 1 /* Do we have SQLite support? */ /* #undef HAVE_SQLITE */ @@ -252,6 +257,7 @@ /* Do we have struct sockaddr_stroage? */ /* #undef HAVE_STRUCT_SOCKADDR_STORAGE */ +#define HAVE_STRUCT_SOCKADDR_STORAGE 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_SYSEXITS_H */ @@ -449,16 +455,16 @@ /* Create a struct iovec if we need one */ -#if !defined(_WIN32) && !defined(HAVE_SYS_UIO_H) +//#if !defined(_WIN32) && !defined(HAVE_SYS_UIO_H) /* (win32 is handled in sasl.h) */ -struct iovec { - char *iov_base; - long iov_len; -}; -#else -#include -#include -#endif +//struct iovec { +// char *iov_base; +// long iov_len; +//}; +//#else +//#include +//#include +//#endif /* location of the random number generator */ #ifdef DEV_RANDOM @@ -496,7 +502,7 @@ #include #include -#include +//#include #ifndef WIN32 # include # ifdef HAVE_SYS_PARAM_H @@ -504,10 +510,11 @@ # endif #else /* WIN32 */ # include +# include #endif /* WIN32 */ #include -#include +//#include #ifndef HAVE_SOCKLEN_T typedef unsigned int socklen_t; @@ -577,5 +584,9 @@ #define HIER_DELIMITER '/' #endif +#define SASL_ROOT_KEY "SOFTWARE\\Carnegie Mellon\\Project Cyrus\\SASL Library" +#define SASL_PLUGIN_PATH_ATTR "SearchPath" +#define SASL_CONF_PATH_ATTR "ConfFile" + #endif /* CONFIG_H */ 4.3. lib/getaddrinfo.c --- cyrus-sasl-2.1.23.orig/lib/getaddrinfo.c 2003-03-19 18:25:28 +0000 +++ cyrus-sasl-2.1.23/lib/getaddrinfo.c 2009-08-19 16:52:53 +0000 @@ -59,11 +59,13 @@ */ #include "config.h" +#ifndef HAVE_GETADDRINFO + #ifndef WIN32 #include -# ifndef macintosh +# ifndef macintosh # include -# endif /* macintosh */ +# endif /* macintosh */ #endif /* WIN32 */ #include @@ -252,3 +254,5 @@ #endif return EAI_NODATA; } + +#endif /* HAVE_GETADDRINFO */ 4.4. lib/getnameinfo.c --- cyrus-sasl-2.1.23.orig/lib/getnameinfo.c 2003-02-13 19:55:54 +0000 +++ cyrus-sasl-2.1.23/lib/getnameinfo.c 2009-08-19 16:52:39 +0000 @@ -59,8 +59,10 @@ */ #include "config.h" -#ifndef WIN32 -# include +#ifndef HAVE_GETADDRINFO + +#ifndef WIN32 +# include #endif /* WIN32 */ #include #include @@ -106,3 +108,5 @@ return 0; } + +#endif /* HAVE_GETNAMEINFO */ 4.5. lib/saslutil.c --- cyrus-sasl-2.1.23.orig/lib/saslutil.c 2009-04-28 15:09:15 +0000 +++ cyrus-sasl-2.1.23/lib/saslutil.c 2009-08-18 18:06:28 +0000 @@ -470,7 +470,7 @@ memset(buf, 0, len); } -#ifdef WIN32 +#ifdef WIN32OLD /***************************************************************************** * * MODULE NAME : GETOPT.C 4.6. plugins/plugin_common.h --- cyrus-sasl-2.1.23.orig/plugins/plugin_common.h 2006-01-17 12:18:21 +0000 +++ cyrus-sasl-2.1.23/plugins/plugin_common.h 2009-08-19 16:25:58 +0000 @@ -51,6 +51,7 @@ #ifndef macintosh #ifdef WIN32 # include +# include #else # include # include 4.7. plugins/plugin_common.c --- cyrus-sasl-2.1.23.orig/plugins/plugin_common.c 2009-04-28 15:09:17 +0000 +++ cyrus-sasl-2.1.23/plugins/plugin_common.c 2009-08-19 16:27:19 +0000 @@ -46,6 +46,7 @@ #ifndef macintosh #ifdef WIN32 # include +# include #else # include # include 5. Patches that are only needed for the static build If you want to build static libs, you have to get rid of all dllimport and dllexport declarations. Here is how to do it. 5.1. include/prop.h --- cyrus-sasl-2.1.23.orig/include/prop.h 2003-12-12 00:47:22 +0000 +++ cyrus-sasl-2.1.23/include/prop.h 2009-08-18 18:06:14 +0000 @@ -32,7 +32,7 @@ * exported. */ /* Under Unix, life is simpler: we just need to mark library functions * as extern. (Technically, we don't even have to do that.) */ -#ifdef WIN32 +#ifdef WIN32OLD # ifdef LIBSASL_EXPORTS # define LIBSASL_API __declspec(dllexport) # else /* LIBSASL_EXPORTS */ @@ -44,7 +44,7 @@ /* Same as above, but used during a variable declaration. Only Unix definition * is different, as we can't assign an initial value to an extern variable */ -#ifdef WIN32 +#ifdef WIN32OLD # ifdef LIBSASL_EXPORTS # define LIBSASL_VAR __declspec(dllexport) # else /* LIBSASL_EXPORTS */ 5.2. plugins/plugin_common.h --- cyrus-sasl-2.1.23.orig/plugins/plugin_common.h 2006-01-17 12:18:21 +0000 +++ cyrus-sasl-2.1.23/plugins/plugin_common.h 2009-08-19 16:25:58 +0000 @@ -63,7 +64,7 @@ #include #include -#ifdef WIN32 +#ifdef WIN32OLD #define PLUG_API __declspec(dllexport) #else #define PLUG_API extern 6. Building # make && make install Should now provide you with Cyrus-SASL libs and includes in C:\sasl2