-
Notifications
You must be signed in to change notification settings - Fork 208
/
Makefile.mingw
111 lines (88 loc) · 3.3 KB
/
Makefile.mingw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
LIBNAME = libwhatsapp.dll
.PHONY: all
all: $(LIBNAME)
C_SRCS = wa_purple.c tinfl.c imgutil.c aes.c
CXX_SRCS = whatsapp-protocol.cc wa_util.cc rc4.cc keygen.cc tree.cc databuffer.cc message.cc
C_OBJS = $(C_SRCS:.c=.o)
CXX_OBJS = $(CXX_SRCS:.cc=.o) AxolotlMessages.pb.o
RESOURCES = libwhatsapp.res
PIDGIN_INCLUDE_WIN32_DEV= -I "$(PIDGIN_DEV_ROOT)/pidgin/libpurple/" \
-I "$(PIDGIN_DEV_ROOT)/win32-dev/gtk_2_0-2.14/include/glib-2.0/" \
-I "$(PIDGIN_DEV_ROOT)/win32-dev/gtk_2_0-2.14/lib/glib-2.0/include/" \
-I "$(PBUF_ROOT)/include/"
PIDGIN_LIB_WIN32_DEV= -L "$(PIDGIN_DEV_ROOT)/win32-dev/gtk_2_0-2.14/lib/" \
-L "$(PIDGIN_DEV_ROOT)/pidgin/libpurple/" \
-L "$(PBUF_ROOT)/lib/" \
-lglib-2.0 -lpurple
INCLUDES = -I./libaxolotl-cpp/ecc \
-I./libaxolotl-cpp/exception \
-I./libaxolotl-cpp/util \
-I./libaxolotl-cpp/state \
-I./libaxolotl-cpp/protocol \
-I./libaxolotl-cpp/groups/ratchet \
-I./libaxolotl-cpp/groups/state \
-I./libaxolotl-cpp/groups \
-I./libaxolotl-cpp/kdf \
-I./libaxolotl-cpp/ratchet \
-I./libaxolotl-cpp/mem-store \
-I./libaxolotl-cpp
STRIP = strip
CC = i686-w64-mingw32-gcc
CXX = i686-w64-mingw32-g++
STRIP = i686-w64-mingw32-strip
RES = i686-w64-mingw32-windres
LD = $(CXX)
CFLAGS_PURPLE = $(shell mingw32-pkg-config --cflags purple)
CFLAGS = \
-std=c99 \
-Wno-unused-parameter \
-O2 \
-m32 \
-Wall \
-Wextra \
-fPIC \
-DPURPLE_PLUGINS \
-DPIC \
$(CFLAGS_PURPLE) \
$(EXTRAINCLUDES) \
$(PIDGIN_INCLUDE_WIN32_DEV) \
$(INCLUDES)
CXXFLAGS = $(CFLAGS) -std=c++11
LIBS_PURPLE = $(shell mingw32-pkg-config --libs purple) $(EXTRALIBS) -lfreeimage ./libaxolotl-cpp/libaxolotl.a -lprotobuf ./libaxolotl-cpp/libcurve25519/libcurve25519.a
LDFLAGS = -shared
AxolotlMessages.pb.h: AxolotlMessages.proto
protoc --cpp_out=. AxolotlMessages.proto
AxolotlMessages.pb.cc: AxolotlMessages.pb.h
# Do nothing
libaxolotl-cpp/libcurve25519/libcurve25519.a:
+make -C libaxolotl-cpp/libcurve25519 CC=$(CC) CXX=$(CXX)
libaxolotl-cpp/libaxolotl.a: libaxolotl-cpp/libcurve25519/libcurve25519.a
+make -C libaxolotl-cpp CC=$(CC) CXX=$(CXX) EXTRA_INCLUDES='$(PIDGIN_INCLUDE_WIN32_DEV)' EXTRA_LIBS='$(PIDGIN_LIB_WIN32_DEV)'
%.o: %.c libaxolotl-cpp/libaxolotl.a
$(CC) -c $(CFLAGS) -o $@ $<
%.o: %.cc AxolotlMessages.pb.h libaxolotl-cpp/libaxolotl.a
$(CXX) -c $(CXXFLAGS) -o $@ $<
%.res: %.rc
$(RES) $< -O coff -o $@
$(LIBNAME): $(C_OBJS) $(CXX_OBJS) $(RESOURCES)
$(LD) $(LDFLAGS) -o $@ $^ $(LIBS_PURPLE) $(PIDGIN_LIB_WIN32_DEV) -static-libgcc -static-libstdc++
$(STRIP) --strip-debug --discard-locals $@
PLUGIN_DIR_PURPLE:=$(shell mingw32-pkg-config --variable=plugindir purple)
DATA_ROOT_DIR_PURPLE:=$(shell mingw32-pkg-config --variable=datarootdir purple)
.PHONY: install
install: $(LIBNAME)
install -D $(LIBNAME) $(PLUGIN_DIR_PURPLE)/$(LIBNAME)
.PHONY: uninstall
uninstall: $(LIBNAME)
rm $(PLUGIN_DIR_PURPLE)/$(LIBNAME)
.PHONY: strip
strip: $(LIBNAME)
$(STRIP) --strip-debug --discard-locals $(LIBNAME)
.PHONY: debug
debug: CFLAGS += -g -DDEBUG
debug: $(LIBNAME)
.PHONY: clean
clean:
-rm -f *.o
-rm -f $(RESOURCES)
-rm -f $(LIBNAME)