No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. # ----------------------------------------------------------------------------
  2. # These variables should not be changed by the regular user, only developers
  3. # should care about them
  4. PROJECTNAME=syncmaildir
  5. VERSION=1.2.6
  6. COPYRIGHT=© 2008-2013 Enrico Tassi <gares@fettunta.org>
  7. BINARIES=mddiff smd-applet
  8. MANPAGES1=mddiff.1 smd-server.1 smd-client.1 \
  9. smd-pull.1 smd-push.1 smd-loop.1 smd-applet.1 smd-translate.1 \
  10. smd-check-conf.1 smd-restricted-shell.1 smd-uniform-names.1
  11. GSCHEMAS=xdg/glib-2.0/schemas/org.syncmaildir.applet.gschema.xml
  12. GSCHEMAS_COMPILED=xdg/glib-2.0/schemas/gschemas.compiled
  13. MANPAGES5=smd-config.5
  14. HTML=index.html design.html hooks.html
  15. DESTDIR=
  16. SF_FRS=/home/frs/project/s/sy/syncmaildir/syncmaildir
  17. SF_LOGIN=$(SF_USER),syncmaildir
  18. SF_WEB=htdocs
  19. TEST_SIZE=100
  20. TEST_MAILBOX=misc/Mail.TEST.tgz
  21. TEST_SUITES=mddiff client-server pull-push migration
  22. BENCH_SIZE=25000
  23. BENCH_MAILBOX=misc/Mail.BENCH.tgz
  24. BENCH_SUITES=benchmarks
  25. PKG_GTK=gtk+-3.0
  26. SMD_APPLET_C=smd-applet.c
  27. PKGS_VALA=glib-2.0 $(PKG_GTK) libnotify gconf-2.0 gee-1.0 gio-2.0
  28. TARGET_GLIB=2.32
  29. PKGCONFIG_CHECK_GLIB_VERSION=--atleast-version=$(TARGET_GLIB) glib-2.0
  30. PKGCONFIG_GLIB_VERSION=--modversion glib-2.0
  31. VALAC=valac-0.22
  32. H=@
  33. # ----------------------------------------------------------------------------
  34. # These variables affect the programs behaviour and their installation;
  35. # they are meant to be overridden if necessary. See the end of this
  36. # file for some templates setting them.
  37. PREFIX=usr/local
  38. SED=sed
  39. XDELTA=xdelta
  40. SSH=ssh
  41. LUAV=5.1
  42. LUA=lua$(LUAV)
  43. CFLAGS=-O2 -Wall -Wextra -Wcast-align -g
  44. PKG_FLAGS=
  45. # ----------------------------------------------------------------------------
  46. # Rules follow...
  47. all: check-build update-smd-config $(BINARIES) $(GSCHEMAS_COMPILED)
  48. update-smd-config:
  49. $H echo "#define SMD_CONF_PREFIX \"/$(PREFIX)\"" > smd-config.h.new
  50. $H echo "#define SMD_CONF_VERSION \"$(VERSION)\"" >> smd-config.h.new
  51. $H echo "#define SMD_CONF_COPYRIGHT \"$(COPYRIGHT)\"" \
  52. >> smd-config.h.new
  53. $H if diff -q smd-config.h smd-config.h.new > /dev/null 2>&1; then \
  54. rm smd-config.h.new; \
  55. else \
  56. echo CONFIGURE smd-config.h; \
  57. mv smd-config.h.new smd-config.h; \
  58. fi
  59. smd-applet.c: smd-applet.vala smd-config.vapi
  60. $H if which $(VALAC) >/dev/null; then \
  61. echo "VALAC $^"; \
  62. $(VALAC) -C $^ --thread --vapidir=./ \
  63. --target-glib=$(TARGET_GLIB) \
  64. --pkg posix $(patsubst %,--pkg %,$(PKGS_VALA)); \
  65. elif [ -e smd-applet.c ]; then \
  66. echo "** No $(VALAC), reusing precompiled .c files"; \
  67. echo "** Changes to the following files will not be"; \
  68. echo "** taken into account: $^"; \
  69. else \
  70. echo "** No $(VALAC) and no precompiled .c files"; \
  71. echo "** To compile smd-applet you need a vala compiler"; \
  72. echo "** or the precompiled $@ file"; \
  73. false; \
  74. fi
  75. $H touch $@
  76. mddiff: mddiff.c smd-config.h
  77. @echo CC $<
  78. $H $(CC) $(CFLAGS) $< -o $@ \
  79. `pkg-config $(PKG_FLAGS) --cflags --libs glib-2.0` $(LDFLAGS)
  80. smd-applet: $(SMD_APPLET_C) smd-config.h
  81. @echo CC $<
  82. $H $(CC) $(CFLAGS) -w $< -o $@ \
  83. `pkg-config $(PKG_FLAGS) --cflags --libs $(PKGS_VALA)` \
  84. $(LDFLAGS)
  85. $(GSCHEMAS_COMPILED): $(GSCHEMAS)
  86. @echo GLIB-COMPILE-SCHEMAS $(dir $(GSCHEMAS))
  87. $H glib-compile-schemas $(dir $(GSCHEMAS))
  88. $H $(foreach p,$(subst :, ,$(XDG_DATA_DIRS)), \
  89. test -e $(p)/glib-2.0/schemas/$(patsubst xdg/%, \
  90. %,$(notdir $(GSCHEMAS))) ||) \
  91. echo WARN: export XDG_DATA_DIRS=\$$XDG_DATA_DIRS:xdg/
  92. check-build: check-w-gcc check-w-$(VALAC) check-w-glib-compile-schemas
  93. $H pkg-config $(PKGCONFIG_CHECK_GLIB_VERSION) || \
  94. (echo glib version too old: \
  95. `pkg-config $(PKGCONFIG_GLIB_VERSION)`; \
  96. echo required version: $(TARGET_GLIB); \
  97. false)
  98. check-run: check-w-$(LUA) check-w-bash
  99. check-w-%:
  100. $H which $* > /dev/null || echo $* not found
  101. test/%: text/all check-run $(TEST_MAILBOX)
  102. $H tests.d/test.sh $(TEST_MAILBOX) $*
  103. test: text/all check-run $(TEST_MAILBOX)
  104. $H SUITES="$(TEST_SUITES)" tests.d/test.sh $(TEST_MAILBOX)
  105. bench: text/all check-run $(BENCH_MAILBOX)
  106. $H SUITES="$(BENCH_SUITES)" tests.d/test.sh \
  107. $(BENCH_MAILBOX) $(addprefix $(shell pwd)/,$T)
  108. misc/Mail.%.tgz:
  109. $(MAKE) check-w-polygen
  110. rm -rf Mail
  111. mkdir -p Mail/cur
  112. namea=Mail/cur/`date +%s`.$$$$;\
  113. nameb=`hostname`;\
  114. date=`date`;\
  115. for i in `seq $$core $($*_SIZE) $$CORES`; do \
  116. name=$${namea}_$$i.$$nameb;\
  117. echo "Subject: foo-subject $$i" >> $$name; \
  118. echo "Message-Id: $$i" >> $$name; \
  119. echo "Date: $$date" >> $$name; \
  120. echo "X-Foo: foo.foo.com" >> $$name; \
  121. echo >> $$name;\
  122. polygen -X 10 /usr/share/polygen/eng/manager.grm >> $$name;\
  123. done
  124. tar -czf $@ Mail
  125. rm -rf Mail
  126. %.1:%.1.txt check-w-txt2man
  127. txt2man -t $* -v "Sync Mail Dir (smd) documentation" -s 1 $< > $@
  128. %.5:%.5.txt check-w-txt2man
  129. txt2man -t $* -v "Sync Mail Dir (smd) documentation" -s 5 $< > $@
  130. define install-replacing
  131. cat $(1) |\
  132. $(SED) 's?@PREFIX@?/$(PREFIX)?' |\
  133. $(SED) 's?@SED@?$(SED)?' |\
  134. $(SED) 's?@XDELTA@?$(XDELTA)?' |\
  135. $(SED) 's?@SSH@?$(SSH)?' |\
  136. $(SED) 's?@SMDVERSION@?$(VERSION)?' |\
  137. $(SED) 's?#! /usr/bin/env lua.*?#! /usr/bin/env $(LUA)?' |\
  138. cat > $(DESTDIR)/$(PREFIX)/$(2)/$(1)
  139. if [ $(2) = "bin" ]; then chmod a+rx $(DESTDIR)/$(PREFIX)/$(2)/$(1); fi
  140. endef
  141. define install
  142. cp $(1) $(DESTDIR)/$(PREFIX)/$(2)/$(notdir $(1))
  143. if [ $(2) = "bin" ]; then chmod a+rx $(DESTDIR)/$(PREFIX)/$(2)/$(1); fi
  144. endef
  145. define mkdir-p
  146. mkdir -p $(DESTDIR)/$(PREFIX)/$(1)
  147. endef
  148. install: install-bin install-misc
  149. install-bin: $(BINARIES)
  150. $(call mkdir-p,bin)
  151. $(call mkdir-p,share/$(PROJECTNAME))
  152. $(call mkdir-p,share/$(PROJECTNAME)-applet)
  153. $(call mkdir-p,share/lua/$(LUAV))
  154. cp $(BINARIES) $(DESTDIR)/$(PREFIX)/bin
  155. $(call install-replacing,smd-server,bin)
  156. $(call install-replacing,smd-client,bin)
  157. $(call install-replacing,smd-pull,bin)
  158. $(call install-replacing,smd-push,bin)
  159. $(call install-replacing,smd-translate,bin)
  160. $(call install-replacing,smd-check-conf,bin)
  161. $(call install-replacing,smd-uniform-names,bin)
  162. $(call install-replacing,smd-restricted-shell,bin)
  163. $(call install-replacing,smd-loop,bin)
  164. $(call install-replacing,smd-common,share/$(PROJECTNAME))
  165. $(call install-replacing,syncmaildir.lua,share/lua/$(LUAV))
  166. install-misc: $(MANPAGES1) $(MANPAGES5)
  167. $(call mkdir-p,$(DESTDIR)/etc/xdg/autostart)
  168. $(foreach d,\
  169. $(filter-out xdg,$(shell find xdg -type d)),\
  170. $(call mkdir-p,share/$(patsubst xdg/%,%,$(d)));)
  171. $(foreach f,\
  172. $(filter-out $(GSCHEMAS_COMPILED),$(shell find xdg -type f)),\
  173. $(call install,$(f),share/$(patsubst xdg/%,%,$(dir $(f))));)
  174. $(call install,smd-applet.ui,share/$(PROJECTNAME)-applet)
  175. $(call mkdir-p,share/man/man1)
  176. $(call mkdir-p,share/man/man5)
  177. cp $(MANPAGES1) $(DESTDIR)/$(PREFIX)/share/man/man1
  178. cp $(MANPAGES5) $(DESTDIR)/$(PREFIX)/share/man/man5
  179. $(call mkdir-p,share/doc/syncmaildir)
  180. cp -r sample-hooks/ $(DESTDIR)/$(PREFIX)/share/doc/syncmaildir
  181. $(call install,README,share/doc/syncmaildir)
  182. clean:
  183. $H rm -f $(BINARIES) $(MANPAGES1) $(MANPAGES5)
  184. $H rm -rf tests.d/run
  185. $H rm -f $(PROJECTNAME)-$(VERSION).tar.gz
  186. $H rm -f $(HTML) $(MANPAGES1:=.html) $(MANPAGES5:=.html)
  187. $H rm -f misc/smd-applet-1.0.0.c
  188. dist $(PROJECTNAME)-$(VERSION).tar.gz: smd-applet.c
  189. rm -f $(PROJECTNAME)-$(VERSION).tar.gz
  190. rm -f $(PROJECTNAME)-$(VERSION).tar
  191. git archive --format=tar \
  192. --prefix=$(PROJECTNAME)-$(VERSION)/ HEAD \
  193. > $(PROJECTNAME)-$(VERSION).tar
  194. tar --transform=s?^?$(PROJECTNAME)-$(VERSION)/? \
  195. -r smd-applet.c \
  196. --owner root --group root \
  197. -f $(PROJECTNAME)-$(VERSION).tar
  198. gzip -9 -f $(PROJECTNAME)-$(VERSION).tar
  199. $(HTML): check-w-markdown
  200. cat misc/head.html > index.html
  201. markdown README >> index.html
  202. cat misc/tail.html >> index.html
  203. cat misc/head.html > design.html
  204. markdown DESIGN >> design.html
  205. cat misc/tail.html >> design.html
  206. cat misc/head.html > hooks.html
  207. grep -h '^##' sample-hooks/* | sed 's/^## \?//' | markdown >> hooks.html
  208. cat misc/tail.html >> hooks.html
  209. %.html:%.txt
  210. cat misc/head.html > $@
  211. echo '<pre>' >> $@
  212. cat $< | sed -e '/^AUTHOR/,$$d' >> $@
  213. echo '</pre>' >> $@
  214. cat misc/tail.html >> $@
  215. upload-website: $(HTML) $(MANPAGES1:%=%.html) $(MANPAGES5:%=%.html)
  216. scp $? misc/style.css \
  217. $(SF_LOGIN)@web.sourceforge.net:$(SF_WEB)
  218. upload-tarball-and-changelog: $(PROJECTNAME)-$(VERSION).tar.gz
  219. scp $(PROJECTNAME)-$(VERSION).tar.gz \
  220. $(SF_LOGIN)@frs.sourceforge.net:$(SF_FRS)/$<
  221. scp ChangeLog $(SF_LOGIN)@frs.sourceforge.net:$(SF_FRS)/README
  222. stats:
  223. T=`git tag | sort -V | head -n 1`; \
  224. for V in `git tag | sort -V | tail -n +2`; do \
  225. echo $$V; \
  226. git diff $$T $$V | diffstat -s; T=$$V; \
  227. done;\
  228. git diff --no-prefix $$V HEAD | diffstat -C
  229. # ----------------------------------------------------------------------------
  230. # These templates collect standard values for known platforms, like osx.
  231. # To use a template run make TEMPLATE/TARGET, for example:
  232. # make osx/all && make osx/install
  233. # You may also combine templates. For example, to build only text mode
  234. # utilities on osx type:
  235. # make osx/text/all && make osx/text/install
  236. text/%:
  237. $H $(MAKE) $* \
  238. BINARIES="$(subst smd-applet,,$(BINARIES))" \
  239. MANPAGES1="$(subst smd-applet.1,,$(MANPAGES1))" \
  240. PREFIX="$(PREFIX)" VALAC=ls H=$H \
  241. CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
  242. static/%:
  243. $H $(MAKE) $* \
  244. CFLAGS="$(CFLAGS) -static " \
  245. PKG_FLAGS="$(PKG_FLAGS) --static " \
  246. PREFIX="$(PREFIX)" H=$H LDFLAGS="$(LDFLAGS)"
  247. gnome2/%:
  248. $H gunzip -c misc/smd-applet-1.0.0.c.gz > misc/smd-applet-1.0.0.c
  249. $H $(MAKE) $* \
  250. SMD_APPLET_C=misc/smd-applet-1.0.0.c PKG_GTK=gtk+-2.0 \
  251. CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" TARGET_GLIB="2.19.1"
  252. osx/%:
  253. $H $(MAKE) $* SED=sed PREFIX="$(PREFIX)" H=$H \
  254. CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
  255. abspath/%:
  256. $H $(MAKE) $* SED=/bin/sed \
  257. XDELTA=/usr/bin/xdelta SSH=/usr/bin/ssh \
  258. PREFIX="$(PREFIX)" H=$H \
  259. CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
  260. .PHONY : update-smd-config
  261. # eof