Fixing the advertised license
[quicknote] / Makefile
1 PROJECT_NAME=quicknote
2 PROJECT_VERSION=0.7.8
3 SOURCE_PATH=src
4 SOURCE=$(shell find $(SOURCE_PATH) -iname "*.py")
5 LOCALE_PATH=locale
6 LOCALE_FILES=$(shell find $(LOCALE_PATH) -iname "*.mo")
7 PROGRAM=$(SOURCE_PATH)/$(PROJECT_NAME).py
8 OBJ=$(SOURCE:.py=.pyc)
9 BUILD_PATH=./builddeb/
10
11 TEXT_DOMAIN=$(PROJECT_NAME)
12 POTFILES=$(wildcard src/quicknoteclasses/*.py)
13 TAG_FILE=~/.ctags/$(PROJECT_NAME).tags
14 TODO_FILE=./TODO
15
16 DEBUGGER=winpdb
17 UNIT_TEST=nosetests --with-doctest -w .
18 SYNTAX_TEST=support/test_syntax.py
19 STYLE_TEST=../../Python/tools/pep8.py --ignore=W191,E501
20 LINT_RC=./support/pylint.rc
21 LINT=pylint --rcfile=$(LINT_RC)
22 PROFILE_GEN=python -m cProfile -o .profile
23 PROFILE_VIEW=python -m pstats .profile
24 TODO_FINDER=support/todo.py
25 CTAGS=ctags-exuberant
26
27 .PHONY: all run profile debug test lint tags todo clean distclean install update_po build_mo
28
29 all: test
30
31 run: $(OBJ)
32         $(PROGRAM)
33
34 profile: $(OBJ)
35         $(PROFILE_GEN) $(PROGRAM)
36         $(PROFILE_VIEW)
37
38 debug: $(OBJ)
39         $(DEBUGGER) $(PROGRAM)
40
41 test: $(OBJ)
42         $(UNIT_TEST)
43
44 package: clean $(OBJ) all
45         dpkg-buildpackage -rfakeroot 
46         dpkg -i ../$(PROJECT_NAME)_$(PROJECT_VERSION)_all.deb
47
48 update_po: po/templates.pot
49         @for lang in $(basename $(notdir $(wildcard po/*.po))); do \
50                 msgmerge -U --strict --no-wrap po/$$lang.po po/templates.pot; \
51         done
52
53 po/templates.pot: $(POTFILES)
54         xgettext --language=Python --strict --no-wrap --output=$@ $(POTFILES)
55
56 build_mo:
57         @for lang in $(basename $(notdir $(wildcard po/*.po))); do \
58                 mkdir -p locale/$$lang/LC_MESSAGES; \
59                 msgfmt --statistics -c -o locale/$$lang/LC_MESSAGES/$(TEXT_DOMAIN).mo po/$$lang.po; \
60         done
61
62 build: $(OBJ) build_mo
63         rm -Rf $(BUILD_PATH)
64
65         mkdir -p $(BUILD_PATH)/generic
66         cp $(SOURCE_PATH)/constants.py $(BUILD_PATH)/generic
67         cp $(PROGRAM)  $(BUILD_PATH)/generic
68         $(foreach file, $(DATA), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
69         $(foreach file, $(SOURCE), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
70         #$(foreach file, $(OBJ), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
71         $(foreach file, $(LOCALE_FILES), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
72         cp data/$(PROJECT_NAME).desktop $(BUILD_PATH)/generic
73         cp data/$(PROJECT_NAME).service $(BUILD_PATH)/generic
74         cp data/low/$(PROJECT_NAME).png $(BUILD_PATH)/generic/26x26-$(PROJECT_NAME).png
75         cp data/40/$(PROJECT_NAME).png $(BUILD_PATH)/generic/40x40-$(PROJECT_NAME).png
76         cp data/48/$(PROJECT_NAME).png $(BUILD_PATH)/generic/48x48-$(PROJECT_NAME).png
77         cp data/scale/$(PROJECT_NAME).png $(BUILD_PATH)/generic/scale-$(PROJECT_NAME).png
78         cp support/builddeb.py $(BUILD_PATH)/generic
79         cp support/py2deb.py $(BUILD_PATH)/generic
80         cp support/fake_py2deb.py $(BUILD_PATH)/generic
81
82         mkdir -p $(BUILD_PATH)/chinook
83         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/chinook
84         cd $(BUILD_PATH)/chinook ; python builddeb.py chinook
85         mkdir -p $(BUILD_PATH)/diablo
86         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/diablo
87         cd $(BUILD_PATH)/diablo ; python builddeb.py diablo
88         mkdir -p $(BUILD_PATH)/fremantle
89         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/fremantle
90         cd $(BUILD_PATH)/fremantle ; python builddeb.py fremantle
91         mkdir -p $(BUILD_PATH)/mer
92         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/mer
93         cd $(BUILD_PATH)/mer ; python builddeb.py mer
94
95 lint: $(OBJ)
96         $(foreach file, $(SOURCE), $(LINT) $(file) ; )
97
98 tags: $(TAG_FILE) 
99
100 todo: $(TODO_FILE)
101
102 clean:
103         rm -rf ./locale
104         rm -Rf $(OBJ)
105         rm -Rf $(BUILD_PATH)
106         rm -Rf $(TODO_FILE)
107
108 distclean:
109         rm -Rf $(OBJ)
110         rm -Rf $(BUILD_PATH)
111         rm -Rf $(TAG_FILE)
112         find $(SOURCE_PATH) -name "*.*~" | xargs rm -f
113         find $(SOURCE_PATH) -name "*.swp" | xargs rm -f
114         find $(SOURCE_PATH) -name "*.bak" | xargs rm -f
115         find $(SOURCE_PATH) -name ".*.swp" | xargs rm -f
116
117 $(TAG_FILE): $(OBJ)
118         mkdir -p $(dir $(TAG_FILE))
119         $(CTAGS) -o $(TAG_FILE) $(SOURCE)
120
121 $(TODO_FILE): $(SOURCE)
122         @- $(TODO_FINDER) $(SOURCE) > $(TODO_FILE)
123
124 %.pyc: %.py
125         $(SYNTAX_TEST) $<
126
127 #Makefile Debugging
128 #Target to print any variable, can be added to the dependencies of any other target
129 #Userfule flags for make, -d, -p, -n
130 print-%: ; @$(error $* is $($*) ($(value $*)) (from $(origin $*)))