~ubuntu-branches/ubuntu/trusty/sbackup/trusty

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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
################################################################################
#
#   Simple Backup - GNU Makefile
#
#   Copyright (c)2008-2010: Jean-Peer Lorenz <peer.loz@gmx.net>
#   Copyright (c)2007-2010: Ouattara Oumar Aziz <wattazoum@gmail.com>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
################################################################################

# grab name and current version
METAFILE="METAINFO"
VERSION=$(shell grep "^VERSION=" $(METAFILE)|cut -d "=" -f 2 -)
PKGNAME=$(shell grep "^PKGNAME=" $(METAFILE)|cut -d "=" -f 2 -)

# retrieve/determine used applications (version of Python interpreter...)
PYTHON=$(shell which python)
servicetool=$(shell which service)
gconftool=$(shell which gconftool-2)

export GCONF_CONFIG_SOURCE=$(shell if test -x "$(gconftool)"; then $(gconftool) --get-default-source; fi)

# available languages UI
PO=ar bg ca cs de en_AU en_CA en_GB es fi fr gl he hu id it lv ms nb nl oc pl pt pt_BR ru sv tr uk zh_CN zh_TW da el fa is ja kk ko kw ro sr sw

# available languages Help/Manual
HELPLANG=C


# definition of paths and filenames
# installation into /usr/local to be compliant to GNU standards
PREFIX=/usr/local
DESTDIR=/usr/local

datadir=$(DESTDIR)/share
bindir=$(DESTDIR)/bin
sbindir=$(DESTDIR)/sbin

libdir=$(datadir)/$(PKGNAME)
helpdir=$(datadir)/gnome/help/$(PKGNAME)
langdir=$(datadir)/locale
icondir=$(datadir)/icons
gconf_schema_file_dir=$(datadir)/gconf/schemas

sysconf_dir=/etc
dbus_system_conf_dir=$(sysconf_dir)/dbus-1/system.d

gconf_schema_file=apps_sbackup_global-preferences.schemas
dbus_system_conf_file=org.sbackupteam.SimpleBackup.conf

iconslst=sbackup-panel.png sbackup-attention.png sbackup-success.png

gtk_update_icon_cache=if test "$(DISABLE_MAKEFILE_GTK_UPDATE_ICON_CACHE)" = ""; then \
						gtk-update-icon-cache -f -t $(icondir)/hicolor; \
						gtk-update-icon-cache -f -t $(icondir)/ubuntu-mono-light; \
						gtk-update-icon-cache -f -t $(icondir)/ubuntu-mono-dark; fi

# distutils options
SETUP.PY_OPTS=--root=/ --install-lib $(libdir) -O0


default: build-po fill-templates
	$(PYTHON) setup.py build

build-po:
	set -e; for lang in $(PO); do install -d po/$$lang/LC_MESSAGES/ ; done
	set -e; for lang in $(PO); do msgfmt po/$$lang.po -o po/$$lang/LC_MESSAGES/sbackup.mo ; done

