be10451cc932f09011bc6542ef7efdac316f6c24
[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 upload: build
96         dput fremantle-extras-builder $(BUILD_PATH)/fremantle/$(PROJECT_NAME)*.changes
97         dput diablo-extras-builder $(BUILD_PATH)/diablo/$(PROJECT_NAME)*.changes
98         dput chinook-extras-builder $(BUILD_PATH)/chinook/$(PROJECT_NAME)*.changes
99
100 lint: $(OBJ)
101         $(foreach file, $(SOURCE), $(LINT) $(file) ; )
102
103 tags: $(TAG_FILE) 
104
105 todo: $(TODO_FILE)
106
107 clean:
108         rm -rf ./locale
109         rm -Rf $(OBJ)
110         rm -Rf $(BUILD_PATH)
111         rm -Rf $(TODO_FILE)
112
113 distclean:
114         rm -Rf $(OBJ)
115         rm -Rf $(BUILD_PATH)
116         rm -Rf $(TAG_FILE)
117         find $(SOURCE_PATH) -name "*.*~" | xargs rm -f
118         find $(SOURCE_PATH) -name "*.swp" | xargs rm -f
119         find $(SOURCE_PATH) -name "*.bak" | xargs rm -f
120         find $(SOURCE_PATH) -name ".*.swp" | xargs rm -f
121
122 $(TAG_FILE): $(OBJ)
123         mkdir -p $(dir $(TAG_FILE))
124         $(CTAGS) -o $(TAG_FILE) $(SOURCE)
125
126 $(TODO_FILE): $(SOURCE)
127         @- $(TODO_FINDER) $(SOURCE) > $(TODO_FILE)
128
129 %.pyc: %.py
130         $(SYNTAX_TEST) $<
131
132 #Makefile Debugging
133 #Target to print any variable, can be added to the dependencies of any other target
134 #Userfule flags for make, -d, -p, -n
135 print-%: ; @$(error $* is $($*) ($(value $*)) (from $(origin $*)))