Commit b80ca35c authored by Richard Bayerle's avatar Richard Bayerle
Browse files

Merge branch 'shtrom-macos-build' into dev

Conflicts:
	README.md
	src/lurch.c
parents 2f68c0be e2e2e1ad
[submodule "lib/axc"]
path = lib/axc
url = https://github.com/gkdr/axc
url = ../axc
[submodule "lib/libomemo"]
path = lib/libomemo
url = https://github.com/gkdr/libomemo
url = ../libomemo
### toolchain
#
CC ?= gcc
PKG_CONFIG ?= pkg-config
XML2_CONFIG ?= xml2-config
LIBGCRYPT_CONFIG ?= libgcrypt-config
MKDIR = mkdir
MKDIR_P = mkdir -p
INSTALL = install
......@@ -16,22 +18,38 @@ CMAKE_FLAGS = -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS=-fPIC
### flags
#
PKGCFG_C=$(shell $(PKG_CONFIG) --cflags glib-2.0 purple) \
$(shell $(XML2_CONFIG) --cflags)
PKGCFG_L=$(shell $(PKG_CONFIG) --libs purple glib-2.0 sqlite3 mxml) \
$(shell $(XML2_CONFIG) --libs) \
-L$(shell $(PKG_CONFIG) --variable=plugindir purple) \
$(shell $(LIBGCRYPT_CONFIG) --libs)
GLIB_CFLAGS ?= $(shell $(PKG_CONFIG) --cflags glib-2.0)
GLIB_LDFLAGS ?= $(shell $(PKG_CONFIG) --libs glib-2.0)
LIBPURPLE_CFLAGS=$(shell $(PKG_CONFIG) --cflags purple)
LIBPURPLE_LDFLAGS=$(shell $(PKG_CONFIG) --cflags purple) \
-L$(shell $(PKG_CONFIG) --variable=plugindir purple)
XML2_CFLAGS ?= $(shell $(XML2_CONFIG) --cflags)
XML2_LDFLAGS ?= $(shell $(XML2_CONFIG) --libs)
LIBGCRYPT_LDFLAGS ?= $(shell $(LIBGCRYPT_CONFIG) --libs)
PKGCFG_C=$(GLIB_CFLAGS) \
$(LIBPURPLE_CFLAGS) \
$(XML2_CFLAGS)
PKGCFG_L=$(shell $(PKG_CONFIG) --libs sqlite3 mxml) \
$(GLIB_LDFLAGS) \
$(LIBPURPLE_LDFLAGS) \
$(XML2_LDFLAGS) \
$(LIBGCRYPT_LDFLAGS)
ifneq ("$(wildcard /etc/redhat-release)","")
LJABBER= -lxmpp
LJABBER= -lxmpp
else
LJABBER= -ljabber
endif
HEADERS=-I$(HDIR)/jabber -I$(LOMEMO_SRC) -I$(AXC_SRC) -I$(AX_DIR)/src
CFLAGS += -std=c11 -Wall -g -Wstrict-overflow $(PKGCFG_C) $(HEADERS)
PLUGIN_CPPFLAGS=-DPURPLE_PLUGINS
CPPFLAGS += -D_XOPEN_SOURCE=700 -D_BSD_SOURCE
LDFLAGS += -ldl -lm $(PKGCFG_L) $(LJABBER)
......@@ -59,7 +77,7 @@ AXC_PATH=$(AXC_BUILD)/libaxc-nt.a
AX_DIR=$(AXC_DIR)/lib/libsignal-protocol-c
AX_PATH=$(AX_DIR)/build/src/libsignal-protocol-c.a
FILES=$(LOMEMO_PATH) $(AXC_PATH) $(AX_PATH)
VENDOR_LIBS=$(LOMEMO_PATH) $(AXC_PATH) $(AX_PATH)
### make rules
......@@ -82,13 +100,15 @@ $(AXC_PATH):
$(LOMEMO_PATH):
$(MAKE) -C "$(LOMEMO_DIR)" build/libomemo-conversations.a
$(BDIR)/lurch.so: $(SDIR)/lurch.c $(AX_PATH) $(AXC_PATH) $(LOMEMO_PATH) $(BDIR)
$(CC) -fPIC $(CFLAGS) $(CPPFLAGS) \
-c "$(SDIR)/lurch.c" \
-o "$(BDIR)/lurch.o"
$(CC) -fPIC -shared $(CFLAGS) $(CPPFLAGS) \
"$(BDIR)/lurch.o" $(FILES) \
$(BDIR)/%.o: $(SDIR)/%.c $(BDIR)
$(CC) -fPIC $(CFLAGS) $(CPPFLAGS) $(PLUGIN_CPPFLAGS) -c $(SDIR)/$*.c -o $@
$(BDIR)/lurch.so: $(BDIR)/lurch.o $(VENDOR_LIBS)
$(CC) -fPIC -shared $(CFLAGS) $(CPPFLAGS) $(PLUGIN_CPPFLAGS) \
"$(BDIR)/lurch.o" $(VENDOR_LIBS) \
-o $@ $(LDFLAGS)
$(BDIR)/lurch.a: $(BDIR)/lurch.o $(VENDOR_LIBS)
$(AR) rcs $@ $^
install: $(BDIR)/lurch.so
[ -e "$(DESTDIR)/$(PURPLE_PLUGIN_DIR)" ] || \
......
......@@ -25,7 +25,7 @@ sudo pacman -U *.xz
```
### Compiling (harder)
#### Linux (and MacOS?)
#### Linux
1. First, install the (submodules') dependencies
* `libpurple-dev`
* `libmxml-dev`
......@@ -84,6 +84,28 @@ Which copies the compiled plugin into your local libpurple plugin directory.
The next time you start Pidgin, or another libpurple client, you should be able to activate it in the "Plugins" window.
## MacOS variations
Install dependencies using Homebrew.
```
brew install glib libxml2 libmxml sqlite libgcrypt hg
```
Get a copy of the libpurple soure (from Pidgin), and prepare it so we can use it
during the build.
```
hg clone https://bitbucket.org/pidgin/main pidgin
cd pidgin
hg checkout v2.10.12
./configure $(./configure --help | grep -i -- --disable | awk '{ print $1 }')
```
```
make LIBPURPLE_CFLAGS=-I${PWD}/pidgin/libpurple LIBPURPLE_LDFLAGS=/Applications/Adium.app/Contents/Frameworks/libpurple.framework/libpurple LJABBER=
```
### Windows
Thanks to EionRobb, Windows users can use the dlls he compiled and provides here: https://eion.robbmob.com/lurch/
......
......@@ -77,6 +77,6 @@ unsigned int jabber_send_typing(PurpleConnection *gc, const char *who, PurpleTyp
gboolean jabber_buzz_isenabled(JabberStream *js, const gchar *namespace);
gboolean jabber_custom_smileys_isenabled(JabberStream *js, const const gchar *namespace);
gboolean jabber_custom_smileys_isenabled(JabberStream *js, const gchar *namespace);
#endif /* PURPLE_JABBER_MESSAGE_H_ */
Subproject commit 032fba9c5610d33298cccaf400af9a8813b03f2f
Subproject commit a9ae1c4627823fbef9e7fd6913918b92be43e4f4
Subproject commit 2d210efed1d8b7bb8cb5f7b7c263e19b09d5ba19
Subproject commit 3c8268172829996ec1f1e7b7a12df5c63ceb0ef1
#define PURPLE_PLUGINS
#include <glib.h>
#include <inttypes.h>
......@@ -27,6 +25,8 @@
#include "axc.h"
#include "axc_store.h"
#include "lurch.h"
#ifdef _WIN32
#define strnlen(a, b) (MIN(strlen(a), (b)))
#endif
......@@ -184,6 +184,38 @@ static char * lurch_uname_strip(const char * uname) {
return stripped;
}
/**
* Log wrapper for AXC
*
* @param level an AXC_LOG level
* @param msg the log message
* @param len the length of the message
* @param ctx_p the axc context
*/
static void lurch_axc_log_func(int level, const char * msg, size_t len, void * user_data)
{
switch(level) {
case AXC_LOG_ERROR:
purple_debug_error("lurch", "[AXC ERROR] %s", msg);
break;
case AXC_LOG_WARNING:
purple_debug_warning("lurch", "[AXC WARNING] %s", msg);
break;
case AXC_LOG_NOTICE:
purple_debug_info("lurch", "[AXC NOTICE] %s", msg);
break;
case AXC_LOG_INFO:
purple_debug_info("lurch", "[AXC INFO] %s", msg);
break;
case AXC_LOG_DEBUG:
purple_debug_misc("lurch", "[AXC DEBUG] %s", msg);
break;
default:
purple_debug_misc("lurch", "[AXC %d] %s", level, msg);
break;
}
}
/**
* Creates and initializes the axc context.
*
......@@ -204,6 +236,8 @@ static int lurch_axc_get_init_ctx(char * uname, axc_context ** ctx_pp) {
goto cleanup;
}
axc_context_set_log_func(ctx_p, lurch_axc_log_func);
db_fn = lurch_uname_get_db_fn(uname, LURCH_DB_NAME_AXC);
ret_val = axc_context_set_db_fn(ctx_p, db_fn, strlen(db_fn));
if (ret_val) {
......@@ -2702,11 +2736,11 @@ static PurplePluginInfo info = {
"core-riba-lurch",
"lurch",
"0.6.5",
LURCH_VERSION,
"Implements OMEMO for libpurple.",
"End-to-end encryption using the Signal protocol, adapted for XMPP.",
"Richard Bayerle <riba@firemail.cc>",
LURCH_AUTHOR,
"https://github.com/gkdr/lurch",
lurch_plugin_load,
......
#ifndef __LURCH_H
# define __LURCH_H
# define LURCH_VERSION "0.6.5"
# define LURCH_AUTHOR "Richard Bayerle <riba@firemail.cc>"
#endif /* __LURCH_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment