root/trunk/uploadr/Makefile

Revision 509, 13.8 kB (checked in by jdecq, 10 months ago)

=appending build number in installers file name

Line 
1 #
2 # Flickr Uploadr
3 #
4 # Copyright (c) 2007-2008 Yahoo! Inc.  All rights reserved.  This library is
5 # free software; you can redistribute it and/or modify it under the terms of
6 # the GNU General Public License (GPL), version 2 only.  This library is
7 # distributed WITHOUT ANY WARRANTY, whether express or implied. See the GNU
8 # GPL for more details (http://www.gnu.org/licenses/gpl.html)
9 #
10
11 # Macs can build DMGs and MARs for all languages with `make`
12 # Windows can build installers and MARs for all languages with `make win`
13
14 INTL := $(filter de-de en-US es-us fr-fr it-it ko-kr pt-br zh-hk ja-jp, $(MAKECMDGOALS))
15
16 ifeq (de-de, $(INTL))
17 INTL_SHORT := de
18 endif
19 ifeq (en-US, $(INTL))
20 INTL_SHORT := en
21 endif
22 ifeq (es-us, $(INTL))
23 INTL_SHORT := es
24 endif
25 ifeq (fr-fr, $(INTL))
26 INTL_SHORT := fr
27 endif
28 ifeq (it-it, $(INTL))
29 INTL_SHORT := it
30 endif
31 ifeq (ko-kr, $(INTL))
32 INTL_SHORT := kr
33 endif
34 ifeq (pt-br, $(INTL))
35 INTL_SHORT := br
36 endif
37 ifeq (zh-hk, $(INTL))
38 INTL_SHORT := hk
39 endif
40 ifeq (ja-jp, $(INTL))
41 INTL_SHORT := ja
42 endif
43
44
45 ########################################################################
46 ########################################################################
47 # Configuration
48
49 # Source files
50 #   Even though this isn't a very Windows-y path, it makes life
51 #   simpler to use it on all platforms
52 SRC := MacUploadr.app/Contents
53
54 # Version number for Uploadr - this comes from application.ini
55 VER := `grep ^Version= $(SRC)/Resources/application.ini | sed 's/Version=\(.*\)/\1/'`
56 # Dated version for the NSIS installer - this comes from application.ini
57 VER_DATE := `grep ^BuildID= $(SRC)/Resources/application.ini | sed 's/BuildID=\([0-9]\{4\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)\([0-9]\{2\}\)/\1.\2.\3.\4/'`
58
59 ########################################################################
60 # Windows configuration
61
62 ifeq (win, $(filter win, $(MAKECMDGOALS)))
63 PLATFORM := win
64
65 # Location of Mozilla tree for the MAR tools
66 MOZILLA := /c/mozilla
67
68 # Location for application bundle staging
69 APPNAME := Flickr\ Uploadr
70
71 # Location to output finished NSIS installers
72 OUT := /c/code/uploadr
73
74 # Location of the makensis.exe binary
75 MAKE_NSIS := /c/Program\ Files/NSIS/Unicode/makensis.exe
76
77
78 # below here, don't modify anything
79
80 # Location for build staging
81 BUILD := $(OUT)/builds/$(INTL)
82
83 # Location for application bundle staging
84 APP := $(BUILD)/$(APPNAME)
85
86 # Location for resource file (chrome, components, etc) staging
87 RES := $(APP)
88
89 # End Windows configuration
90 ########################################################################
91
92 ########################################################################
93 # Mac configuration
94
95 else
96 PLATFORM := mac
97
98 # GraphicsMagick version for stupid directory structure
99 GM_VER := 1.2.5
100
101 # Location of Mozilla tree for the MAR tools
102 MOZILLA := ~/UPLOADR/mozilla
103
104 # Location for build staging
105 #   The base of this path must exist before running make
106 BUILD := ~/Desktop/builds/$(INTL)
107
108 # Location for application bundle staging
109 APP := $(BUILD)/Flickr\ Uploadr.app
110
111 # Location for resource file (chrome, components, etc) staging
112 RES := $(APP)/Contents/Resources
113
114 # Location to output finished DMGs
115 OUT := ~/Desktop
116
117 # End Mac configuration
118 ########################################################################
119
120 endif
121
122 # End configuration
123 ########################################################################
124 ########################################################################
125
126
127
128 dummy:
129         @echo "Nothing happens if you don't give some arguments!"
130         @echo "  win all, mac all:   Build the whole thing"
131         @echo "  packaging, mar: Build a single package or update but requires"
132         @echo "              de-de, en-US, es-us, fr-fr, it-it, ko-kr, pt-br, or zh-hk"
133         @echo "              dev for development build: i.e. unjared content"
134
135 all: all-build all-mar
136
137 mac:
138         @echo "Building for Mac"
139 win:
140         @echo "Building for Windows"
141
142 all-build:
143         make $(PLATFORM) de-de packaging
144         make $(PLATFORM) en-US packaging
145         make $(PLATFORM) es-us packaging
146         make $(PLATFORM) fr-fr packaging
147         make $(PLATFORM) it-it packaging
148         make $(PLATFORM) ko-kr packaging
149         make $(PLATFORM) pt-br packaging
150         make $(PLATFORM) zh-hk packaging
151         make $(PLATFORM) ja-jp packaging
152
153 all-mar:
154         @make $(PLATFORM) de-de mar
155         @make $(PLATFORM) en-US mar
156         @make $(PLATFORM) es-us mar
157         @make $(PLATFORM) fr-fr mar
158         @make $(PLATFORM) it-it mar
159         @make $(PLATFORM) ko-kr mar
160         @make $(PLATFORM) pt-br mar
161         @make $(PLATFORM) zh-hk mar
162         @make $(PLATFORM) ja-jp mar
163
164
165 de-de:
166         @echo "Building German (de-de)"
167 en-US:
168         @echo "Building English (en-US)"
169 es-us:
170         @echo "Building Spanish (es-us)"
171 fr-fr:
172         @echo "Building French (fr-fr)"
173 it-it:
174         @echo "Building Italian (it-it)"
175 ko-kr:
176         @echo "Building Korean (ko-kr)"
177 pt-br:
178         @echo "Building Portuguese (pt-br)"
179 zh-hk:
180         @echo "Building Chinese (zh-hk)"
181 ja-jp:
182         @echo "Building Japanese (ja-jp)"
183 dev:
184         @echo "Development Build"
185
186 packaging:
187         @echo "Build step"
188         @# Make sure the package directory exists
189         mkdir -p $(BUILD)
190
191         @# Saving the previous version for the partial MAR
192 #       rm -rf $(BUILD)/old
193 #       mv $(APP) $(BUILD)/old
194         rm -rf $(APP)
195 ifeq (mac, $(PLATFORM))
196         rm -f $(BUILD)/Applications
197 endif
198
199         @# Package structure
200 ifeq (mac, $(PLATFORM))
201         mkdir -p $(APP)/Contents
202         mkdir $(APP)/Contents/lib
203         mkdir $(APP)/Contents/Frameworks
204         mkdir $(APP)/Contents/MacOS
205         mkdir $(RES)
206         cp $(SRC)/Info.plist $(APP)/Contents/
207 else
208         mkdir $(APP)
209 endif
210
211         @# GraphicsMagick config files
212 ifeq (mac, $(PLATFORM))
213         mkdir $(APP)/Contents/lib/GraphicsMagick-$(GM_VER)
214         mkdir $(APP)/Contents/lib/GraphicsMagick-$(GM_VER)/config
215         cp $(SRC)/lib/GraphicsMagick-$(GM_VER)/config/*.mgk \
216                 $(APP)/Contents/lib/GraphicsMagick-$(GM_VER)/config/
217 else
218         cp $(SRC)/Resources/*.mgk $(RES)/
219 endif
220
221         @# XULRunner
222         cp $(SRC)/Resources/application.ini $(RES)/
223         cp $(SRC)/Resources/LICENSE.txt $(RES)/
224 ifeq (mac, $(PLATFORM))
225         cp -R $(SRC)/Frameworks/XUL.framework $(APP)/Contents/Frameworks/
226         cp $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/xulrunner \
227                 $(APP)/Contents/MacOS/xulrunner
228         cp $(SRC)/Resources/icons.icns $(RES)/
229 endif
230 ifeq (win, $(PLATFORM))
231         cp -R $(SRC)/Resources/xulrunner $(RES)/
232         cp $(SRC)/Resources/Flickr\ Uploadr.exe $(RES)/
233         cp $(SRC)/Resources/libexpat.dll $(RES)/
234         cp $(SRC)/Resources/icons.ico $(RES)/
235 endif
236
237         @# XULRunner preferences
238         mkdir -p $(RES)/defaults/preferences
239         cp $(SRC)/Resources/defaults/preferences/*.js \
240                 $(RES)/defaults/preferences/
241         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/defaults/preferences/prefs.js > \
242                 $(RES)/defaults/preferences/prefs.js
243
244         @# XULRunner locale
245 ifeq (mac, $(PLATFORM))
246         rm $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/??-??.*
247         cp ./xulrunner_locales/$(INTL).* \
248                 $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/
249 else
250         rm $(RES)/xulrunner/chrome/??-??.*
251         cp ./xulrunner_locales/$(INTL).* $(RES)/xulrunner/chrome/
252 endif
253
254         @# Chrome
255         mkdir $(RES)/chrome
256         mkdir $(BUILD)/jar
257         mkdir $(BUILD)/jar/content
258         mkdir $(BUILD)/jar/content/uploadr
259         cp $(SRC)/Resources/chrome/content/uploadr/*.js $(BUILD)/jar/content/uploadr/
260         cp $(SRC)/Resources/chrome/content/uploadr/*.xul $(BUILD)/jar/content/uploadr/
261         mkdir $(BUILD)/jar/content/hacks
262 ifeq (mac, $(PLATFORM))
263         mkdir $(BUILD)/jar/content/hacks/mac
264         cp $(SRC)/Resources/chrome/content/hacks/mac/*.xul $(BUILD)/jar/content/hacks/mac/
265 #       cp $(SRC)/Resources/chrome/content/hacks/mac/*.js $(BUILD)/jar/content/hacks/mac/
266 endif
267 ifeq (win, $(PLATFORM))
268         mkdir $(BUILD)/jar/content/hacks/win
269         cp $(SRC)/Resources/chrome/content/hacks/win/*.xul $(BUILD)/jar/content/hacks/win/
270 #       cp $(SRC)/Resources/chrome/content/hacks/win/*.js $(BUILD)/jar/content/hacks/win/
271 endif
272 ifeq (linux, $(PLATFORM))
273         mkdir content/hacks/unix
274         cp $(SRC)/Resources/chrome/content/hacks/unix/*.xul $(BUILD)/jar/content/hacks/unix/
275 #       cp $(SRC)/Resources/chrome/content/hacks/unix/*.js $(BUILD)/jar/content/hacks/unix/
276 endif
277         mkdir $(BUILD)/jar/locale
278         mkdir $(BUILD)/jar/locale/branding
279         cp $(SRC)/Resources/chrome/locale/branding/*.* $(BUILD)/jar/locale/branding/
280         mkdir $(BUILD)/jar/locale/$(INTL)
281         cp $(SRC)/Resources/chrome/locale/$(INTL)/*.* $(BUILD)/jar/locale/$(INTL)/
282 ifeq (dev, $(filter dev, $(MAKECMDGOALS)))
283         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/chrome/chrome.manifest > \
284                 $(RES)/chrome/chrome.manifest
285 else
286         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/chrome/chrome.manifest.prod > \
287                 $(RES)/chrome/chrome.manifest
288 endif
289         mkdir $(BUILD)/jar/skin
290 #ifeq (mac, $(PLATFORM))
291 #       mkdir $(BUILD)/jar/skin/hacks
292 #       mkdir $(BUILD)/jar/skin/hacks/mac
293 #       cp $(SRC)/Resources/chrome/skin/hacks/mac/hacks.css $(BUILD)/jar/skin/hacks/mac/
294 #endif
295 #ifeq (win, $(PLATFORM))
296 #       mkdir $(BUILD)/jar/skin/hacks/win
297 #       cp $(SRC)/Resources/chrome/skin/hacks/win/hacks.css $(BUILD)/jar/skin/hacks/win/
298 #endif
299 #ifeq (linux, $(PLATFORM))
300 #       mkdir $(BUILD)/jar/skin/hacks/unix
301 #       cp $(SRC)/Resources/chrome/skin/hacks/unix/hacks.css $(BUILD)/jar/skin/hacks/unix/
302 #endif
303         mkdir $(BUILD)/jar/skin/uploadr
304         cp $(SRC)/Resources/chrome/skin/uploadr/*.css $(BUILD)/jar/skin/uploadr/
305         cp $(SRC)/Resources/chrome/skin/uploadr/*.gif $(BUILD)/jar/skin/uploadr/
306         cp $(SRC)/Resources/chrome/skin/uploadr/*.png $(BUILD)/jar/skin/uploadr/
307
308 ifeq (dev, $(filter dev, $(MAKECMDGOALS)))
309         cd $(BUILD)/jar/ && mv content $(RES)/chrome/ && mv locale $(RES)/chrome/ && mv skin $(RES)/chrome/
310 else
311 ifeq (win, $(PLATFORM))
312         cd $(BUILD)/jar/ && zip uploadr.zip -r content locale skin
313 else
314         cd $(BUILD)/jar/ && zip uploadr -r content locale skin
315 endif
316         mv $(BUILD)/jar/uploadr.zip $(RES)/chrome/uploadr.jar
317 endif
318         rm -rf $(BUILD)/jar
319
320         @# Non-JAR'd Chrome
321         mkdir $(RES)/chrome/icons
322         mkdir $(RES)/chrome/icons/default
323         cp $(SRC)/Resources/chrome/icons/default/*.ico $(RES)/chrome/icons/default/
324
325         @# XPCOM
326         mkdir $(RES)/components
327         cp $(SRC)/Resources/components/*.xpt $(RES)/components/
328 ifeq (mac, $(PLATFORM))
329         cp $(SRC)/Resources/components/*.dylib $(RES)/components/
330 endif
331 ifeq (win, $(PLATFORM))
332         cp $(SRC)/Resources/components/*.dll $(RES)/components/
333 endif
334 ifeq (linux, $(PLATFORM))
335         cp $(SRC)/Resources/components/*.so $(RES)/components/
336 endif
337         cp $(SRC)/Resources/components/*.js $(RES)/components/
338
339         @# Create DMG for Macs
340 ifeq (mac, $(PLATFORM))
341         ln -s /Applications $(BUILD)/Applications
342         cp mac_installer/install-pane-$(INTL_SHORT).png $(BUILD)/.i.png
343         cp mac_installer/DS_Store $(BUILD)/.DS_Store
344         rm -f $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT).dmg
345         rm -f $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT)-dev.dmg
346 ifeq (dev, $(filter dev, $(MAKECMDGOALS)))
347         hdiutil create -srcfolder $(BUILD) -volname "Flickr Uploadr $(VER)" \
348                 -format UDZO -imagekey zlib-level=9 \
349                 $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT)-dev.dmg
350 else
351         hdiutil create -srcfolder $(BUILD) -volname "Flickr Uploadr $(VER)" \
352                 -format UDZO -imagekey zlib-level=9 \
353                 $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT).dmg
354 endif
355 endif
356
357         @# Create NSIS installer for Windows
358 ifeq (win, $(PLATFORM))
359
360         perl win_installer/strsub.pl win_installer/strings.nsh \
361                 $(SRC)/Resources/chrome/locale/$(INTL)/installer.properties > \
362                 $(BUILD)/strings-temp.nsh
363         perl win_installer/utf16.pl \
364                 $(BUILD)/strings-temp.nsh > \
365                 $(BUILD)/strings.nsh
366         rm $(BUILD)/strings-temp.nsh
367
368         perl win_installer/strsub.pl win_installer/config.ini \
369                 $(SRC)/Resources/chrome/locale/$(INTL)/installer.properties > \
370                 $(BUILD)/config-temp.ini
371         perl win_installer/utf16.pl \
372                 $(BUILD)/config-temp.ini > \
373                 $(BUILD)/config.ini
374         rm $(BUILD)/config-temp.ini
375 ifeq (dev, $(filter dev, $(MAKECMDGOALS)))
376         perl win_installer/utf16.pl \
377                 win_installer/build_dev.nsi > \
378                 $(BUILD)/build.nsi
379 else
380         perl win_installer/utf16.pl \
381                 win_installer/build.nsi > \
382                 $(BUILD)/build.nsi
383 endif
384         cp win_installer/vcredist_x86.exe $(APP)/vcredist_x86.exe
385
386         $(MAKE_NSIS) -DVERSION=$(VER) \
387                 -DVERSION_DATE=$(VER_DATE) \
388                 $(BUILD)/build.nsi
389 ifeq (dev, $(filter dev, $(MAKECMDGOALS)))
390         mv $(BUILD)/FlickrUploadr-$(VER)-XX.exe \
391                 $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT)-dev.exe
392 else
393         mv $(BUILD)/FlickrUploadr-$(VER)-XX.exe \
394                 $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT).exe
395 endif
396         rm $(BUILD)/build.nsi
397         rm $(BUILD)/strings.nsh
398         rm $(BUILD)/config.ini
399 endif
400
401         @# Create ??? for Linux
402 ifeq (linux, $(PLATFORM))
403 endif
404
405
406
407 mar:
408
409         @echo "MAR step"
410         @# Making MAR files
411 ifeq (mac, $(PLATFORM))
412         @ln -s Flickr\ Uploadr.app $(BUILD)/new
413 endif
414 ifeq (win, $(PLATFORM))
415         @# In Windows, `ln -s ...` == `cp -R ...`
416         @ln -s $(BUILD)/Flickr\ Uploadr $(BUILD)/new
417 endif
418 ifeq (linux, $(PLATFORM))
419         @ln -s Flickr\ Uploadr $(BUILD)/new
420 endif
421         @rm -f $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT).complete.mar
422         @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
423                 $(MOZILLA)/tools/update-packaging/make_full_update.sh \
424                 $(OUT)/FlickrUploadr-$(VER)-$(VER_DATE)-$(INTL_SHORT)-$(PLATFORM).complete.mar \
425                 $(BUILD)/new &> /dev/null
426 #       @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar
427 #       @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
428 #               $(MOZILLA)/tools/update-packaging/make_incremental_update.sh \
429 #               $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar \
430 #               $(BUILD)/old $(BUILD)/new &> /dev/null
431 ifeq (win, $(PLATFORM))
432         @rm -rf $(BUILD)/new
433 else
434         @rm $(BUILD)/new
435 endif
436
437         @# Size and hash for the XML file
438 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
439 #               awk '{print "$(INTL) complete size: ",$$5}'
440 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
441 #               awk '{print "$(INTL) complete MD5:  ",$$4}'
442 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
443 #               awk '{print "$(INTL) partial size: ",$$5}'
444 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
445 #               awk '{print "$(INTL) partial MD5:  ",$$4}'
Note: See TracBrowser for help on using the browser.