SendTo automatic rename filename (#1620)
[gpodder.git] / makefile
blob4af02b200a0b40a99c6dd58bfe2b85f4fdbb9846
2 # gPodder - A media aggregator and podcast client
3 # Copyright (c) 2005-2018 The gPodder Team
5 # gPodder is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # gPodder is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 ##########################################################################
22 BINFILE = bin/gpodder
23 MANPAGES = share/man/man1/gpodder.1 share/man/man1/gpo.1
25 GPODDER_SERVICE_FILE=share/dbus-1/services/org.gpodder.service
26 GPODDER_SERVICE_FILE_IN=$(addsuffix .in,$(GPODDER_SERVICE_FILE))
28 DESKTOP_FILES_IN=$(wildcard share/applications/*.desktop.in)
29 DESKTOP_FILES_IN_H=$(patsubst %.desktop.in,%.desktop.in.h,$(DESKTOP_FILES_IN))
30 DESKTOP_FILES=$(patsubst %.desktop.in,%.desktop,$(DESKTOP_FILES_IN))
32 MESSAGES = po/messages.pot
33 POFILES = $(wildcard po/*.po)
34 LOCALEDIR = share/locale
35 MOFILES = $(patsubst po/%.po,$(LOCALEDIR)/%/LC_MESSAGES/gpodder.mo, $(POFILES))
37 UIFILES=$(wildcard share/gpodder/ui/gtk/*.ui)
38 UIFILES_H=$(subst .ui,.ui.h,$(UIFILES))
39 GETTEXT_SOURCE=$(wildcard src/gpodder/*.py \
40 src/gpodder/gtkui/*.py \
41 src/gpodder/gtkui/interface/*.py \
42 src/gpodder/gtkui/desktop/*.py \
43 src/gpodder/plugins/*.py \
44 share/gpodder/extensions/*.py)
46 GETTEXT_SOURCE += $(UIFILES_H)
47 GETTEXT_SOURCE += $(wildcard bin/*[^~])
48 GETTEXT_SOURCE += $(DESKTOP_FILES_IN_H)
50 DESTDIR ?= /
51 PREFIX ?= /usr
53 PYTHON ?= python3
54 HELP2MAN ?= help2man
56 PYTEST ?= $(shell command -v pytest || command -v pytest-3)
58 ##########################################################################
60 help:
61 @cat tools/make-help.txt
63 ##########################################################################
65 unittest:
66 LC_ALL=C PYTHONPATH=src/ $(PYTEST) --ignore=tests --ignore=src/gpodder/utilwin32ctypes.py --doctest-modules src/gpodder/util.py src/gpodder/jsonconfig.py
67 LC_ALL=C PYTHONPATH=src/ $(PYTEST) tests --ignore=src/gpodder/utilwin32ctypes.py --ignore=src/mygpoclient --cov=gpodder
69 ISORTOPTS := -c share src/gpodder tools bin/* *.py
70 lint:
71 pycodestyle --version
72 pycodestyle share src/gpodder tools bin/* *.py
74 isort --version
75 isort -q $(ISORTOPTS) || isort --df $(ISORTOPTS)
76 codespell --quiet-level 3 --skip "./.git,*.po,.mypy_cache,./share/applications/gpodder.desktop"
78 release: distclean
79 $(PYTHON) setup.py sdist
81 releasetest: unittest $(DESKTOP_FILES) $(POFILES)
82 for f in $(DESKTOP_FILES); do desktop-file-validate $$f || exit 1; done
83 for f in $(POFILES); do msgfmt --check $$f || exit 1; done
85 $(GPODDER_SERVICE_FILE): $(GPODDER_SERVICE_FILE_IN)
86 sed -e 's#__PREFIX__#$(PREFIX)#' $< >$@
88 %.desktop: %.desktop.in $(POFILES)
89 sed -e 's#__PREFIX__#$(PREFIX)#' $< >$@.tmp
90 intltool-merge -d -u po $@.tmp $@
91 rm -f $@.tmp
93 %.desktop.in.h: %.desktop.in
94 intltool-extract --quiet --type=gettext/ini $<
96 build: messages $(GPODDER_SERVICE_FILE) $(DESKTOP_FILES)
98 install: build
99 $(PYTHON) setup.py install --root=$(DESTDIR) --prefix=$(PREFIX) --optimize=1
101 install-win: build
102 $(PYTHON) setup.py install
104 ##########################################################################
105 ifdef VERSION
106 revbump:
107 LC_ALL=C sed -i "s/\(__version__\s*=\s*'\).*'/\1$(VERSION)'/" src/gpodder/__init__.py
108 LC_ALL=C sed -i "s/\(__date__\s*=\s*'\).*'/\1$(shell date "+%Y-%m-%d")'/" src/gpodder/__init__.py
109 LC_ALL=C sed -i "s/\(__copyright__\s*=.*2005-\)[0-9]*\(.*\)/\1$(shell date "+%Y")\2/" src/gpodder/__init__.py
110 $(MAKE) messages manpages
111 else
112 revbump:
113 @echo "Usage: make revbump VERSION=x.y.z"
114 endif
115 ##########################################################################
117 manpages: $(MANPAGES)
119 share/man/man1/gpodder.1: src/gpodder/__init__.py $(BINFILE)
120 LC_ALL=C $(HELP2MAN) --name="$(shell $(PYTHON) setup.py --description)" -N $(BINFILE) >$@
122 share/man/man1/gpo.1: src/gpodder/__init__.py
123 sed -i 's/^\.TH.*/.TH GPO "1" "$(shell LANG=en date "+%B %Y")" "gpodder $(shell $(PYTHON) setup.py --version)" "User Commands"/' $@
125 ##########################################################################
127 messages: $(MOFILES)
129 %.po: $(MESSAGES)
130 msgmerge --previous --silent $@ $< --output-file=$@
131 msgattrib --set-obsolete --ignore-file=$< -o $@ $@
132 msgattrib --no-obsolete -o $@ $@
134 $(LOCALEDIR)/%/LC_MESSAGES/gpodder.mo: po/%.po
135 @mkdir -p $(@D)
136 msgfmt $< -o $@
138 %.ui.h: %.ui
139 intltool-extract --quiet --type=gettext/glade $<
141 $(MESSAGES): $(GETTEXT_SOURCE)
142 xgettext --from-code=utf-8 -LPython -k_:1 -kN_:1 -kN_:1,2 -kn_:1,2 -o $(MESSAGES) $^
144 messages-force:
145 xgettext --from-code=utf-8 -LPython -k_:1 -kN_:1 -kN_:1,2 -kn_:1,2 -o $(MESSAGES) $(GETTEXT_SOURCE)
147 ##########################################################################
149 # This only works in a Git working commit, and assumes that the local Git
150 # HEAD has already been pushed to the main repository. It's mainly useful
151 # for the gPodder maintainer to quickly generate a commit link that can be
152 # posted online in bug trackers and mailing lists.
154 headlink:
155 @echo http://gpodder.org/commit/`git show-ref HEAD | head -c8`
157 ##########################################################################
159 clean:
160 $(PYTHON) setup.py clean
161 find src/ '(' -name '*.pyc' -o -name '*.pyo' ')' -exec rm '{}' +
162 find src/ -type d -name '__pycache__' -exec rm -r '{}' +
163 find share/gpodder/ui/ -name '*.ui.h' -exec rm '{}' +
164 rm -f MANIFEST .coverage messages.mo po/*.mo
165 rm -f $(GPODDER_SERVICE_FILE)
166 rm -f $(DESKTOP_FILES) $(DESKTOP_FILES_IN_H)
167 rm -rf build $(LOCALEDIR)
169 distclean: clean
170 rm -rf dist
172 ##########################################################################
174 .PHONY: help unittest release releasetest build install manpages clean distclean messages headlink lint revbump
176 ##########################################################################