This repository has been archived by the owner on Jun 26, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
217 lines (198 loc) · 6.96 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# Pyromaths Makefile.
#
# See 'make help' for available targets and usage details.
### CONFIG
#
# Pyromaths version
VERSION ?= 18.6.2
# Archive format(s) produced by 'make src' (bztar,gztar,zip...)
FORMATS ?= bztar,zip
# Verbosity and logging
#OUT ?= > /dev/null # uncomment: quieter output
OUT ?= >> /tmp/log # uncomment: log output to file
### ENVIRONMENT VARIABLES
#
# Path
PYRO := $(PWD)
DIST := $(PYRO)/dist
BUILD := $(PYRO)/build
ARCHIVE := $(PYRO)/..
# Target-specific build dir (if needed)
BUILDIR = $(BUILD)/$@
# Mac app folder
APP := $(DIST)/Pyromaths.app/Contents
# Project files
FILES := AUTHORS COPYING NEWS pyromaths README setup.py MANIFEST.in src data
### MANIFESTS
#
# Base manifest (README, src/ and test/ auto-included):
MANIFEST := \
include AUTHORS COPYING NEWS \n\
exclude MANIFEST.in \n\
prune test \n\
prune utils \n\
graft data \n
# Minimal install (i.e. without test/ dir):
MANIFEST-min := $(MANIFEST) \
graft data \n\
prune test \n
# Full project sources:
MANIFEST-all := $(MANIFEST) \
graft debian \n\
graft utils \n\
graft data \n\
graft Doc \n\
graft Doc/source \n\
include Makefile \n
# Unix:
MANIFEST-unix := $(MANIFEST-min) \
exclude data/qtmac_fr.qm \n\
exclude data/images/pyromaths.icns \n\
exclude data/images/pyromaths.ico \n
# Mac app:
MANIFEST-mac := $(MANIFEST-min) \
prune data/linux \n\
exclude data/images/pyromaths.ico \n\
exclude data/images/pyromaths-banniere.png \n
# Win app:
MANIFEST-win := $(MANIFEST-min) \
prune data/linux \n\
exclude data/qtmac_fr.qm \n\
exclude data/images/pyromaths.icns \n
### SHORTCUTS & COMPATIBILITY
#
ifeq ($(OS),Windows_NT)
# Windows
PYTHON ?= c:/Python27/python.exe
else
# Unix
PYTHON ?= python
ifeq ($(shell uname -s),Darwin)
# Mac/BSD
sed-i := sed -i ''
else
# GNU
sed-i := sed -i
endif
endif
setup := $(PYTHON) setup.py
### MACROS
#
# Remove manifest file, egg-info dir and target build dir, clean-up sources.
clean = rm -f MANIFEST.in && rm -rf src/*.egg-info && rm -rf $(BUILDIR) &&\
find . -name '*~' | xargs rm -f && find . -iname '*.pyc' | xargs rm -f
# src must be after rpm, otherwise rpm produces a .tar.gz file that replaces the
# .tar.gz source file (should $$FORMATS include gztar).
all: egg rpm deb src
help:
#
# Build pyromaths packages in several formats.
#
# Usage (Unix):
# $$ make src # Make full-source archive(s)
# $$ make egg # Make python egg
# $$ make rpm # Make RPM package
# $$ make deb # Make DEB package
# $$ make [all] # Make all previous archives/packages
#
# Usage (Mac):
# $$ make app # Make standalone application
#
# Usage (Windows):
# $$ make exe # Make standalone executable (experimental)
#
# And also:
# $$ make version # Apply target $$VERSION [$(VERSION)] to sources
# $$ make clean # Clean-up build/dist folders and source tree
# $$ make repo # Make debian repository
#
# Notes:
# - Notice the source achive $$FORMATS produced [$(FORMATS)].
# - Mangle with $$OUT to make it quieter/verbose/log to output file.
clean:
# Clean
rm -r $(BUILD)/* || mkdir -p $(BUILD)
rm -r $(DIST)/* || mkdir -p $(DIST)
rmdir $(BUILD)
rmdir $(DIST)
$(clean)
version:
# Apply target version ($(VERSION)) to sources
$(sed-i) "s/VERSION\s*=\s*'.*'/VERSION = '$(VERSION)'/" src/pyromaths/Values.py
src: version
# Make full-source archive(s) (formats=$(FORMATS))
$(clean)
echo "$(MANIFEST-all)" > MANIFEST.in
$(setup) sdist --formats=$(FORMATS) -d $(DIST) $(OUT)
egg: version
# Make python egg
$(clean)
echo "$(MANIFEST-unix)" > MANIFEST.in
$(setup) bdist_egg -d $(DIST) $(OUT)
rpm: version
# Make RPM package
$(clean)
echo "$(MANIFEST-unix)" > MANIFEST.in
$(setup) bdist --formats=rpm -b $(BUILD) -d $(DIST) $(OUT)
rm $(DIST)/pyromaths-$(VERSION).tar.gz
min: version
# Make minimalist .tar.bz source archive in $(BUILD)
$(clean)
echo "$(MANIFEST-unix)" > MANIFEST.in
$(setup) sdist --formats=bztar -d $(BUILD) $(OUT)
deb: min
# Make DEB archive
$(clean)
cd $(BUILD) && tar -xjf pyromaths-$(VERSION).tar.bz2 &&\
mv pyromaths-$(VERSION) $(BUILDIR) &&\
mv pyromaths-$(VERSION).tar.bz2 pyromaths_$(VERSION).orig.tar.bz2
cp -r debian $(BUILDIR)
cd $(BUILDIR) && debuild -i -D -tc -kB39EE5B6 $(OUT) || exit 0
mkdir -p $(DIST)
mv $(BUILD)/pyromaths_$(VERSION)-*_all.deb $(DIST)
repo: min
# update apt repository
$(clean)
cd $(BUILD) && tar -xjf pyromaths-$(VERSION).tar.bz2 &&\
mv pyromaths-$(VERSION) $(BUILDIR) &&\
mv pyromaths-$(VERSION).tar.bz2 pyromaths_$(VERSION).orig.tar.bz2
cp -r debian $(BUILDIR)
cd $(BUILDIR) && debuild -i -tc -kB39EE5B6 -S $(OUT)
cd $(BUILD)
#dput -l $(BUILD)/pyromaths_$(VERSION)-1_amd64.changes
dput -l -f ppa:jerome-ortais/ppa $(BUILD)/pyromaths_$(VERSION)-1_source.changes
data/%.qm: data/%.ts
# Translate new/updated language files
lrelease $< -qm $@
app: version data/qtmac_fr.qm
# ..Remove previous build
rm -rf $(BUILD) $(DIST)
# Make standalone Mac application
$(setup) py2app -O2 -b $(BUILD) -d $(DIST) $(OUT)
# ..Clean-up unnecessary files/folders
rm -f $(APP)/PkgInfo
cd $(APP)/Resources && rm -rf site.pyc include lib/python2.*/config lib/python2.*/site.pyc
cd $(APP)/Frameworks &&\
rm -rf *.framework/Contents *.framework/Versions/4.0 \
*.framework/Versions/Current *.framework/*.prl \
QtCore.framework/QtCore QtGui.framework/QtGui
cd $(APP)/Frameworks/Python.framework/Versions/2.* &&\
rm -rf include lib Resources
rm -rf $(APP)/Resources/lib/python2.7/pyromaths.ex/examples
find $(APP)/Resources/lib/python2.7/pyromaths.ex \( -name '*.pyc' \) -delete
rm -rf $(APP)/Frameworks/pyromaths
# ..Remove all architectures but x86_64..."
ditto --rsrc --arch x86_64 --hfsCompression $(DIST)/Pyromaths.app $(DIST)/Pyromaths-x86_64.app
exe:
# Make standalone Windows executable
# ..Remove previous builds
rmdir /s /q $(BUILDIR)
rm $(DIST)/Pyromaths-*-win32.exe
# ..Create stripped-down sources
md $(BUILDIR)
xcopy data $(BUILDIR)/data /i /s
xcopy src $(BUILDIR)/src /i /s
copy $(FILES) $(BUILDIR)
move $(BUILDIR)/pyromaths $(BUILDIR)/Pyromaths.py
# ..Create standalone exe
cd $(BUILDIR) && $(setup) innosetup -b $(BUILD) -d $(DIST)