2006-04-12 Mikael Hallendal <micke@imendio.com>
* autogen.sh:
* configure.ac:
* configure.in:
- Bumped the autoconf and automake requirements.
- Added support to compile with --with-ssl=gnutls|openssl|no. The
default is to build against gnutls and you must explicitely tell that
you don't want SSL support or configure will fail if you don't have
GnuTLS (or building with --with-ssl=openssl).
* loudmouth/Makefile.am:
* loudmouth/lm-ssl-openssl.c:
- Added an OpenSSL backend. Currently doesn't verify certificates.
--- a/ChangeLog Wed Apr 05 15:19:13 2006 +0000
+++ b/ChangeLog Wed Apr 12 14:37:15 2006 +0000
@@ -1,3 +1,17 @@
+2006-04-12 Mikael Hallendal <micke@imendio.com>
+
+ * autogen.sh:
+ * configure.ac:
+ * configure.in:
+ - Bumped the autoconf and automake requirements.
+ - Added support to compile with --with-ssl=gnutls|openssl|no. The
+ default is to build against gnutls and you must explicitely tell that
+ you don't want SSL support or configure will fail if you don't have
+ GnuTLS (or building with --with-ssl=openssl).
+ * loudmouth/Makefile.am:
+ * loudmouth/lm-ssl-openssl.c:
+ - Added an OpenSSL backend. Currently doesn't verify certificates.
+
2006-04-05 Mikael Hallendal <micke@imendio.com>
* configure.in: Define HAVE_SSL which will be set if GnuTLS or OpenSSL
--- a/autogen.sh Wed Apr 05 15:19:13 2006 +0000
+++ b/autogen.sh Wed Apr 12 14:37:15 2006 +0000
@@ -1,78 +1,191 @@
#!/bin/sh
-
-PACKAGE="loudmouth"
-
-have_libtool=false
-have_autoconf=false
-have_automake=false
-need_configure_in=false
+# Run this to generate all the initial makefiles, etc.
-have_gtk_doc=false
-want_gtk_doc=false
+: ${AUTOCONF=autoconf}
+: ${AUTOHEADER=autoheader}
+: ${AUTOMAKE=automake-1.9}
+: ${ACLOCAL=aclocal-1.9}
+: ${LIBTOOLIZE=libtoolize}
+: ${INTLTOOLIZE=intltoolize}
+: ${LIBTOOL=libtool}
+: ${GNOME_DOC_PREPARE=gnome-doc-prepare}
+: ${GTKDOCIZE=gtkdocize}
-if libtool --version < /dev/null > /dev/null 2>&1 ; then
- libtool_version=`libtoolize --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
- have_libtool=true
- case $libtool_version in
- 1.3*)
- need_configure_in=true
- ;;
- esac
-fi
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+ORIGDIR=`pwd`
+cd $srcdir
+PROJECT="loudmouth"
+TEST_TYPE=-f
+FILE=loudmouth/loudmouth.h
+CONFIGURE=configure.ac
+
+DIE=0
-if autoconf --version < /dev/null > /dev/null 2>&1 ; then
- autoconf_version=`autoconf --version | sed 's/^[^0-9]*\([0-9.][0-9.]*\).*/\1/'`
- have_autoconf=true
- case $autoconf_version in
- 2.13)
- need_configure_in=true
- ;;
- esac
-fi
+($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have autoconf installed to compile $PROJECT."
+ echo "Download the appropriate package for your distribution,"
+ echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+ DIE=1
+}
-if $have_libtool ; then : ; else
- echo;
- echo "You must have libtool >= 1.3 installed to compile $PACKAGE";
- echo;
- exit;
-fi
+(grep "^AC_PROG_INTLTOOL" $srcdir/$CONFIGURE >/dev/null) && {
+ ($INTLTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have \`intltoolize' installed to compile $PROJECT."
+ echo "Get ftp://ftp.gnome.org/pub/GNOME/stable/sources/intltool/intltool-0.22.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
-if grep "^GTK_DOC_CHECK" ./configure.in; then
- want_gtk_doc=true
-fi
+(grep "^GNOME_DOC_INIT" $srcdir/$CONFIGURE >/dev/null) && {
+ ($GNOME_DOC_PREPARE --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have \`gnome-doc-prepare' installed to compile $PROJECT."
+ #echo "Get ftp://ftp.gnome.org/pub/GNOME/stable/sources/intltool/intltool-0.22.tar.gz"
+ #echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
-if $want_gtk_doc; then
- (gtkdocize --version) < /dev/null > /dev/null 2>&1 || {
+if grep "^GTK_DOC_CHECK" $srcdir/$CONFIGURE; then
+ ($GTKDOCIZE --version) < /dev/null > /dev/null 2>&1 || {
echo;
echo "You need gtk-doc to build $PACKAGE";
echo;
}
fi
-(automake --version) < /dev/null > /dev/null 2>&1 || {
- echo;
- echo "You must have automake installed to compile $PACKAGE";
- echo;
- exit;
+($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have automake installed to compile $PROJECT."
+ echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.9.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+}
+
+(grep "^AM_PROG_LIBTOOL" $CONFIGURE >/dev/null) && {
+ ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "**Error**: You must have \`libtool' installed to compile $PROJECT."
+ echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.4.tar.gz"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ }
+}
+
+if grep "^AM_[A-Z0-9_]\{1,\}_GETTEXT" "$CONFIGURE" >/dev/null; then
+ if grep "sed.*POTFILES" "$CONFIGURE" >/dev/null; then
+ GETTEXTIZE=""
+ else
+ if grep "^AM_GLIB_GNU_GETTEXT" "$CONFIGURE" >/dev/null; then
+ GETTEXTIZE="glib-gettextize"
+ GETTEXTIZE_URL="ftp://ftp.gtk.org/pub/gtk/v2.0/glib-2.0.0.tar.gz"
+ else
+ GETTEXTIZE="gettextize"
+ GETTEXTIZE_URL="ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
+ fi
+
+ $GETTEXTIZE --version < /dev/null > /dev/null 2>&1
+ if test $? -ne 0; then
+ echo
+ echo "**Error**: You must have \`$GETTEXTIZE' installed to compile $PKG_NAME."
+ echo "Get $GETTEXTIZE_URL"
+ echo "(or a newer version if it is available)"
+ DIE=1
+ fi
+ fi
+fi
+
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+test $TEST_TYPE $FILE || {
+ echo "You must run this script in the top-level $PROJECT directory"
+ exit 1
}
-echo "Generating configuration files for $PACKAGE, please wait...."
-echo;
+#if test -z "$*"; then
+# echo "I am going to run ./configure with no arguments - if you wish "
+# echo "to pass any to it, please specify them on the $0 command line."
+#fi
+
+case $CC in
+*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
+esac
-if $need_configure_in ; then
- if test ! -f configure.in ; then
- echo "Creating symlink from configure.in to configure.ac..."
- echo
- ln -s configure.ac configure.in
- fi
+for coin in .
+do
+ dr=`dirname $coin`
+ if test -f $dr/NO-AUTO-GEN; then
+ echo skipping $dr -- flagged as no auto-gen
+ else
+ echo processing $dr
+ macrodirs= #`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
+ ( cd $dr
+ aclocalinclude="$ACLOCAL_FLAGS"
+ for k in $macrodirs; do
+ if test -d $k; then
+ aclocalinclude="$aclocalinclude -I $k"
+ ##else
+ ## echo "**Warning**: No such directory \`$k'. Ignored."
+ fi
+ done
+ if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE >/dev/null; then
+ if grep "sed.*POTFILES" $CONFIGURE >/dev/null; then
+ : do nothing -- we still have an old unmodified $CONFIGURE
+ else
+ echo "Creating $dr/aclocal.m4 ..."
+ test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
+ echo "Running glib-gettextize... Ignore non-fatal messages."
+ echo "no" | glib-gettextize --force --copy
+ echo "Making $dr/aclocal.m4 writable ..."
+ test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
+ fi
+ fi
+ if grep "^AC_PROG_INTLTOOL" $CONFIGURE >/dev/null; then
+ echo "Running intltoolize..."
+ intltoolize --copy --force --automake
+ fi
+ if grep "^GNOME_DOC_INIT" $CONFIGURE >/dev/null; then
+ echo "Running $GNOME_DOC_PREPARE..."
+ $GNOME_DOC_PREPARE --force --copy || exit 1
+ fi
+ if grep "^AM_PROG_LIBTOOL" $CONFIGURE >/dev/null; then
+ echo "Running $LIBTOOLIZE..."
+ $LIBTOOLIZE --force --copy
+ fi
+ echo "Running $ACLOCAL $aclocalinclude ..."
+ $ACLOCAL $aclocalinclude
+ if grep "^GTK_DOC_CHECK" $CONFIGURE > /dev/null; then
+ echo "Running $GTKDOCIZE..."
+ $GTKDOCIZE
+ fi
+ if grep "^AM_CONFIG_HEADER" $CONFIGURE >/dev/null; then
+ echo "Running $AUTOHEADER..."
+ $AUTOHEADER
+ fi
+ echo "Running $AUTOMAKE --gnu $am_opt ..."
+ $AUTOMAKE --add-missing --gnu $am_opt
+ echo "Running $AUTOCONF ..."
+ $AUTOCONF
+ )
+ fi
+done
+
+conf_flags="--enable-maintainer-mode"
+
+cd "$ORIGDIR"
+
+if test x$NOCONFIGURE = x; then
+ echo Running $srcdir/configure $conf_flags "$@" ...
+ $srcdir/configure $conf_flags "$@" \
+ && echo Now type \`make\' to compile $PROJECT || exit 1
+else
+ echo Skipping configure process.
fi
-
-aclocal $ACLOCAL_FLAGS
-libtoolize --force
-gtkdocize || exit 1
-autoheader
-automake --add-missing
-autoconf
-
-./configure $@ --enable-maintainer-mode --enable-compile-warnings
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/configure.ac Wed Apr 12 14:37:15 2006 +0000
@@ -0,0 +1,251 @@
+AC_INIT(Loudmouth, 1.0.3, loudmouth)
+AC_PREREQ(2.59)
+AC_COPYRIGHT([Copyright (C) 2003-2006 Imendio AB])
+
+AC_CONFIG_SRCDIR(loudmouth/loudmouth.h)
+AM_CONFIG_HEADER(config.h)
+AM_INIT_AUTOMAKE(1.9 dist-bzip2 no-define)
+
+AM_MAINTAINER_MODE
+
+AC_PROG_CC
+AC_ISC_POSIX
+AC_HEADER_STDC
+AM_PROG_LIBTOOL
+
+AM_PATH_GLIB_2_0
+
+IDT_COMPILE_WARNINGS
+
+changequote(,)dnl
+if test "x$GCC" = "xyes"; then
+ case " $CFLAGS " in
+ *[\ \ ]-Wall[\ \ ]*) ;;
+ *) CFLAGS="$CFLAGS -Wall" ;;
+ esac
+fi
+changequote([,])dnl
+
+AC_SUBST(CFLAGS)
+AC_SUBST(LDFLAGS)
+
+GLIB2_REQUIRED=2.4.0
+GNUTLS_REQUIRED=1.0.0
+LIBTASN1_REQUIRED=0.2.6
+
+AC_SUBST(GLIB2_REQUIRED)
+AC_SUBST(GNUTLS_REQUIRED)
+AC_SUBST(LIBTASN1_REQUIRED)
+
+LM_CHECK_TIMEZONE
+
+PKG_CHECK_MODULES(LOUDMOUTH, glib-2.0 >= $GLIB2_REQUIRED)
+
+# Check Unit test framework (defined in acinclude.m4)
+IDT_PATH_CHECK(0.9.2, have_check=yes, have_check=no)
+
+AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)
+
+dnl +--------------------+
+dnl | Check for gtk-doc. |-------------------------------
+dnl +--------------------+
+
+AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ])
+
+if test "x$with_html_dir" = "x" ; then
+ HTML_DIR='${datadir}/gtk-doc/html'
+else
+ HTML_DIR=$with_html_dir
+fi
+
+AC_SUBST(HTML_DIR)
+
+gtk_doc_min_version=1.0
+AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version])
+if pkg-config --atleast-version=$gtk_doc_min_version gtk-doc; then
+ AC_MSG_RESULT(yes)
+ GTKDOC=true
+else
+ AC_MSG_RESULT(no)
+ GTKDOC=false
+fi
+
+dnl Let people disable the gtk-doc stuff.
+AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc Use gtk-doc to build documentation [default=no]], enable_gtk_doc="$enableval", enable_gtk_doc=no)
+
+if test x$enable_gtk_doc = xauto ; then
+ if test x$GTKDOC = xtrue ; then
+ enable_gtk_doc=yes
+ else
+ enable_gtk_doc=no
+ fi
+fi
+
+AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
+
+dnl define a MAINT-like variable REBUILD which is set if Perl
+dnl and awk are found, so autogenerated sources can be rebuilt
+AC_ARG_ENABLE(rebuilds, [ --disable-rebuilds disable all source autogeneration rules],,enable_rebuilds=yes)
+REBUILD=\#
+if test "x$enable_rebuilds" = "xyes" && \
+ test -n "$PERL" && \
+ $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
+ test -n "$AWK" ; then
+ REBUILD=
+fi
+AC_SUBST(REBUILD)
+
+
+dnl +--------------------------------------------------------+
+dnl | Checking for libnsl and libsocket need on some systems |-
+dnl +--------------------------------------------------------+
+AC_CHECK_LIB(nsl,gethostbyname)
+AC_CHECK_LIB(socket,socket)
+
+dnl +--------------------------------------------------------+
+dnl | Checking for SSL support |-
+dnl +--------------------------------------------------------+
+AC_ARG_WITH(ssl,
+ AS_HELP_STRING([--with-ssl@<:@=gnutls|openssl|no@:>@],
+ [Which SSL implementation to use, default is gnutls]),
+ ac_ssl=$withval,
+ ac_ssl=gnutls)
+
+AC_ARG_WITH(openssl-includes,
+ AC_HELP_STRING([--with-openssl-includes=DIR],[OpenSSL includes]),
+ [ use_openssl=yes CPPFLAGS="$CPPFLAGS -I$withval" ]
+ )
+
+AC_ARG_WITH(openssl-libs,
+ AC_HELP_STRING([--with-openssl-libs=DIR],[OpenSSL libraries]),
+ [ use_openssl=yes LDFLAGS="$LDFLAGS -L$withval" ]
+ )
+
+enable_ssl=no
+if test x$ac_ssl = xgnutls; then
+ dnl Look for GnuTLS
+ AM_PATH_LM_LIBGNUTLS($GNUTLS_REQUIRED, have_libgnutls=yes, have_libgnutls=no)
+ if test x$have_libgnutls = xyes; then
+ CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
+ LIBS="$LIBS $LIBGNUTLS_LIBS"
+ AC_DEFINE(HAVE_GNUTLS, 1, [whether to use GnuTSL support.])
+ enable_ssl=GnuTLS
+ else
+ AC_MSG_ERROR([GnuTLS was not found, use --with-ssl=no|openssl to build without SSL support or with OpenSSL])
+ fi
+elif test x$ac_ssl = xopenssl; then
+ dnl Look for OpenSSL
+ AC_CHECK_HEADERS([openssl/ssl.h])
+ OLDLIBS="$LIBS"
+ AC_CHECK_LIB(crypto, BIO_f_base64, [
+ AC_CHECK_LIB(ssl, SSL_new, [ SSL_LIB="-lssl -lcrypto"
+ AC_DEFINE(HAVE_OPENSSL, [], [Have OpenSSL]) ], [ have_openssl=no ], [ -lcrypto ])
+ ], [ have_openssl=no ], [])
+
+ if test x$have_openssl = xno; then
+ AC_MSG_ERROR([OpenSSL was not found, use --with-ssl=no|gnutls to build without SSL support or with GnuTLS])
+ else
+ LIBS="$OLDLIBS $SSL_LIB"
+ enable_ssl=OpenSSL
+ fi
+else
+ echo "Disabling SSL support"
+fi
+
+if test x$enable_ssl != xno; then
+ AC_DEFINE(HAVE_SSL, 1, [whether to use SSL support.])
+else
+ if test x$ac_ssl != xno; then
+ AC_MSG_ERROR([No SSL implementation was found, if you do not want to build with SSL use --with-ssl=no])
+ fi
+fi
+
+AM_CONDITIONAL(USE_OPENSSL, test x$enable_ssl = xOpenSSL)
+AM_CONDITIONAL(USE_GNUTLS, test x$enable_ssl = xGnuTLS)
+
+dnl +-------------+
+dnl | Build Flags |--------------------------------------------
+dnl +-------------+
+DOC_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS $WARN_CFLAGS"
+AC_SUBST(DOC_CFLAGS)
+AC_SUBST(CFLAGS)
+AC_SUBST(CPPFLAGS)
+AC_SUBST(LDFLAGS)
+dnl -----------------------------------------------------------
+
+dnl +--------------+
+dnl | Debug output |-------------------------------------------
+dnl +--------------+
+
+AC_ARG_ENABLE(debug,
+ [ --enable-debug Enable debug output [default=yes]],
+ enable_debug="$enableval", enable_debug=yes, enable_debug=no)
+
+if test x$enable_debug = xno ; then
+ echo "Debugging disabled"
+ LOUDMOUTH_CFLAGS="$LOUDMOUTH_CFLAGS -DLM_NO_DEBUG"
+else
+ echo "Debugging enabled"
+fi
+
+AC_SUBST(LOUDMOUTH_CFLAGS)
+AC_SUBST(LOUDMOUTH_LIBS)
+
+dnl Gtk doc
+GTK_DOC_CHECK(1.0)
+
+dnl +--------------------------------------+
+dnl | Check if we shoudl build C# bindings |-------------------
+dnl +--------------------------------------+
+
+dnl --------------
+dnl | mono setup |--------------------------------------------
+dnl --------------
+dnl AC_ARG_ENABLE(mono, [ --enable-mono build mono bindings [default=auto]], enable_mono="$enableval", enable_mono=auto)
+
+dnl if test "x$enable_mono" != "xno"; then
+dnl PKG_CHECK_MODULES(,gtk-sharp,have_mono=yes,have_mono=no)
+
+dnl if test "x$have_mono" = "xyes"; then
+dnl AC_PATH_PROG(MCS, mcs, no)
+dnl AC_PATH_PROG(MONO, mono, no)
+dnl fi
+dnl else
+dnl have_mono=no
+dnl fi
+
+dnl if test "x$enable_mono" = "xyes"; then
+dnl AC_MSG_CHECKING(for mono environment)
+dnl if test "x$have_mono" = "xno"; then
+dnl AC_MSG_ERROR([not found])
+dnl fi
+dnl fi
+
+dnl AM_CONDITIONAL(HAVE_MONO, test x$have_mono = xyes)
+
+AC_OUTPUT([
+Makefile
+docs/Makefile
+docs/reference/Makefile
+loudmouth/Makefile
+examples/Makefile
+tests/Makefile
+loudmouth-1.0.pc
+loudmouth.spec])
+
+dnl ==========================================================================
+echo "
+
+ Loudmouth $VERSION from Imendio AB
+ =====================================
+
+ prefix: ${prefix}
+ compiler: ${CC}
+ Enable SSL ${enable_ssl}
+ Enable Debug: ${enable_debug}
+ Enable Unit Tests: ${have_check}
+
+ Now type 'make' to build Loudmouth
+"
+
--- a/configure.in Wed Apr 05 15:19:13 2006 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,215 +0,0 @@
-AC_INIT(loudmouth/lm-message.h)
-
-AM_CONFIG_HEADER(config.h)
-
-AM_INIT_AUTOMAKE(loudmouth, 1.0.3)
-
-AM_MAINTAINER_MODE
-
-AC_PROG_CC
-AC_ISC_POSIX
-AC_HEADER_STDC
-AM_PROG_LIBTOOL
-
-AM_PATH_GLIB_2_0
-
-IDT_COMPILE_WARNINGS
-
-changequote(,)dnl
-if test "x$GCC" = "xyes"; then
- case " $CFLAGS " in
- *[\ \ ]-Wall[\ \ ]*) ;;
- *) CFLAGS="$CFLAGS -Wall" ;;
- esac
-fi
-changequote([,])dnl
-
-AC_SUBST(CFLAGS)
-AC_SUBST(LDFLAGS)
-
-GLIB2_REQUIRED=2.4.0
-GNUTLS_REQUIRED=1.0.0
-LIBTASN1_REQUIRED=0.2.6
-
-AC_SUBST(GLIB2_REQUIRED)
-AC_SUBST(GNUTLS_REQUIRED)
-AC_SUBST(LIBTASN1_REQUIRED)
-
-LM_CHECK_TIMEZONE
-
-PKG_CHECK_MODULES(LOUDMOUTH, glib-2.0 >= $GLIB2_REQUIRED)
-
-# Check Unit test framework (defined in acinclude.m4)
-IDT_PATH_CHECK(0.9.2, have_check=yes, have_check=no)
-
-AM_CONDITIONAL(HAVE_CHECK, test x$have_check = xyes)
-
-dnl +--------------------+
-dnl | Check for gtk-doc. |-------------------------------
-dnl +--------------------+
-
-AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ])
-
-if test "x$with_html_dir" = "x" ; then
- HTML_DIR='${datadir}/gtk-doc/html'
-else
- HTML_DIR=$with_html_dir
-fi
-
-AC_SUBST(HTML_DIR)
-
-gtk_doc_min_version=1.0
-AC_MSG_CHECKING([gtk-doc version >= $gtk_doc_min_version])
-if pkg-config --atleast-version=$gtk_doc_min_version gtk-doc; then
- AC_MSG_RESULT(yes)
- GTKDOC=true
-else
- AC_MSG_RESULT(no)
- GTKDOC=false
-fi
-
-dnl Let people disable the gtk-doc stuff.
-AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc Use gtk-doc to build documentation [default=no]], enable_gtk_doc="$enableval", enable_gtk_doc=no)
-
-if test x$enable_gtk_doc = xauto ; then
- if test x$GTKDOC = xtrue ; then
- enable_gtk_doc=yes
- else
- enable_gtk_doc=no
- fi
-fi
-
-AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
-
-dnl define a MAINT-like variable REBUILD which is set if Perl
-dnl and awk are found, so autogenerated sources can be rebuilt
-AC_ARG_ENABLE(rebuilds, [ --disable-rebuilds disable all source autogeneration rules],,enable_rebuilds=yes)
-REBUILD=\#
-if test "x$enable_rebuilds" = "xyes" && \
- test -n "$PERL" && \
- $PERL -e 'exit !($] >= 5.002)' > /dev/null 2>&1 && \
- test -n "$AWK" ; then
- REBUILD=
-fi
-AC_SUBST(REBUILD)
-
-
-dnl +--------------------------------------------------------+
-dnl | Checking for libnsl and libsocket need on some systems |-
-dnl +--------------------------------------------------------+
-AC_CHECK_LIB(nsl,gethostbyname)
-AC_CHECK_LIB(socket,socket)
-
-dnl +--------------------------------------------------------+
-dnl | Checking for SSL (through GnuTLS) support |
-dnl +--------------------------------------------------------+
-AC_ARG_WITH(ssl, [ --with-ssl=no/yes define whether to look for SSL, default=yes],
- ac_ssl=$withval,
- ac_ssl=yes
- )
-
-enable_ssl=no
-if test x$ac_ssl != xno; then
- AM_PATH_LM_LIBGNUTLS($GNUTLS_REQUIRED, have_libgnutls=yes, have_libgnutls=no)
- if test x$have_libgnutls = xyes; then
- CFLAGS="$CFLAGS $LIBGNUTLS_CFLAGS"
- LIBS="$LIBS $LIBGNUTLS_LIBS"
- AC_DEFINE(HAVE_GNUTLS, 1, [whether to use GnuTSL support.])
- enable_ssl=yes
- else
- echo "Couldn't find GnuTLS, disabling SSL support"
- fi
-else
- echo "Disabling SSL support"
-fi
-
-if test x$enable_ssl = xyes; then
- AC_DEFINE(HAVE_SSL, 1, [whether to use SSL support.])
-fi
-
-dnl +-------------+
-dnl | Build Flags |--------------------------------------------
-dnl +-------------+
-DOC_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS $WARN_CFLAGS"
-AC_SUBST(DOC_CFLAGS)
-AC_SUBST(CFLAGS)
-AC_SUBST(CPPFLAGS)
-AC_SUBST(LDFLAGS)
-dnl -----------------------------------------------------------
-
-dnl +--------------+
-dnl | Debug output |-------------------------------------------
-dnl +--------------+
-
-AC_ARG_ENABLE(debug,
- [ --enable-debug Enable debug output [default=yes]],
- enable_debug="$enableval", enable_debug=yes, enable_debug=no)
-
-if test x$enable_debug = xno ; then
- echo "Debugging disabled"
- LOUDMOUTH_CFLAGS="$LOUDMOUTH_CFLAGS -DLM_NO_DEBUG"
-else
- echo "Debugging enabled"
-fi
-
-AC_SUBST(LOUDMOUTH_CFLAGS)
-AC_SUBST(LOUDMOUTH_LIBS)
-
-dnl Gtk doc
-GTK_DOC_CHECK(1.0)
-
-dnl +--------------------------------------+
-dnl | Check if we shoudl build C# bindings |-------------------
-dnl +--------------------------------------+
-
-dnl --------------
-dnl | mono setup |--------------------------------------------
-dnl --------------
-dnl AC_ARG_ENABLE(mono, [ --enable-mono build mono bindings [default=auto]], enable_mono="$enableval", enable_mono=auto)
-
-dnl if test "x$enable_mono" != "xno"; then
-dnl PKG_CHECK_MODULES(,gtk-sharp,have_mono=yes,have_mono=no)
-
-dnl if test "x$have_mono" = "xyes"; then
-dnl AC_PATH_PROG(MCS, mcs, no)
-dnl AC_PATH_PROG(MONO, mono, no)
-dnl fi
-dnl else
-dnl have_mono=no
-dnl fi
-
-dnl if test "x$enable_mono" = "xyes"; then
-dnl AC_MSG_CHECKING(for mono environment)
-dnl if test "x$have_mono" = "xno"; then
-dnl AC_MSG_ERROR([not found])
-dnl fi
-dnl fi
-
-dnl AM_CONDITIONAL(HAVE_MONO, test x$have_mono = xyes)
-
-AC_OUTPUT([
-Makefile
-docs/Makefile
-docs/reference/Makefile
-loudmouth/Makefile
-examples/Makefile
-tests/Makefile
-loudmouth-1.0.pc
-loudmouth.spec])
-
-dnl ==========================================================================
-echo "
-
- Loudmouth $VERSION from Imendio AB
- =====================================
-
- prefix: ${prefix}
- compiler: ${CC}
- Enable SSL ${enable_ssl}
- Enable Debug: ${enable_debug}
- Enable Unit Tests: ${have_check}
-
- Now type 'make' to build Loudmouth
-"
-
--- a/loudmouth/Makefile.am Wed Apr 05 15:19:13 2006 +0000
+++ b/loudmouth/Makefile.am Wed Apr 12 14:37:15 2006 +0000
@@ -1,6 +1,6 @@
NULL=
-INCLUDES = \
+AM_CPPFLAGS = \
-I. \
-I$(top_srcdir) \
$(LOUDMOUTH_CFLAGS) \
@@ -10,6 +10,16 @@
lib_LTLIBRARIES = libloudmouth-1.la
+if USE_GNUTLS
+ssl_sources = \
+ lm-ssl-gnutls.c
+endif
+
+if USE_OPENSSL
+ssl_sources = \
+ lm-ssl-openssl.c
+endif
+
libloudmouth_1_la_SOURCES = \
lm-connection.c \
lm-debug.c \
@@ -24,10 +34,10 @@
lm-sha.c \
lm-sha.h \
lm-ssl-generic.c \
- lm-ssl-gnutls.c \
lm-ssl-base.c \
lm-ssl-base.h \
lm-ssl-internals.h \
+ $(ssl_sources) \
lm-utils.c \
lm-proxy.c \
$(NULL)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/loudmouth/lm-ssl-openssl.c Wed Apr 12 14:37:15 2006 +0000
@@ -0,0 +1,207 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006 Imendio AB
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include <string.h>
+#include <glib.h>
+
+#include "lm-error.h"
+#include "lm-ssl-base.h"
+#include "lm-ssl-internals.h"
+
+#ifdef HAVE_OPENSSL
+
+#include <openssl/ssl.h>
+
+struct _LmSSL {
+ LmSSLBase base;
+
+ SSL_CTX *ctx;
+
+ SSL *session;
+/* gnutls_certificate_client_credentials gnutls_xcred;*/
+};
+
+static gboolean ssl_verify_certificate (LmSSL *ssl,
+ const gchar *server);
+static GIOStatus ssl_io_status_from_return (LmSSL *ssl,
+ gint error);
+
+static gboolean
+ssl_verify_certificate (LmSSL *ssl, const gchar *server)
+{
+ LmSSLBase *base;
+
+ base = LM_SSL_BASE (ssl);
+
+ /* FIXME: Implement */
+
+ return TRUE;
+}
+
+static GIOStatus
+ssl_io_status_from_return (LmSSL *ssl, gint ret)
+{
+ gint error;
+ GIOStatus status;
+
+ if (ret > 0) {
+ return G_IO_STATUS_NORMAL;
+ }
+
+ error = SSL_get_error (ssl->session, ret);
+
+ if (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE) {
+ status = G_IO_STATUS_AGAIN;
+ }
+ else if (error == SSL_ERROR_ZERO_RETURN) {
+ status = G_IO_STATUS_EOF;
+ } else {
+ status = G_IO_STATUS_ERROR;
+ }
+
+ return status;
+}
+
+/* From lm-ssl-protected.h */
+
+LmSSL *
+_lm_ssl_new (const gchar *expected_fingerprint,
+ LmSSLFunction ssl_function,
+ gpointer user_data,
+ GDestroyNotify notify)
+{
+ LmSSL *ssl;
+
+ ssl = g_new0 (LmSSL, 1);
+
+ _lm_ssl_base_init ((LmSSLBase *) ssl,
+ expected_fingerprint,
+ ssl_function, user_data, notify);
+
+ return ssl;
+}
+
+void
+_lm_ssl_initialize (LmSSL *ssl)
+{
+ static gboolean initialized = FALSE;
+ SSL_METHOD *meth;
+
+ if (!initialized) {
+ SSL_library_init ();
+
+ /* FIXME: Is this needed when we are not in debug? */
+ SSL_load_error_strings ();
+ initialized = TRUE;
+ }
+
+ meth = SSLv23_method ();
+ ssl->ctx = SSL_CTX_new (meth);
+
+}
+
+gboolean
+_lm_ssl_begin (LmSSL *ssl, gint fd, const gchar *server, GError **error)
+{
+ BIO *sbio;
+
+ ssl->session = SSL_new (ssl->ctx);
+ sbio = BIO_new_socket (fd, BIO_NOCLOSE);
+ SSL_set_bio (ssl->session, sbio, sbio);
+
+ if (SSL_connect (ssl->session) <= 0) {
+ g_set_error (error,
+ LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ "*** OpenSSL handshake failed");
+
+ return FALSE; /* Error */
+ }
+
+ if (!ssl_verify_certificate (ssl, server)) {
+ g_set_error (error,
+ LM_ERROR, LM_ERROR_CONNECTION_OPEN,
+ "*** OpenSSL certificate verification failed");
+ return FALSE;
+ }
+
+ /* FIXME: Check creds */
+ return TRUE;
+}
+
+GIOStatus
+_lm_ssl_read (LmSSL *ssl, gchar *buf, gint len, gsize *bytes_read)
+{
+ GIOStatus status;
+ gint b_read;
+
+ *bytes_read = 0;
+ b_read = SSL_read (ssl->session, buf, len);
+
+ status = ssl_io_status_from_return (ssl, b_read);
+
+ if (status == G_IO_STATUS_NORMAL) {
+ *bytes_read = b_read;
+ }
+
+ return status;
+}
+
+gint
+_lm_ssl_send (LmSSL *ssl, const gchar *str, gint len)
+{
+ GIOStatus status;
+ gint bytes_written;
+
+
+ bytes_written = SSL_write (ssl->session, str, len);
+ status = ssl_io_status_from_return (ssl, bytes_written);
+
+ while (bytes_written < 0) {
+ if (status != G_IO_STATUS_AGAIN) {
+ return -1;
+ }
+
+ bytes_written = SSL_write (ssl->session, str, len);
+ status = ssl_io_status_from_return (ssl, bytes_written);
+ }
+
+ return bytes_written;
+}
+
+void
+_lm_ssl_close (LmSSL *ssl)
+{
+ SSL_free (ssl->session);
+ ssl->session = NULL;
+}
+
+void
+_lm_ssl_free (LmSSL *ssl)
+{
+ _lm_ssl_base_free_fields (LM_SSL_BASE (ssl));
+
+ SSL_CTX_free (ssl->ctx);
+
+ g_free (ssl);
+}
+
+#endif /* HAVE_GNUTLS */