Commit c5625f6d7abd4afd2795f94c3777c6721ec2098a

Authored by Matti Virkkunen
1 parent 5a9b65f4

Add makefile option to build and statically link Thrift.

.gitignore
1 1 thrift_line
  2 +thrift_static
2 3 *.o
3 4 libline.so
4 5 .depend
... ...
README.md
... ... @@ -3,8 +3,6 @@ purple-line
3 3  
4 4 libpurple (Pidgin, Finch) protocol plugin for [LINE](http://line.me/).
5 5  
6   -**Warning: Unfinished software! This plugin is still under development and many things are still unstable or unimplemented.**
7   -
8 6 ![Screenshot](http://i.imgur.com/By1yLXB.png)
9 7  
10 8 Where are the binaries and packages?
... ... @@ -19,21 +17,46 @@ How to install
19 17  
20 18 Make sure you have the required prerequisites:
21 19  
22   -* libpurple - probably available from your package manager
23   -* Apache Thrift compiler and C++ library - v0.9.1 should be stable. The Git version and OS packages
24   - are sometimes a bit iffy. Compiling by hand is your best bet.
  20 +* libpurple - Library that provides the core functionality of Pidgin and other compatible clients.
  21 + Probably available from your package manager
  22 +* thrift / libthrift - Apache Thrift compiler and C++ library. May be available from your package
  23 + manager.
25 24  
26 25 To install the plugin system-wide, run:
27 26  
28 27 make
29 28 sudo make install
30 29  
31   -You can also install the plugin for your user only by running:
  30 +The makefile supports a flag THRIFT_STATIC=true which causes it to download and build a version of
  31 +Thrift and statically link it. This should be convenient for people using one of the numerous
  32 +distributions that do not package Thrift.
  33 +
  34 +You can also install the plugin for your user only by replacing `install` with `user-install`.
  35 +
  36 +How to install (Arch Linux)
  37 +---------------------------
  38 +
  39 +Arch Linux packages all the required dependencies, so you can install the plugin by simply typing:
32 40  
  41 + sudo pacman -S thrift libpurple
33 42 make
34   - make user-install
  43 + sudo make install
  44 +
  45 +How to install (Ubuntu)
  46 +-----------------------
  47 +
  48 +Ubuntu does not currently package Thrift so it must be obtained elsewhere, or statically linked. To
  49 +build the plugin with a statically linked Thrift library, type:
  50 +
  51 + sudo apt-get install \
  52 + libpurple-dev \
  53 + libboost-dev libboost-test-dev \
  54 + libboost-program-options-dev libboost-system-dev libboost-filesystem-dev libevent-dev \
  55 + automake libtool flex bison pkg-config g++ libssl-dev
  56 + make THRIFT_STATIC=true
  57 + sudo make install THRIFT_STATIC=true
35 58  
36   -Builds are only tested on Arch Linux and a recent Ubuntu for now.
  59 +The installed packages include all the suggested dependencies from Thrift's website.
37 60  
38 61 Implemented
39 62 -----------
... ...
libpurple/Makefile
  1 +THRIFT_STATIC_DIR = thrift_static
  2 +
  3 +ifdef THRIFT_STATIC
  4 + THRIFT = $(THRIFT_STATIC_DIR)/compiler/cpp/thrift
  5 + THRIFT_CXXFLAGS = -I$(THRIFT_STATIC_DIR)/lib/cpp/src
  6 + THRIFT_LIBS = -L$(THRIFT_STATIC_DIR)/lib/cpp/.libs -Wl,-Bstatic -lthrift -Wl,-Bdynamic
  7 + THRIFT_DEP = $(THRIFT)
  8 +else
  9 + THRIFT = thrift
  10 + THRIFT_CXXFLAGS = `pkg-config --cflags thrift`
  11 + THRIFT_LIBS = `pkg-config --libs thrift`
  12 +endif
  13 +
1 14 CXX = g++
2 15 CXXFLAGS = -g -Wall -shared -fPIC \
3 16 -DHAVE_INTTYPES_H -DHAVE_CONFIG_H -DPURPLE_PLUGINS \
4   - `pkg-config --cflags purple thrift`
5   -THRIFT = thrift
  17 + `pkg-config --cflags purple` $(THRIFT_CXXFLAGS)
6 18  
7   -LIBS = `pkg-config --libs purple thrift`
  19 +LIBS = `pkg-config --libs purple` $(THRIFT_LIBS)
8 20  
9 21 PURPLE_PLUGIN_DIR:=$(shell pkg-config --variable=plugindir purple)
10 22 PURPLE_DATA_ROOT_DIR:=$(shell pkg-config --variable=datarootdir purple)
... ... @@ -24,21 +36,38 @@ OBJS = $(SRCS:.cpp=.o)
24 36  
25 37 all: $(MAIN)
26 38  
27   -$(MAIN): $(OBJS)
  39 +$(MAIN): $(OBJS) $(THRIFT_DEP)
28 40 $(CXX) $(CXXFLAGS) -Wl,-z,defs -o $(MAIN) $(OBJS) $(LIBS)
  41 + strip $(MAIN)
29 42  
30 43 .cpp.o:
31 44 $(CXX) $(CXXFLAGS) -std=c++11 -c $< -o $@
32 45  
33   -thrift_line: line.thrift
  46 +thrift_line: line.thrift $(THRIFT_DEP)
34 47 mkdir -p thrift_line
35 48 $(THRIFT) --gen cpp -out thrift_line line.thrift
36 49  
  50 +$(THRIFT):
  51 + mkdir -p $(THRIFT_STATIC_DIR)
  52 + wget -P $(THRIFT_STATIC_DIR) \
  53 + http://mirror.netinch.com/pub/apache/thrift/0.9.2/thrift-0.9.2.tar.gz
  54 + tar xf $(THRIFT_STATIC_DIR)/thrift-0.9.2.tar.gz \
  55 + -C $(THRIFT_STATIC_DIR) --strip-components 1
  56 + cd $(THRIFT_STATIC_DIR); ./configure \
  57 + --with-pic \
  58 + --disable-tests --disable-tutorial \
  59 + --without-libevent --without-zlib --without-qt4 --without-c_glib --without-csharp \
  60 + --without-java --without-erlang --without-python --without-perl --without-php \
  61 + --without-php_extension --without-ruby --without-haskell --without-go --without-d \
  62 + --without-nodejs --without-lua --without-openssl
  63 + $(MAKE) -C $(THRIFT_STATIC_DIR)
  64 +
37 65 .PHONY: clean
38 66 clean:
39 67 rm -f $(MAIN)
40 68 rm -f *.o
41 69 rm -rf thrift_line
  70 + rm -rf $(THRIFT_STATIC_DIR)
42 71  
43 72 .PHONY: user-install
44 73 user-install: all
... ... @@ -70,4 +99,14 @@ depend: .depend
70 99 rm -f .depend
71 100 $(CXX) $(CXXFLAGS) -MM $(REAL_SRCS) >>.depend
72 101  
  102 +ifneq ($(MAKECMDGOALS),clean)
  103 +ifneq ($(MAKECMDGOALS),user-install)
  104 +ifneq ($(MAKECMDGOALS),user-uninstall)
  105 +ifneq ($(MAKECMDGOALS),install)
  106 +ifneq ($(MAKECMDGOALS),uninstall)
73 107 -include .depend
  108 +endif
  109 +endif
  110 +endif
  111 +endif
  112 +endif
... ...