Makefile 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. PIDGIN_TREE_TOP ?= ../pidgin-2.10.11
  2. PIDGIN3_TREE_TOP ?= ../pidgin-main
  3. LIBPURPLE_DIR ?= $(PIDGIN_TREE_TOP)/libpurple
  4. WIN32_DEV_TOP ?= $(PIDGIN_TREE_TOP)/../win32-dev
  5. WIN32_CC ?= $(WIN32_DEV_TOP)/mingw-4.7.2/bin/gcc
  6. PROTOC_C ?= protoc-c
  7. PKG_CONFIG ?= pkg-config
  8. DIR_PERM = 0755
  9. LIB_PERM = 0755
  10. FILE_PERM = 0644
  11. REVISION_ID = $(shell hg id -i)
  12. REVISION_NUMBER = $(shell hg id -n)
  13. ifneq ($(REVISION_ID),)
  14. PLUGIN_VERSION ?= 0.9.$(shell date +%Y.%m.%d).git.r$(REVISION_NUMBER).$(REVISION_ID)
  15. else
  16. PLUGIN_VERSION ?= 0.9.$(shell date +%Y.%m.%d)
  17. endif
  18. CFLAGS ?= -O2 -g -pipe -Wall
  19. LDFLAGS ?= -Wl,-z,relro
  20. CFLAGS += -std=c99 -DEMAIL_PLUGIN_VERSION='"$(PLUGIN_VERSION)"'
  21. # Comment out to disable localisation
  22. CFLAGS += -DENABLE_NLS
  23. # Do some nasty OS and purple version detection
  24. ifeq ($(OS),Windows_NT)
  25. EMAIL_TARGET = libemail.dll
  26. EMAIL_DEST = "$(PROGRAMFILES)/Pidgin/plugins"
  27. EMAIL_ICONS_DEST = "$(PROGRAMFILES)/Pidgin/pixmaps/pidgin/protocols"
  28. LOCALEDIR = "$(PROGRAMFILES)/Pidgin/locale"
  29. else
  30. UNAME_S := $(shell uname -s)
  31. #.. There are special flags we need for OSX
  32. ifeq ($(UNAME_S), Darwin)
  33. #
  34. #.. /opt/local/include and subdirs are included here to ensure this compiles
  35. # for folks using Macports. I believe Homebrew uses /usr/local/include
  36. # so things should "just work". You *must* make sure your packages are
  37. # all up to date or you will most likely get compilation errors.
  38. #
  39. INCLUDES = -I/opt/local/include -lz $(OS)
  40. CC = gcc
  41. else
  42. CC ?= gcc
  43. endif
  44. ifeq ($(shell $(PKG_CONFIG) --exists purple-3 2>/dev/null && echo "true"),)
  45. ifeq ($(shell $(PKG_CONFIG) --exists purple 2>/dev/null && echo "true"),)
  46. EMAIL_TARGET = FAILNOPURPLE
  47. EMAIL_DEST =
  48. EMAIL_ICONS_DEST =
  49. else
  50. EMAIL_TARGET = libemail.so
  51. EMAIL_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=plugindir purple`
  52. EMAIL_ICONS_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=datadir purple`/pixmaps/pidgin/protocols
  53. LOCALEDIR = $(DESTDIR)$(shell $(PKG_CONFIG) --variable=datadir purple)/locale
  54. endif
  55. else
  56. EMAIL_TARGET = libemail3.so
  57. EMAIL_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=plugindir purple-3`
  58. EMAIL_ICONS_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=datadir purple-3`/pixmaps/pidgin/protocols
  59. LOCALEDIR = $(DESTDIR)$(shell $(PKG_CONFIG) --variable=datadir purple-3)/locale
  60. endif
  61. endif
  62. WIN32_CFLAGS = -std=c99 -I$(WIN32_DEV_TOP)/glib-2.28.8/include -I$(WIN32_DEV_TOP)/glib-2.28.8/include/glib-2.0 -I$(WIN32_DEV_TOP)/glib-2.28.8/lib/glib-2.0/include -I$(WIN32_DEV_TOP)/json-glib-0.14/include/json-glib-1.0 -DENABLE_NLS -DEMAIL_PLUGIN_VERSION='"$(PLUGIN_VERSION)"' -Wall -Wextra -Werror -Wno-deprecated-declarations -Wno-unused-parameter -fno-strict-aliasing -Wformat
  63. WIN32_LDFLAGS = -L$(WIN32_DEV_TOP)/glib-2.28.8/lib -L$(WIN32_DEV_TOP)/json-glib-0.14/lib -lpurple -lintl -lglib-2.0 -lgobject-2.0 -ljson-glib-1.0 -g -ggdb -static-libgcc -lz
  64. WIN32_PIDGIN2_CFLAGS = -I$(PIDGIN_TREE_TOP)/libpurple -I$(PIDGIN_TREE_TOP) $(WIN32_CFLAGS)
  65. WIN32_PIDGIN3_CFLAGS = -I$(PIDGIN3_TREE_TOP)/libpurple -I$(PIDGIN3_TREE_TOP) -I$(WIN32_DEV_TOP)/gplugin-dev/gplugin $(WIN32_CFLAGS)
  66. WIN32_PIDGIN2_LDFLAGS = -L$(PIDGIN_TREE_TOP)/libpurple $(WIN32_LDFLAGS)
  67. WIN32_PIDGIN3_LDFLAGS = -L$(PIDGIN3_TREE_TOP)/libpurple -L$(WIN32_DEV_TOP)/gplugin-dev/gplugin $(WIN32_LDFLAGS) -lgplugin
  68. CFLAGS += -DLOCALEDIR=\"$(LOCALEDIR)\"
  69. C_FILES :=
  70. PURPLE_COMPAT_FILES := purple2compat/purple-socket.c
  71. PURPLE_C_FILES := libemail.c $(C_FILES)
  72. .PHONY: all install FAILNOPURPLE clean install-icons install-locales %-locale-install
  73. LOCALES = $(patsubst %.po, %.mo, $(wildcard po/*.po))
  74. all: $(EMAIL_TARGET)
  75. libemail.so: $(PURPLE_C_FILES) $(PURPLE_COMPAT_FILES)
  76. $(CC) -fPIC $(CFLAGS) -shared -o $@ $^ $(LDFLAGS) `$(PKG_CONFIG) purple glib-2.0 json-glib-1.0 --libs --cflags` $(INCLUDES) -Ipurple2compat -g -ggdb
  77. libemail3.so: $(PURPLE_C_FILES)
  78. $(CC) -fPIC $(CFLAGS) -shared -o $@ $^ $(LDFLAGS) `$(PKG_CONFIG) purple-3 glib-2.0 json-glib-1.0 --libs --cflags` $(INCLUDES) -g -ggdb
  79. libemail.dll: $(PURPLE_C_FILES) $(PURPLE_COMPAT_FILES)
  80. $(WIN32_CC) -O0 -g -ggdb -shared -o $@ $^ $(WIN32_PIDGIN2_CFLAGS) $(WIN32_PIDGIN2_LDFLAGS) -Ipurple2compat
  81. libemail3.dll: $(PURPLE_C_FILES) $(PURPLE_COMPAT_FILES)
  82. $(WIN32_CC) -O0 -g -ggdb -shared -o $@ $^ $(WIN32_PIDGIN3_CFLAGS) $(WIN32_PIDGIN3_LDFLAGS)
  83. po/purple-email.pot: libemail.c
  84. xgettext $^ -k_ --no-location -o $@
  85. po/%.po: po/purple-email.pot
  86. msgmerge $@ po/purple-email.pot > tmp-$*
  87. mv -f tmp-$* $@
  88. po/%.mo: po/%.po
  89. msgfmt -o $@ $^
  90. %-locale-install: po/%.mo
  91. install -D -m $(FILE_PERM) -p po/$(*F).mo $(LOCALEDIR)/$(*F)/LC_MESSAGES/purple-email.mo
  92. install: $(EMAIL_TARGET) install-icons install-locales
  93. mkdir -m $(DIR_PERM) -p $(EMAIL_DEST)
  94. install -m $(LIB_PERM) -p $(EMAIL_TARGET) $(EMAIL_DEST)
  95. install-icons: email16.png email22.png email48.png
  96. mkdir -m $(DIR_PERM) -p $(EMAIL_ICONS_DEST)/16
  97. mkdir -m $(DIR_PERM) -p $(EMAIL_ICONS_DEST)/22
  98. mkdir -m $(DIR_PERM) -p $(EMAIL_ICONS_DEST)/48
  99. install -m $(FILE_PERM) -p email16.png $(EMAIL_ICONS_DEST)/16/email.png
  100. install -m $(FILE_PERM) -p email22.png $(EMAIL_ICONS_DEST)/22/email.png
  101. install -m $(FILE_PERM) -p email48.png $(EMAIL_ICONS_DEST)/48/email.png
  102. install-locales: $(patsubst po/%.po, %-locale-install, $(wildcard po/*.po))
  103. FAILNOPURPLE:
  104. echo "You need libpurple development headers installed to be able to compile this plugin"
  105. clean:
  106. rm -f $(EMAIL_TARGET)
  107. gdb:
  108. gdb --args pidgin -c ~/.fake_purple -n -m