about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2014-02-09 00:32:11 +0000
committerJames Booth <boothj5@gmail.com>2014-02-09 00:32:11 +0000
commitfa89e2aa628c769540a73989759394f2bd7744c1 (patch)
treeefdadc4ad612fde5f75ca167851d02a838d79aeb
parent50afe7366e00767208fc9d17167a768cf924d6cb (diff)
downloadprofani-tty-fa89e2aa628c769540a73989759394f2bd7744c1.tar.gz
Check for libotr version
-rw-r--r--Makefile.am17
-rw-r--r--configure.ac28
-rw-r--r--src/otr3.c (renamed from src/otr.c)2
3 files changed, 40 insertions, 7 deletions
diff --git a/Makefile.am b/Makefile.am
index 1c3388d2..9bea1a50 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -94,8 +94,11 @@ main_source = src/main.c
 git_sources = \
     src/gitversion.c
 
-otr_sources = \
-    src/otr.c src/otr.h
+otr3_sources = \
+    src/otr3.c src/otr.h
+
+otr4_sources = \
+    src/otr4.c src/otr.h
 
 if INCLUDE_GIT_VERSION
 with_git_sources = $(git_sources) $(core_sources)
@@ -105,9 +108,15 @@ with_git_sources = $(core_sources)
 tests_with_git_sources = $(test_sources)
 endif
 
+if BUILD_OTR
 if BUILD_OTR3
-with_otr_sources = $(with_git_sources) $(otr_sources)
-tests_with_otr_sources = $(tests_with_git_sources) $(otr_sources)
+with_otr_sources = $(with_git_sources) $(otr3_sources)
+tests_with_otr_sources = $(tests_with_git_sources) $(otr3_sources)
+endif
+if BUILD_OTR4
+with_otr_sources = $(with_git_sources) $(otr4_sources)
+tests_with_otr_sources = $(tests_with_git_sources) $(otr4_sources)
+endif
 else
 with_otr_sources = $(with_git_sources)
 tests_with_otr_sources = $(tests_with_git_sources)
diff --git a/configure.ac b/configure.ac
index aed16cd8..65560ac9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,14 +131,38 @@ elif test "x$with_xscreensaver" = x; then
         [AC_MSG_NOTICE([libX11 not found, falling back to profanity auto-away])])
 fi
 
+AM_CONDITIONAL([BUILD_OTR], [false])
 AM_CONDITIONAL([BUILD_OTR3], [false])
+AM_CONDITIONAL([BUILD_OTR4], [false])
 if test "x$enable_otr" = xyes; then
     AC_SEARCH_LIBS([otrl_init], [otr],
-        [AM_CONDITIONAL([BUILD_OTR3], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])],
+        [AC_COMPILE_IFELSE(
+            [AC_LANG_PROGRAM([[
+            #include <libotr/version.h>
+            ]],[[
+            #if OTRL_VERSION_MAJOR == 4
+            // OK
+            #else
+            # assume version 3
+            #endif
+            ]])],
+            [AM_CONDITIONAL([BUILD_OTR], [true]) AM_CONDITIONAL([BUILD_OTR4], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])],
+            [AM_CONDITIONAL([BUILD_OTR], [true]) AM_CONDITIONAL([BUILD_OTR3], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])])],
         [AC_MSG_ERROR([libotr is required for otr encryption support])])
 elif test "x$enable_otr" = x; then
     AC_SEARCH_LIBS([otrl_init], [otr],
-        [AM_CONDITIONAL([BUILD_OTR3], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])],
+        [AC_COMPILE_IFELSE(
+            [AC_LANG_PROGRAM([[
+            #include <libotr/version.h>
+            ]],[[
+            #if OTRL_VERSION_MAJOR == 4
+            // OK
+            #else
+            # assume version 3
+            #endif
+            ]])],
+            [AM_CONDITIONAL([BUILD_OTR], [true]) AM_CONDITIONAL([BUILD_OTR4], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])],
+            [AM_CONDITIONAL([BUILD_OTR], [true]) AM_CONDITIONAL([BUILD_OTR3], [true]) AC_DEFINE([HAVE_LIBOTR], [1], [Have libotr])])],
         [AC_MSG_NOTICE([libotr not found, otr entryption support not enabled])])
 fi
 
diff --git a/src/otr.c b/src/otr3.c
index fb8af681..5da2bfab 100644
--- a/src/otr.c
+++ b/src/otr3.c
@@ -1,5 +1,5 @@
 /*
- * otr.c
+ * otr3.c
  *
  * Copyright (C) 2012, 2013 James Booth <boothj5@gmail.com>
  *