~vcs-imports/listen/trunk

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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#/usr/bin/make -f
# vim: ts=4
#

VERSION ?= 0.6~svn$(shell date '+%Y%m%d')

#0 = don't check dependencies usefull to make distribued packages
CHECK_DEPENDS ?= 1

PYTHON  = python
PREFIX ?= /usr
LIBDIR  ?= $(PREFIX)/lib
BINDIR  ?= $(PREFIX)/bin
DATADIR ?= $(PREFIX)/share
LOCALEDIR ?= $(DATADIR)/locale
MANDIR  ?= $(DATADIR)/man
DBUSDIR  ?= $(DATADIR)/dbus-1

USE_GTKMOZEMBED ?= 

GTKMOZEMBED_PATH ?= $(shell pkg-config --libs-only-L mozilla-gtkmozembed 2>/dev/null || pkg-config --libs-only-L firefox-gtkmozembed 2>/dev/null | sed -e "s/-L//g" -e "s/[  ]//g" )


DIST_DIR = src data misc mmkeys po 
DIST_FILE = check.py copy gpl.txt INSTALL Makefile README TODO header.tmpl
DIST_TAR_EXCLUDE = (src/gnomevfswrap.py$$|src/cairo-test.py$$|data/_img.*)
DIST_INSTALL ?= dists/
DIST_BUILD_DEB ?= 0

PYSRC_DIR = $(shell find src -type d -not -ipath \*.svn\* | sed -e 's@src/@@g' -e '/src/d')

PO = $(shell find ./po -name *.po -print | sed -e 's!.po!!g')

all: check mmkeys.so po-data

	echo "#!/bin/sh" > listen
	cat header.tmpl >> listen
	echo >> listen
	echo 'export LISTEN_LIBRARY_PATH="$(LIBDIR)/listen"' >> listen
	echo 'export LISTEN_DATA_PATH="$(DATADIR)/listen"' >> listen
	echo 'export LISTEN_VERSION="$(VERSION)"' >> listen
ifdef USE_GTKMOZEMBED
	echo 'export MOZILLA_FIVE_HOME="$(GTKMOZEMBED_PATH)"' >> listen
	echo 'export LD_LIBRARY_PATH="$(GTKMOZEMBED_PATH)"' >> listen
endif
	echo >> listen
	echo 'cd $$LISTEN_LIBRARY_PATH && exec $(PYTHON) listen "$$@"' >> listen
	echo >> listen

	echo '[D-BUS Service]' > org.gnome.Listen.service
	echo 'Name=org.gnome.Listen' >> org.gnome.Listen.service
	echo 'Exec=$(BINDIR)/listen' >> org.gnome.Listen.service

	docbook2x-man misc/listen.1.docbook --to-stdout | gzip > listen.1.gz

	python -m compileall src
	python -O -m compileall src
	@echo "Done"
	@echo "Type: make install now"



check: 
	@if [ $(CHECK_DEPENDS) -eq 1 ]; then \
		/bin/echo -n "Checking for Python... "; \
		which $(PYTHON) || ( echo "Not found." && /bin/false ); \
		$(PYTHON) ./check.py; \
	fi

mmkeys.so:
	${MAKE} -C mmkeys
	cp mmkeys/mmkeys.so src/mmkeys.so

