Pulling in changes from skeleton
[multilist] / Makefile
1 PROJECT_NAME=multilist
2 PROJECT_VERSION=0.3.1
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 update_po: po/templates.pot
45         @for lang in $(basename $(notdir $(wildcard po/*.po))); do \
46                 msgmerge -U --strict --no-wrap po/$$lang.po po/templates.pot; \
47         done
48
49 po/templates.pot: $(POTFILES)
50         xgettext --language=Python --strict --no-wrap --output=$@ $(POTFILES)
51
52 build_mo:
53         @for lang in $(basename $(notdir $(wildcard po/*.po))); do \
54                 mkdir -p locale/$$lang/LC_MESSAGES; \
55                 msgfmt --statistics -c -o locale/$$lang/LC_MESSAGES/$(TEXT_DOMAIN).mo po/$$lang.po; \
56         done
57
58 package: $(OBJ) build_mo
59         rm -Rf $(BUILD_PATH)
60
61         mkdir -p $(BUILD_PATH)/generic
62         cp $(SOURCE_PATH)/constants.py $(BUILD_PATH)/generic
63         cp $(PROGRAM)  $(BUILD_PATH)/generic
64         $(foreach file, $(DATA), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
65         $(foreach file, $(SOURCE), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
66         #$(foreach file, $(OBJ), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
67         $(foreach file, $(LOCALE_FILES), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
68         cp data/$(PROJECT_NAME).desktop $(BUILD_PATH)/generic
69         cp data/icons/26_$(PROJECT_NAME).png $(BUILD_PATH)/generic/26x26-$(PROJECT_NAME).png
70         cp data/icons/32_$(PROJECT_NAME).png $(BUILD_PATH)/generic/32x32-$(PROJECT_NAME).png
71         cp data/icons/48_$(PROJECT_NAME).png $(BUILD_PATH)/generic/48x48-$(PROJECT_NAME).png
72         cp support/builddeb.py $(BUILD_PATH)/generic
73         cp support/py2deb.py $(BUILD_PATH)/generic
74         cp support/fake_py2deb.py $(BUILD_PATH)/generic
75
76         mkdir -p $(BUILD_PATH)/diablo
77         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/diablo
78         cd $(BUILD_PATH)/diablo ; python builddeb.py diablo
79         mkdir -p $(BUILD_PATH)/fremantle
80         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/fremantle
81         cd $(BUILD_PATH)/fremantle ; python builddeb.py fremantle
82         mkdir -p $(BUILD_PATH)/debian
83         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/debian
84         cd $(BUILD_PATH)/debian ; python builddeb.py debian
85
86 upload:
87         dput fremantle-extras-builder $(BUILD_PATH)/fremantle/$(PROJECT_NAME)*.changes
88         dput diablo-extras-builder $(BUILD_PATH)/diablo/$(PROJECT_NAME)*.changes
89         cp $(BUILD_PATH)/debian/*.deb www/$(PROJECT_NAME).deb
90
91 lint: $(OBJ)
92         $(foreach file, $(SOURCE), $(LINT) $(file) ; )
93
94 tags: $(TAG_FILE) 
95
96 todo: $(TODO_FILE)
97
98 clean:
99         rm -rf ./locale
100         rm -Rf $(OBJ)
101         rm -Rf $(BUILD_PATH)
102         rm -Rf $(TODO_FILE)
103
104 distclean:
105         rm -Rf $(OBJ)
106         rm -Rf $(BUILD_PATH)
107         rm -Rf $(TAG_FILE)
108         find $(SOURCE_PATH) -name "*.*~" | xargs rm -f
109         find $(SOURCE_PATH) -name "*.swp" | xargs rm -f
110         find $(SOURCE_PATH) -name "*.bak" | xargs rm -f
111         find $(SOURCE_PATH) -name ".*.swp" | xargs rm -f
112
113 $(TAG_FILE): $(OBJ)
114         mkdir -p $(dir $(TAG_FILE))
115         $(CTAGS) -o $(TAG_FILE) $(SOURCE)
116
117 $(TODO_FILE): $(SOURCE)
118         @- $(TODO_FINDER) $(SOURCE) > $(TODO_FILE)
119
120 %.pyc: %.py
121         $(SYNTAX_TEST) $<
122
123 #Makefile Debugging
124 #Target to print any variable, can be added to the dependencies of any other target
125 #Userfule flags for make, -d, -p, -n
126 print-%: ; @$(error $* is $($*) ($(value $*)) (from $(origin $*)))