#TODO: use intltool and scan *.desktop...
po-gen:
	set -e; xgettext -o po/sbackup.pot src/sbackup/*.py src/sbackup/*/*.py data/ui/*.glade scripts/*.py
	set -e; for lang in $(PO); do msgmerge -U po/$$lang.po po/sbackup.pot; done

fill-templates:
	set -e; sed s+@prefix@+$(PREFIX)+ src/sbackup/resources.in > src/sbackup/resources
	set -e; sed s+@prefix@+$(PREFIX)+ data/desktop/sbackup-config.desktop.in > data/desktop/sbackup-config.desktop
	set -e; sed s+@prefix@+$(PREFIX)+ data/desktop/sbackup-config-su.desktop.in > data/desktop/sbackup-config-su.desktop.tmp
	set -e; sed s+@prefix@+$(PREFIX)+ data/desktop/sbackup-config-su.desktop.tmp > data/desktop/sbackup-config-su.desktop
	set -e; sed s+@prefix@+$(PREFIX)+ data/desktop/sbackup-restore.desktop.in > data/desktop/sbackup-restore.desktop
	set -e; sed s+@prefix@+$(PREFIX)+ data/desktop/sbackup-restore-su.desktop.in > data/desktop/sbackup-restore-su.desktop.tmp
	set -e; sed s+@prefix@+$(PREFIX)+ data/desktop/sbackup-restore-su.desktop.tmp > data/desktop/sbackup-restore-su.desktop
	set -e; sed s+@version@+$(VERSION)+ setup.py.in > setup.py.tmp
	set -e; sed s+@pkgname@+$(PKGNAME)+ setup.py.tmp > setup.py
	set -e; sed s+@version@+$(VERSION)+ src/sbackup/metainfo.in > src/sbackup/metainfo.tmp
	set -e; sed s+@pkgname@+$(PKGNAME)+ src/sbackup/metainfo.tmp > src/sbackup/metainfo
	rm -f data/desktop/*.tmp src/sbackup/*.tmp *.tmp

check:
	@echo "Check for another installation of sbackup"
	@set -e; for lang in $(DESTDIR)/sbin/sbackupd $(DESTDIR)/bin/sbackup $(DESTDIR)/../sbin/sbackupd $(DESTDIR)/../bin/sbackup; do echo "	checking: $$lang"; if [ -e $$lang ]; then echo "Another installation of sbackup is present. Please uninstall first."; exit 1; fi ; done
	@set -e; for lang in $(DESTDIR)/bin/nssbackupd $(DESTDIR)/../bin/nssbackupd; do echo "	checking: $$lang"; if [ -e $$lang ]; then echo "Another installation of nssbackup is present. Please uninstall first."; exit 1; fi ; done

install: check install-package install-po install-help install-bin install-data
	chmod +x $(libdir)/multipleTarScript
	chmod +x $(libdir)/sbackup-launch
	chmod +x $(libdir)/sbackup-dbusservice
	chmod +x $(libdir)/sbackup-indicator
	chmod +x $(libdir)/sbackup-progress
	chmod +x $(libdir)/sbackup-terminate
	chmod +x $(libdir)/sbackup-run
	chmod +x $(libdir)/sbackup-config-gtk
	chmod +x $(libdir)/sbackup-restore-gtk
	chmod +x $(libdir)/sbackup-upgrade-backups
	chmod +x $(libdir)/sbackupconfig.py

# application's binaries
install-bin:
	install -d $(bindir) $(sbindir)
	ln -sf ../share/sbackup/sbackup-run $(bindir)/sbackup
	ln -sf ../share/sbackup/sbackup-config-gtk $(bindir)/sbackup-config-gtk
	ln -sf ../share/sbackup/sbackup-restore-gtk $(bindir)/sbackup-restore-gtk
	ln -sf ../share/sbackup/sbackup-upgrade-backups $(bindir)/sbackup-upgrade-backups
	ln -sf ../share/sbackup/sbackupconfig.py $(sbindir)/sbackupconfig

# python package
install-package:
	$(PYTHON) setup.py install ${SETUP.PY_OPTS} --prefix=$(PREFIX)

# localization
install-po:
	set -e; for lang in $(PO); do install -d $(langdir)/$$lang/LC_MESSAGES/ ; done
	set -e; for lang in $(PO); do install -m 644 po/$$lang/LC_MESSAGES/* $(langdir)/$$lang/LC_MESSAGES/ ; done

# help/manual
install-help:
	install -d $(helpdir)
	set -e; for lang in $(HELPLANG); do \
	install -d $(helpdir)/$$lang/; \
	install -d $(helpdir)/$$lang/figures; \
	install -m 644 help/$$lang/*.page $(helpdir)/$$lang/; \
	install -m 644 help/$$lang/*.xml $(helpdir)/$$lang/; \
	install -m 644 help/$$lang/figures/*.png $(helpdir)/$$lang/figures; \
	done

# additional data/configuration
install-data: install-icons install-dbus install-gconf
	@if test "$(DISABLE_MAKEFILE_DESKTOP_DATABASE_RELOAD)" = ""; then \
	update-desktop-database; fi

install-icons:
	install -d $(icondir)/hicolor/24x24/apps/ $(icondir)/ubuntu-mono-light/apps/24/ $(icondir)/ubuntu-mono-dark/apps/24/
	set -e; for icon in $(iconslst); do install -m 644 data/icons/hicolor/24x24/$$icon $(icondir)/hicolor/24x24/apps/ ; done
	set -e; for icon in $(iconslst); do install -m 644 data/icons/ubuntu-mono-light/24/$$icon $(icondir)/ubuntu-mono-light/apps/24/ ; done
	set -e; for icon in $(iconslst); do install -m 644 data/icons/ubuntu-mono-dark/24/$$icon $(icondir)/ubuntu-mono-dark/apps/24/ ; done
	$(gtk_update_icon_cache)

install-dbus:
	install -d $(dbus_system_conf_dir)
	install -m 644 data/$(dbus_system_conf_file) $(dbus_system_conf_dir)
	@if test "$(DISABLE_MAKEFILE_DBUS_RELOAD)" = ""; then \
	if [ -x $(servicetool) ]; then \
	$(servicetool) dbus force-reload; \
	else if [ -r /etc/init.d/dbus ]; then \
	invoke-rc.d dbus force-reload; fi; fi; \
	fi

install-gconf:
	install -d $(gconf_schema_file_dir)
	install -m 644 data/$(gconf_schema_file) $(gconf_schema_file_dir)
	@if test "$(GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL)" = ""; then \
	gconf-schemas --register $(gconf_schema_file_dir)/$(gconf_schema_file); \
	fi


# targets for un-installation
uninstall: uninstall-package uninstall-bin uninstall-data uninstall-help clean-data

uninstall-bin:
	rm -f $(bindir)/sbackup
	rm -f $(bindir)/sbackup-config-gtk
	rm -f $(bindir)/sbackup-restore-gtk
	rm -f $(bindir)/sbackup-upgrade-backups
	rm -f $(sbindir)/sbackupconfig

uninstall-package:
	rm -rf $(libdir)

uninstall-data: uninstall-icons uninstall-dbus uninstall-gconf
	rm -f $(datadir)/pixmaps/sbackup-restore.png
	rm -f $(datadir)/pixmaps/sbackup-conf.png
	rm -f $(datadir)/pixmaps/sbackup.png
	rm -f $(datadir)/pixmaps/sbackup32x32.png
	rm -f $(datadir)/applications/sbackup-config*.desktop
	rm -f $(datadir)/applications/sbackup-restore*.desktop
	rm -rf $(datadir)/doc/sbackup
	set -e; find $(langdir) -name sbackup.mo -exec rm -f '{}' \;

uninstall-icons:
	set -e; for icon in $(iconslst); do rm -f $(icondir)/hicolor/24x24/apps/$$icon ; done
	set -e; for icon in $(iconslst); do rm -f $(icondir)/ubuntu-mono-light/apps/24/$$icon ; done
	set -e; for icon in $(iconslst); do rm -f $(icondir)/ubuntu-mono-dark/apps/24/$$icon ; done
	$(gtk_update_icon_cache)

uninstall-dbus:
	rm -f $(dbus_system_conf_dir)/$(dbus_system_conf_file)

#FIXME: treat gconf schema file as proper conffile?
uninstall-gconf:
	@if test "$(GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL)" = ""; then \
	if test -r "$(gconf_schema_file_dir)/$(gconf_schema_file)"; then \
	gconf-schemas --unregister $(gconf_schema_file_dir)/$(gconf_schema_file); fi; \
	fi
	rm -f $(gconf_schema_file_dir)/$(gconf_schema_file)


uninstall-help:
	rm -rf $(helpdir)

clean-data: clean-crondata clean-tmpdata

# remove script/symlinks from cron directory
clean-crondata:
	@if test "$(DISABLE_MAKEFILE_CLEAN_DATA)" = ""; then \
	rm -f /etc/cron.d/sbackup; \
	rm -f /etc/cron.hourly/sbackup; \
	rm -f /etc/cron.daily/sbackup; \
	rm -f /etc/cron.weekly/sbackup; \
	rm -f /etc/cron.monthly/sbackup; fi

clean-tmpdata:
	@if test "$(DISABLE_MAKEFILE_CLEAN_DATA)" = ""; then \
	rm -rf /var/log/sbackup; \
	rm -f /var/log/sbackup-*.log; \
	rm -f /var/log/sbackup-*.log.*.gz; \
	rm -rf /tmp/sbackup; fi

purge-user-config:
	rm -f /etc/sbackup.conf
	rm -rf /etc/sbackup.d


reinstall: uninstall install


# clean source code directory
clean:
	set -e; find . -name '*.py[co]' -exec rm -f '{}' \;
	set -e; find . -name '*~' -exec rm -f '{}' \;
	set -e; find . -name '*.bak' -exec rm -f '{}' \;
	rm -rf build dist setup.py
	rm -f data/desktop/sbackup-config*.desktop
	rm -f data/desktop/sbackup-restore*.desktop
	rm -f src/sbackup/resources
	rm -f src/sbackup/metainfo
	rm -rf src/sbackup.egg-info
	set -e; for lang in $(PO); do rm -rf po/$$lang ; done

# Purpose of this target is to print some informational data
show-infos:
	@echo "Summary of parameters"
	@echo "  Metafile     : "$(METAFILE)
	@echo "  Version      : "$(VERSION)
	@echo "  Package name : "$(PKGNAME)
	@echo "  Python       : "$(PYTHON)
	@echo "  setup.py opts: "$(SETUP.PY_OPTS)
	@echo
	@echo "Directories"
	@echo "  PREFIX      : "$(PREFIX)
	@echo "  DESTDIR     : "$(DESTDIR)
	@echo "  datadir     : "$(datadir)
	@echo "  helpdir     : "$(helpdir)
	@echo "  langdir     : "$(langdir)
	@echo "  bindir      : "$(bindir)
	@echo "  sbindir     : "$(sbindir)