Removing svg in hopes of fixing icon issues
[gonvert] / Makefile
1 PROJECT_NAME=gonvert
2 PACKAGE_NAME=gonvert
3
4 SOURCE_PATH=$(PACKAGE_NAME)
5 SOURCE=$(shell find $(SOURCE_PATH) -iname "*.py")
6
7 PROGRAM=Gonvert
8 ICON_SIZES=26 32 48 80
9 ICONS=$(foreach size, $(ICON_SIZES), data/icons/$(size)/$(PROJECT_NAME).png)
10 PACKAGE_VARIANTS=fremantle harmattan ubuntu
11 DESKTOP_FILES=$(foreach variant, $(PACKAGE_VARIANTS), data/$(variant)/$(PROJECT_NAME).desktop)
12 SETUP_FILES=$(foreach variant, $(PACKAGE_VARIANTS), ./setup.$(variant).py)
13 DIST_BASE_PATH=./dist
14 DIST_PATHS=$(foreach variant, $(PACKAGE_VARIANTS), $(DIST_BASE_PATH)_$(variant)) $(DIST_BASE_PATH)_diablo
15
16 OBJ=$(SOURCE:.py=.pyc)
17 TAG_FILE=~/.ctags/$(PROJECT_NAME).tags
18 TODO_FILE=./TODO
19
20 DEBUGGER=winpdb
21 UNIT_TEST=nosetests --with-doctest -w .
22 SYNTAX_TEST=support/test_syntax.py
23 STYLE_TEST=../../Python/tools/pep8.py --ignore=W191,E501
24 LINT_RC=./support/pylint.rc
25 LINT=pylint --rcfile=$(LINT_RC)
26 PROFILE_GEN=python -m cProfile -o .profile
27 PROFILE_VIEW=python -m pstats .profile
28 TODO_FINDER=support/todo.py
29 CTAGS=ctags-exuberant
30
31
32 .PHONY: all run profile debug test build lint tags todo clean distclean
33
34 all: test
35
36 run: $(OBJ)
37         $(PROGRAM)
38
39 profile: $(OBJ)
40         $(PROFILE_GEN) $(PROGRAM)
41         $(PROFILE_VIEW)
42
43 debug: $(OBJ)
44         $(DEBUGGER) $(PROGRAM)
45
46 test: $(OBJ)
47         $(UNIT_TEST)
48
49 package: $(OBJ) $(ICONS) $(SETUP_FILES) $(DESKTOP_FILES)
50         rm -Rf $(DIST_BASE_PATH)_*/*
51         ./setup.fremantle.py sdist_diablo \
52                 -d $(DIST_BASE_PATH)_diablo \
53                 --install-purelib=/usr/lib/python2.5/site-packages
54         ./setup.fremantle.py sdist_fremantle \
55                 -d $(DIST_BASE_PATH)_fremantle \
56                 --install-purelib=/usr/lib/python2.5/site-packages
57         ./setup.harmattan.py sdist_harmattan \
58                 -d $(DIST_BASE_PATH)_harmattan
59                 --install-purelib=/usr/lib/python2.6/dist-packages
60         ./setup.ubuntu.py sdist_ubuntu \
61                 -d $(DIST_BASE_PATH)_ubuntu
62         mkdir $(DIST_BASE_PATH)_ubuntu/build
63         cd $(DIST_BASE_PATH)_ubuntu/build ; tar -zxvf ../*.tar.gz
64         cd $(DIST_BASE_PATH)_ubuntu/build ; dpkg-buildpackage -tc -rfakeroot -us -uc
65
66 upload:
67         dput diablo-extras-builder $(DIST_BASE_PATH)_diablo/$(PROJECT_NAME)*.changes
68         dput fremantle-extras-builder $(DIST_BASE_PATH)_fremantle/$(PROJECT_NAME)*.changes
69         cp $(DIST_BASE_PATH)_ubuntu/*.deb www/$(PROJECT_NAME).deb
70
71 lint: $(OBJ)
72         $(foreach file, $(SOURCE), $(LINT) $(file) ; )
73
74 tags: $(TAG_FILE) 
75
76 todo: $(TODO_FILE)
77
78 clean:
79         rm -Rf $(OBJ)
80         rm -Rf $(TODO_FILE)
81         rm -f $(ICONS) $(SETUP_FILES) $(DESKTOP_FILES)
82         rm -Rf $(DIST_PATHS)
83
84 distclean: clean
85         find $(SOURCE_PATH) -name "*.*~" | xargs rm -f
86         find $(SOURCE_PATH) -name "*.swp" | xargs rm -f
87         find $(SOURCE_PATH) -name "*.bak" | xargs rm -f
88         find $(SOURCE_PATH) -name ".*.swp" | xargs rm -f
89
90
91 $(SETUP_FILES): VARIANT=$(word 2, $(subst ., ,$@))
92
93 setup.fremantle.py: setup.py src/constants.py
94         cog.py -c \
95                 -D DESKTOP_FILE_PATH=/usr/share/applications/hildon \
96                 -D INPUT_DESKTOP_FILE=data/$(VARIANT)/$(PROJECT_NAME).desktop \
97                 -D ICON_CATEGORY=hildon \
98                 -D ICON_SIZES=26,32,48 \
99                 -o $@ $<
100         chmod +x $@
101
102 setup.harmattan.py: setup.py src/constants.py
103         cog.py -c \
104                 -D DESKTOP_FILE_PATH=/usr/share/applications \
105                 -D INPUT_DESKTOP_FILE=data/$(VARIANT)/$(PROJECT_NAME).desktop \
106                 -D ICON_CATEGORY=hildon \
107                 -D ICON_SIZES=32,80 \
108                 -o $@ $<
109         chmod +x $@
110
111 setup.ubuntu.py: setup.py src/constants.py
112         cog.py -c \
113                 -D DESKTOP_FILE_PATH=/usr/share/applications \
114                 -D INPUT_DESKTOP_FILE=data/$(VARIANT)/$(PROJECT_NAME).desktop \
115                 -D ICON_CATEGORY=apps \
116                 -D ICON_SIZES=32,48 \
117                 -o $@ $<
118         chmod +x $@
119
120 $(ICONS): SIZE=$(word 3, $(subst /, ,$@))
121 $(ICONS): data/$(PROJECT_NAME).png support/scale.py
122         mkdir -p $(dir $@)
123         support/scale.py --input $< --output $@ --size $(SIZE)
124
125 $(DESKTOP_FILES): VARIANT=$(word 2, $(subst /, ,$@))
126 $(DESKTOP_FILES): data/template.desktop
127         mkdir -p $(dir $@)
128         cog.py -d \
129                 -D VARIANT=$(VARIANT) \
130                 -D PROGRAM=$(PROGRAM) \
131                 -o $@ $<
132
133
134 $(TAG_FILE): $(OBJ)
135         mkdir -p $(dir $(TAG_FILE))
136         $(CTAGS) -o $(TAG_FILE) $(SOURCE)
137
138 $(TODO_FILE): $(SOURCE)
139         @- $(TODO_FINDER) $(SOURCE) > $(TODO_FILE)
140
141 %.pyc: %.py
142         $(SYNTAX_TEST) $<
143
144 #Makefile Debugging
145 #Target to print any variable, can be added to the dependencies of any other target
146 #Userfule flags for make, -d, -p, -n
147 print-%: ; @$(error $* is $($*) ($(value $*)) (from $(origin $*)))