Switching to a more automatic route for things
[gc-dialer] / Makefile
1 PROJECT_NAME=dialcentral
2 SOURCE_PATH=src
3 SOURCE=$(shell find $(SOURCE_PATH) -iname *.py)
4 PROGRAM=$(SOURCE_PATH)/$(PROJECT_NAME).py
5 DATA_TYPES=*.ini *.map *.glade *.png
6 DATA=$(foreach type, $(DATA_TYPES), $(shell find $(SOURCE_PATH) -iname $(type)))
7 OBJ=$(SOURCE:.py=.pyc)
8 BUILD_PATH=./build/
9 TAG_FILE=~/.ctags/$(PROJECT_NAME).tags
10
11 DEBUGGER=winpdb
12 UNIT_TEST=nosetests --with-doctest -w .
13 STYLE_TEST=../../Python/tools/pep8.py --ignore=W191
14 LINT_RC=./support/pylint.rc
15 LINT=pylint --rcfile=$(LINT_RC)
16 PROFILE_GEN=python -m cProfile -o .profile
17 PROFILE_VIEW=python -m pstats .profile
18 CTAGS=ctags-exuberant
19
20 .PHONY: all run profile debug test lint tags package clean distclean
21
22 all: test package
23
24 run: $(SOURCE)
25         $(SOURCE_PATH)/dc_glade.py
26
27 profile: $(SOURCE)
28         $(PROFILE_GEN) $(PROGRAM)
29         $(PROFILE_VIEW)
30
31 debug: $(SOURCE)
32         $(DEBUGGER) $(PROGRAM)
33
34 test: $(SOURCE)
35         $(UNIT_TEST)
36
37 package:
38         rm -Rf $(BUILD_PATH)
39         mkdir $(BUILD_PATH)
40         cp $(SOURCE_PATH)/$(PROJECT_NAME).py  $(BUILD_PATH)
41         $(foreach file, $(DATA), cp $(file) $(BUILD_PATH)/$(subst /,-,$(file)) ; )
42         $(foreach file, $(SOURCE), cp $(file) $(BUILD_PATH)/$(subst /,-,$(file)) ; )
43         $(foreach file, $(OBJ), cp $(file) $(BUILD_PATH)/$(subst /,-,$(file)) ; )
44         cp support/$(PROJECT_NAME).desktop $(BUILD_PATH)
45         cp support/icons/hicolor/26x26/hildon/$(PROJECT_NAME).png $(BUILD_PATH)/26x26-$(PROJECT_NAME).png
46         cp support/icons/hicolor/64x64/hildon/$(PROJECT_NAME).png $(BUILD_PATH)/64x64-$(PROJECT_NAME).png
47         cp support/icons/hicolor/scalable/hildon/$(PROJECT_NAME).png $(BUILD_PATH)/scale-$(PROJECT_NAME).png
48         cp support/builddeb.py $(BUILD_PATH)
49
50 lint:
51         $(foreach file, $(SOURCE), $(LINT) $(file) ; )
52
53 tags: $(TAG_FILE) 
54
55 clean:
56         rm -Rf $(OBJ)
57         rm -Rf $(BUILD_PATH)
58
59 distclean:
60         rm -Rf $(OBJ)
61         rm -Rf $(BUILD_PATH)
62         rm -Rf $(TAG_FILE)
63         find $(SOURCE_PATH) -name "*.*~" | xargs rm -f
64         find $(SOURCE_PATH) -name "*.swp" | xargs rm -f
65         find $(SOURCE_PATH) -name "*.bak" | xargs rm -f
66         find $(SOURCE_PATH) -name ".*.swp" | xargs rm -f
67
68 $(TAG_FILE): $(SOURCE)
69         mkdir -p $(dir $(TAG_FILE))
70         $(CTAGS) -o $(TAG_FILE) $(SOURCE)
71
72 #Makefile Debugging
73 #Target to print any variable, can be added to the dependencies of any other target
74 #Userfule flags for make, -d, -p, -n
75 print-%: ; @$(error $* is $($*) ($(value $*)) (from $(origin $*)))