Fix for py2.5
[gonvert] / Makefile
1 PROJECT_NAME=gonvert
2 PACKAGE_NAME=$(PROJECT_NAME)
3
4 SOURCE_PATH=$(PACKAGE_NAME)
5 SOURCE=$(shell find $(SOURCE_PATH) -iname "*.py")
6
7 PROGRAM=Gonvert
8 ICON_SIZES=26 32 48 64 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_prep: $(OBJ) $(ICONS) $(SETUP_FILES) $(DESKTOP_FILES)
50
51 package_diablo: _package_prep
52         rm -Rf $(DIST_BASE_PATH)_diablo/*
53         ./setup.fremantle.py sdist_diablo \
54                 -d $(DIST_BASE_PATH)_diablo \
55                 --install-purelib=/usr/lib/python2.5/site-packages
56 package_fremantle: _package_prep
57         rm -Rf $(DIST_BASE_PATH)_fremantle/*
58         ./setup.fremantle.py sdist_fremantle \
59                 -d $(DIST_BASE_PATH)_fremantle \
60                 --install-purelib=/usr/lib/python2.5/site-packages
61 package_harmattan: _package_prep
62         rm -Rf $(DIST_BASE_PATH)_harmattan/*
63         ./setup.harmattan.py sdist_harmattan \
64                 -d $(DIST_BASE_PATH)_harmattan \
65                 --install-purelib=/usr/lib/python2.6/dist-packages
66 package_ubuntu: _package_prep
67         rm -Rf $(DIST_BASE_PATH)_ubuntu/*
68         ./setup.ubuntu.py sdist_ubuntu \
69                 -d $(DIST_BASE_PATH)_ubuntu
70         mkdir $(DIST_BASE_PATH)_ubuntu/build
71         cd $(DIST_BASE_PATH)_ubuntu/build ; tar -zxvf ../*.tar.gz
72         cd $(DIST_BASE_PATH)_ubuntu/build ; dpkg-buildpackage -tc -rfakeroot -us -uc
73
74 package: package_diablo package_fremantle package_harmattan package_ubuntu
75
76 upload_diablo:
77         dput diablo-extras-builder $(DIST_BASE_PATH)_diablo/$(PROJECT_NAME)*.changes
78 upload_fremantle:
79         dput fremantle-extras-builder $(DIST_BASE_PATH)_fremantle/$(PROJECT_NAME)*.changes
80 upload_harmattan:
81         ./support/obs_upload.sh $(PROJECT_NAME) harmattan dist_harmattan
82 upload_ubuntu:
83         cp $(DIST_BASE_PATH)_ubuntu/*.deb www/$(PROJECT_NAME).deb
84
85 upload: upload_diablo upload_fremantle upload_harmattan upload_ubuntu
86
87 lint: $(OBJ)
88         $(foreach file, $(SOURCE), $(LINT) $(file) ; )
89
90 tags: $(TAG_FILE) 
91
92 todo: $(TODO_FILE)
93
94 clean:
95         rm -Rf $(OBJ)
96         rm -Rf $(TODO_FILE)
97         rm -f $(ICONS) $(SETUP_FILES) $(DESKTOP_FILES)
98         rm -Rf $(DIST_PATHS) ./build
99
100 distclean: clean
101         find $(SOURCE_PATH) -name "*.*~" | xargs rm -f
102         find $(SOURCE_PATH) -name "*.swp" | xargs rm -f
103         find $(SOURCE_PATH) -name "*.bak" | xargs rm -f
104         find $(SOURCE_PATH) -name ".*.swp" | xargs rm -f
105
106
107 $(SETUP_FILES): VARIANT=$(word 2, $(subst ., ,$@))
108
109 setup.fremantle.py: setup.py src/constants.py
110         cog.py -c \
111                 -D DESKTOP_FILE_PATH=/usr/share/applications/hildon \
112                 -D INPUT_DESKTOP_FILE=data/$(VARIANT)/$(PROJECT_NAME).desktop \
113                 -D ICON_CATEGORY=hildon \
114                 -D ICON_SIZES=26,32,48 \
115                 -o $@ $<
116         chmod +x $@
117
118 setup.harmattan.py: setup.py src/constants.py
119         cog.py -c \
120                 -D DESKTOP_FILE_PATH=/usr/share/applications \
121                 -D INPUT_DESKTOP_FILE=data/$(VARIANT)/$(PROJECT_NAME).desktop \
122                 -D ICON_CATEGORY=apps \
123                 -D ICON_SIZES=64,80 \
124                 -o $@ $<
125         chmod +x $@
126
127 setup.ubuntu.py: setup.py src/constants.py
128         cog.py -c \
129                 -D DESKTOP_FILE_PATH=/usr/share/applications \
130                 -D INPUT_DESKTOP_FILE=data/$(VARIANT)/$(PROJECT_NAME).desktop \
131                 -D ICON_CATEGORY=apps \
132                 -D ICON_SIZES=32,48 \
133                 -o $@ $<
134         chmod +x $@
135
136 $(ICONS): SIZE=$(word 3, $(subst /, ,$@))
137 $(ICONS): data/$(PROJECT_NAME).png support/scale.py
138         mkdir -p $(dir $@)
139         support/scale.py --input $< --output $@ --size $(SIZE)
140
141 $(DESKTOP_FILES): VARIANT=$(word 2, $(subst /, ,$@))
142 $(DESKTOP_FILES): data/template.desktop
143         mkdir -p $(dir $@)
144         cog.py -d \
145                 -D VARIANT=$(VARIANT) \
146                 -D PROGRAM=$(PROGRAM) \
147                 -D ICON_NAME=$(PROJECT_NAME) \
148                 -o $@ $<
149
150
151 $(TAG_FILE): $(OBJ)
152         mkdir -p $(dir $(TAG_FILE))
153         $(CTAGS) -o $(TAG_FILE) $(SOURCE)
154
155 $(TODO_FILE): $(SOURCE)
156         @- $(TODO_FINDER) $(SOURCE) > $(TODO_FILE)
157
158 %.pyc: %.py
159         $(SYNTAX_TEST) $<
160
161 #Makefile Debugging
162 #Target to print any variable, can be added to the dependencies of any other target
163 #Userfule flags for make, -d, -p, -n
164 print-%: ; @$(error $* is $($*) ($(value $*)) (from $(origin $*)))