Initial packaging configured
[watersofshiloah] / Makefile
1 PROJECT_NAME=MormonChannel
2 SOURCE_PATH=src
3 SOURCE=$(shell find $(SOURCE_PATH) -iname "*.py")
4 PROGRAM=$(SOURCE_PATH)/mormonchannel_gtk.py
5 DATA_PATH=data
6 DATA_TYPES=*.ini *.map *.glade *.png
7 DATA=$(foreach type, $(DATA_TYPES), $(shell find $(DATA_PATH) -iname "$(type)")) data/COPYING
8 OBJ=$(SOURCE:.py=.pyc)
9 BUILD_PATH=./build
10 TAG_FILE=~/.ctags/$(PROJECT_NAME).tags
11 TODO_FILE=./TODO
12
13 DEBUGGER=winpdb
14 UNIT_TEST=nosetests --with-doctest -w .
15 SYNTAX_TEST=support/test_syntax.py
16 STYLE_TEST=../../Python/tools/pep8.py --ignore=W191,E501
17 LINT_RC=./support/pylint.rc
18 LINT=pylint --rcfile=$(LINT_RC)
19 PROFILE_GEN=python -m cProfile -o .profile
20 PROFILE_VIEW=python -m pstats .profile
21 TODO_FINDER=support/todo.py
22 CTAGS=ctags-exuberant
23
24 .PHONY: all run profile debug test build lint tags todo clean distclean
25
26 all: test
27
28 run: $(OBJ)
29         $(PROGRAM)
30
31 profile: $(OBJ)
32         $(PROFILE_GEN) $(PROGRAM)
33         $(PROFILE_VIEW)
34
35 debug: $(OBJ)
36         $(DEBUGGER) $(PROGRAM)
37
38 test: $(OBJ)
39         $(UNIT_TEST)
40
41 package: $(OBJ)
42         rm -Rf $(BUILD_PATH)
43
44         mkdir -p $(BUILD_PATH)/generic
45         cp $(SOURCE_PATH)/constants.py  $(BUILD_PATH)/generic
46         cp $(SOURCE_PATH)/$(PROJECT_NAME).py  $(BUILD_PATH)/generic
47         $(foreach file, $(DATA), cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
48         $(foreach file, $(SOURCE) $(SOURCE_PATH)/LICENSE, cp $(file) $(BUILD_PATH)/generic/$(subst /,-,$(file)) ; )
49         cp support/$(PROJECT_NAME).desktop $(BUILD_PATH)/generic
50         cp data/icon.png $(BUILD_PATH)/generic/48x48-$(PROJECT_NAME).png
51         cp support/builddeb.py $(BUILD_PATH)/generic
52         cp support/py2deb.py $(BUILD_PATH)/generic
53         cp support/fake_py2deb.py $(BUILD_PATH)/generic
54
55         mkdir -p $(BUILD_PATH)/diablo
56         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/diablo
57         cd $(BUILD_PATH)/diablo ; python builddeb.py diablo
58         mkdir -p $(BUILD_PATH)/fremantle
59         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/fremantle
60         cd $(BUILD_PATH)/fremantle ; python builddeb.py fremantle
61         mkdir -p $(BUILD_PATH)/debian
62         cp -R $(BUILD_PATH)/generic/* $(BUILD_PATH)/debian
63         cd $(BUILD_PATH)/debian ; python builddeb.py debian
64
65 upload:
66         dput fremantle-extras-builder $(BUILD_PATH)/fremantle/$(PROJECT_NAME)*.changes
67         dput diablo-extras-builder $(BUILD_PATH)/diablo/$(PROJECT_NAME)*.changes
68         cp $(BUILD_PATH)/debian/*.deb ./www/$(PROJECT_NAME).deb
69
70 lint: $(OBJ)
71         $(foreach file, $(SOURCE), $(LINT) $(file) ; )
72
73 tags: $(TAG_FILE) 
74
75 todo: $(TODO_FILE)
76
77 clean:
78         rm -Rf $(OBJ)
79         rm -Rf $(BUILD_PATH)
80         rm -Rf $(TODO_FILE)
81
82 distclean:
83         rm -Rf $(OBJ)
84         rm -Rf $(BUILD_PATH)
85         rm -Rf $(TAG_FILE)
86         find $(SOURCE_PATH) -name "*.*~" | xargs rm -f
87         find $(SOURCE_PATH) -name "*.swp" | xargs rm -f
88         find $(SOURCE_PATH) -name "*.bak" | xargs rm -f
89         find $(SOURCE_PATH) -name ".*.swp" | xargs rm -f
90
91 $(TAG_FILE): $(OBJ)
92         mkdir -p $(dir $(TAG_FILE))
93         $(CTAGS) -o $(TAG_FILE) $(SOURCE)
94
95 $(TODO_FILE): $(SOURCE)
96         @- $(TODO_FINDER) $(SOURCE) > $(TODO_FILE)
97
98 %.pyc: %.py
99         $(SYNTAX_TEST) $<
100
101 #Makefile Debugging
102 #Target to print any variable, can be added to the dependencies of any other target
103 #Userfule flags for make, -d, -p, -n
104 print-%: ; @$(error $* is $($*) ($(value $*)) (from $(origin $*)))