root/trunk/uploadr/Makefile

Revision 360, 11.9 kB (checked in by calh, 2 years ago)

added ja-jp as a buildable target. renamed all the config/string files. no need to pass INTL to NSIS

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