clean: po-clean	
	rm -rf build
	rm -f tags
	rm -f misc/listen.1 listen.1.gz listen.desktop
	rm -rf $(DIST_INSTALL)
	rm -f listen org.gnome.Listen.service
	find . -type f -name '*.pyc'  -print | xargs rm -rf
	find . -type f -name '*.pyo'  -print | xargs rm -rf
	rm -f src/*.so
	${MAKE} -C mmkeys clean

dist-clean: clean 
	rm -f .project tags
	find . -type d -name '.svn'  -print | xargs rm -rf
	find . -name '*.bak'  -exec rm -rf {} \;
	find . -name '*~'  -exec rm -rf {} \;
	find . -name '.*'  -exec rm -rf {} \; 

make-install-dirs:
	mkdir -p $(DESTDIR)$(BINDIR)
	for dir in $(PYSRC_DIR); do \
		mkdir -p $(DESTDIR)$(LIBDIR)/listen/$${dir} ; \
	done
	
	mkdir -p $(DESTDIR)$(DATADIR)/listen/img/source
	mkdir -p $(DESTDIR)$(DATADIR)/pixmaps
	mkdir -p $(DESTDIR)$(DATADIR)/applications
	mkdir -p $(DESTDIR)$(DATADIR)/man/man1
	mkdir -p $(DESTDIR)$(DATADIR)/dbus-1/services
	
	for lang in $(PO); do mkdir -p $(DESTDIR)$(LOCALEDIR)/$$lang/LC_MESSAGES; done

install: make-install-dirs
	install -m 644 src/*.py $(DESTDIR)$(LIBDIR)/listen
	install -m 644 src/*.pyc $(DESTDIR)$(LIBDIR)/listen
	install -m 644 src/*.pyo $(DESTDIR)$(LIBDIR)/listen
	for dir in $(PYSRC_DIR); do \
		install -m 644 src/$${dir}/*.py $(DESTDIR)$(LIBDIR)/listen/$${dir} ; \
		install -m 644 src/$${dir}/*.pyc $(DESTDIR)$(LIBDIR)/listen/$${dir} ; \
		install -m 644 src/$${dir}/*.pyo $(DESTDIR)$(LIBDIR)/listen/$${dir} ; \
	done
	
	install -m 644 src/mmkeys.so $(DESTDIR)$(LIBDIR)/listen/
	install -m 644 src/listen $(DESTDIR)$(LIBDIR)/listen/
	install -m 644 data/*.glade $(DESTDIR)$(DATADIR)/listen
	install -m 644 data/img/*.png $(DESTDIR)$(DATADIR)/listen/img
	install -m 644 data/img/source/*.png $(DESTDIR)$(DATADIR)/listen/img/source
	install -m 644 data/img/listen.png $(DESTDIR)$(DATADIR)/pixmaps/
	
	install -m 644 listen.desktop $(DESTDIR)$(DATADIR)/applications/
	install -m 644 listen.1.gz $(DESTDIR)$(MANDIR)/man1/
	install -m 644 org.gnome.Listen.service $(DESTDIR)$(DBUSDIR)/services
	
	for lang in $(PO); do install -m 644 po/$$lang.mo $(DESTDIR)$(LOCALEDIR)/$$lang/LC_MESSAGES/listen.mo; done
	
	install -m 755 listen $(DESTDIR)$(BINDIR)


po-data:
	for lang in $(PO); do msgfmt po/$$lang.po -o po/$$lang.mo;done
	intltool-merge -d po misc/listen.desktop.in listen.desktop

po-gen:
	intltool-extract --type=gettext/glade data/trackedit.glade
	intltool-extract --type=gettext/glade data/queuemanager.glade
	intltool-extract --type=gettext/ini misc/listen.desktop.in
	xgettext --from-code=UTF-8 -k_ -kN_ -o po/listen.pot src/*.py src/*/*.py data/*.h misc/*.h src/*/*/*.py
	for lang in $(PO); do msgmerge -U po/$$lang.po po/listen.pot; done

po-clean:
	rm -rf data/*.h
	rm -rf misc/*.h
	rm -rf po/*.mo

header:
	for f in $$(find src/ -type f -name '*.py'); do \
		tag_path=$$(echo $$f | sed -e 's,^src\(.*\)/[^/]*$$,\1,g' -e 's,\([^/]*\),..,g') ;\
		sed -i -e '/^# vim:/d' $$f ;\
		sed -i -e '/^# -*- coding:/d' $$f ;\
		sed -i -e "/^###$$/{N;N;s,^\(###\n#\n# Listen \),# -*- coding: utf-8 -*-\n# vim: ts=4\n\1,}" $$f ;\
	done

dists: clean
	mkdir -p $(DIST_INSTALL)
	mkdir -p build/listen-$(VERSION)
	for dir in $(DIST_DIR); do \
		mkdir -p build/listen-$(VERSION)/$$dir/; \
		cp -rf $$dir/ build/listen-$(VERSION)/; \
	done
	cp $(DIST_FILE) build/listen-$(VERSION)
	${MAKE} -C build/listen-$(VERSION)/ dist-clean
	
	#
	# Prepare all tar ...
	cd build && find listen-$(VERSION) -print | egrep '$(DIST_TAR_EXCLUDE)' > exclude_dists
	cd build && tar czfX ../$(DIST_INSTALL)/listen-$(VERSION).tar.gz exclude_dists listen-$(VERSION)/
	cd build && tar cjfX ../$(DIST_INSTALL)/listen-$(VERSION).tar.bz2 exclude_dists listen-$(VERSION)/
	
	#
	# Prepare debian pakcage if is possible...
	# For svn version and debian based system only
	if [ -d debian ] && [ $(DIST_BUILD_DEB) -eq 1 ]; then \
		mkdir -p $(DIST_INSTALL)/packages/; \
		rm -rf build/listen-$(VERSION); \
		cp -f $(DIST_INSTALL)/listen-$(VERSION).tar.gz  build/listen_$(VERSION).orig.tar.gz ; \
		tar -xzf build/listen_$(VERSION).orig.tar.gz -C build/; \
		cp -rf debian build/listen-$(VERSION)/debian; \
		${MAKE} -C build/listen-$(VERSION)/ dist-clean; \
		cd build/listen-$(VERSION) ; \
		dch -v "$(VERSION)" --distribution "unstable" --force-distribution "SVN snapshot $(VERSION)" ; \
		debuild -S -sa ; \
		dpkg-buildpackage -rfakeroot -us -uc; \
		cd ../..; \
		mv build/listen_* $(DIST_INSTALL)packages/ ; \
	fi 
	
	rm -rf build

tags:
	python -OO utils/ptags.py $$(find src/ -type f -name '*.py'  -print )