Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. # Note: Use "-C .git" to avoid ascending to parent dirs if .git not present
  12. GIT_REVISION_ID = $(shell git -C .git rev-parse --short HEAD 2>/dev/null)
  13. REVISION_ID = $(shell hg id -i 2>/dev/null)
  14. REVISION_NUMBER = $(shell hg id -n 2>/dev/null)
  15. ifneq ($(REVISION_ID),)
  16. PLUGIN_VERSION ?= 0.9.$(shell date +%Y.%m.%d).git.r$(REVISION_NUMBER).$(REVISION_ID)
  17. else ifneq ($(GIT_REVISION_ID),)
  18. PLUGIN_VERSION ?= 0.9.$(shell date +%Y.%m.%d).git.$(GIT_REVISION_ID)
  19. else
  20. PLUGIN_VERSION ?= 0.9.$(shell date +%Y.%m.%d)
  21. endif
  22. CFLAGS ?= -O2 -g -pipe -Wall
  23. LDFLAGS ?= -Wl,-z,relro
  24. CFLAGS += -std=c99 -DGROUPME_PLUGIN_VERSION='"$(PLUGIN_VERSION)"'
  25. # Comment out to disable localisation
  26. CFLAGS += -DENABLE_NLS
  27. # Do some nasty OS and purple version detection
  28. ifeq ($(OS),Windows_NT)
  29. #only defined on 64-bit windows
  30. PROGFILES32 = ${ProgramFiles(x86)}
  31. ifndef PROGFILES32
  32. PROGFILES32 = $(PROGRAMFILES)
  33. endif
  34. GROUPME_TARGET = libgroupme.dll
  35. GROUPME_DEST = "$(PROGFILES32)/Pidgin/plugins"
  36. GROUPME_ICONS_DEST = "$(PROGFILES32)/Pidgin/pixmaps/pidgin/protocols"
  37. LOCALEDIR = "$(PROGFILES32)/Pidgin/locale"
  38. else
  39. UNAME_S := $(shell uname -s)
  40. #.. There are special flags we need for OSX
  41. ifeq ($(UNAME_S), Darwin)
  42. #
  43. #.. /opt/local/include and subdirs are included here to ensure this compiles
  44. # for folks using Macports. I believe Homebrew uses /usr/local/include
  45. # so things should "just work". You *must* make sure your packages are
  46. # all up to date or you will most likely get compilation errors.
  47. #
  48. INCLUDES = -I/opt/local/include -lz $(OS)
  49. CC = gcc
  50. else
  51. CC ?= gcc
  52. endif
  53. ifeq ($(shell $(PKG_CONFIG) --exists purple-3 2>/dev/null && echo "true"),)
  54. ifeq ($(shell $(PKG_CONFIG) --exists purple 2>/dev/null && echo "true"),)
  55. GROUPME_TARGET = FAILNOPURPLE
  56. GROUPME_DEST =
  57. GROUPME_ICONS_DEST =
  58. else
  59. GROUPME_TARGET = libgroupme.so
  60. GROUPME_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=plugindir purple`
  61. GROUPME_ICONS_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=datadir purple`/pixmaps/pidgin/protocols
  62. LOCALEDIR = $(DESTDIR)$(shell $(PKG_CONFIG) --variable=datadir purple)/locale
  63. endif
  64. else
  65. GROUPME_TARGET = libgroupme3.so
  66. GROUPME_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=plugindir purple-3`
  67. GROUPME_ICONS_DEST = $(DESTDIR)`$(PKG_CONFIG) --variable=datadir purple-3`/pixmaps/pidgin/protocols
  68. LOCALEDIR = $(DESTDIR)$(shell $(PKG_CONFIG) --variable=datadir purple-3)/locale
  69. endif
  70. endif
  71. 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 -DGROUPME_PLUGIN_VERSION='"$(PLUGIN_VERSION)"' -Wall -Wextra -Werror -Wno-deprecated-declarations -Wno-unused-parameter -fno-strict-aliasing -Wformat
  72. 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
  73. WIN32_PIDGIN2_CFLAGS = -I$(PIDGIN_TREE_TOP)/libpurple -I$(PIDGIN_TREE_TOP) $(WIN32_CFLAGS)
  74. WIN32_PIDGIN3_CFLAGS = -I$(PIDGIN3_TREE_TOP)/libpurple -I$(PIDGIN3_TREE_TOP) -I$(WIN32_DEV_TOP)/gplugin-dev/gplugin $(WIN32_CFLAGS)
  75. WIN32_PIDGIN2_LDFLAGS = -L$(PIDGIN_TREE_TOP)/libpurple $(WIN32_LDFLAGS)
  76. WIN32_PIDGIN3_LDFLAGS = -L$(PIDGIN3_TREE_TOP)/libpurple -L$(WIN32_DEV_TOP)/gplugin-dev/gplugin $(WIN32_LDFLAGS) -lgplugin
  77. CFLAGS += -DLOCALEDIR=\"$(LOCALEDIR)\"
  78. C_FILES :=
  79. PURPLE_COMPAT_FILES :=
  80. PURPLE_C_FILES := libgroupme.c $(C_FILES)
  81. .PHONY: all install FAILNOPURPLE clean install-icons install-locales %-locale-install
  82. LOCALES = $(patsubst %.po, %.mo, $(wildcard po/*.po))
  83. all: $(GROUPME_TARGET)
  84. libgroupme.so: $(PURPLE_C_FILES) $(PURPLE_COMPAT_FILES)
  85. $(CC) -fPIC $(CFLAGS) $(CPPFLAGS) -shared -o $@ $^ $(LDFLAGS) `$(PKG_CONFIG) purple glib-2.0 json-glib-1.0 --libs --cflags` $(INCLUDES) -Ipurple2compat -g -ggdb
  86. libgroupme3.so: $(PURPLE_C_FILES)
  87. $(CC) -fPIC $(CFLAGS) $(CPPFLAGS) -shared -o $@ $^ $(LDFLAGS) `$(PKG_CONFIG) purple-3 glib-2.0 json-glib-1.0 --libs --cflags` $(INCLUDES) -g -ggdb
  88. libgroupme.dll: $(PURPLE_C_FILES) $(PURPLE_COMPAT_FILES)
  89. $(WIN32_CC) -O0 -g -ggdb -shared -o $@ $^ $(WIN32_PIDGIN2_CFLAGS) $(WIN32_PIDGIN2_LDFLAGS) -Ipurple2compat
  90. libgroupme3.dll: $(PURPLE_C_FILES) $(PURPLE_COMPAT_FILES)
  91. $(WIN32_CC) -O0 -g -ggdb -shared -o $@ $^ $(WIN32_PIDGIN3_CFLAGS) $(WIN32_PIDGIN3_LDFLAGS)
  92. po/purple-groupme.pot: libgroupme.c
  93. xgettext $^ -k_ --no-location -o $@
  94. po/%.po: po/purple-groupme.pot
  95. msgmerge $@ po/purple-groupme.pot > tmp-$*
  96. mv -f tmp-$* $@
  97. po/%.mo: po/%.po
  98. msgfmt -o $@ $^
  99. %-locale-install: po/%.mo
  100. install -D -m $(FILE_PERM) -p po/$(*F).mo $(LOCALEDIR)/$(*F)/LC_MESSAGES/purple-groupme.mo
  101. install: $(GROUPME_TARGET) install-icons install-locales
  102. mkdir -m $(DIR_PERM) -p $(GROUPME_DEST)
  103. install -m $(LIB_PERM) -p $(GROUPME_TARGET) $(GROUPME_DEST)
  104. install-icons: groupme16.png groupme22.png groupme48.png
  105. mkdir -m $(DIR_PERM) -p $(GROUPME_ICONS_DEST)/16
  106. mkdir -m $(DIR_PERM) -p $(GROUPME_ICONS_DEST)/22
  107. mkdir -m $(DIR_PERM) -p $(GROUPME_ICONS_DEST)/48
  108. install -m $(FILE_PERM) -p groupme16.png $(GROUPME_ICONS_DEST)/16/groupme.png
  109. install -m $(FILE_PERM) -p groupme22.png $(GROUPME_ICONS_DEST)/22/groupme.png
  110. install -m $(FILE_PERM) -p groupme48.png $(GROUPME_ICONS_DEST)/48/groupme.png
  111. install-locales: $(patsubst po/%.po, %-locale-install, $(wildcard po/*.po))
  112. FAILNOPURPLE:
  113. echo "You need libpurple development headers installed to be able to compile this plugin"
  114. clean:
  115. rm -f $(GROUPME_TARGET)
  116. gdb:
  117. gdb --args pidgin -c ~/.fake_purple -n -m