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 + ]],[[ + #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 + ]],[[ + #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 similarity index 99% rename from src/otr.c rename to 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 *