root/trunk/uploadr/Makefile

Revision 602, 14.1 kB (checked in by ashot, 8 months ago)

in the right place now..

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