root/trunk/uploadr/Makefile

Revision 365, 12.2 kB (checked in by calh, 2 years ago)

build windows installer strings/config files from a single template, substituting strings from the locale folder. more ja-jp stuff in the makefile. convert files to utf-16 on the fly (only have utf-8 in trunk).

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
57 ########################################################################
58 # Windows configuration
59
60 ifeq (win, $(filter win, $(MAKECMDGOALS)))
61 PLATFORM := win
62
63 # Location of Mozilla tree for the MAR tools
64 MOZILLA := /c/mozilla
65
66 # Location for application bundle staging
67 APPNAME := Flickr\ Uploadr
68
69 # Location to output finished NSIS installers
70 OUT := /c/code/uploadr
71
72 # Location of the makensis.exe binary
73 MAKE_NSIS := /c/Program\ Files/NSIS/Unicode/makensis.exe
74
75
76 # below here, don't modify anything
77
78 # Dated version for the NSIS installer - this comes from application.ini
79 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/'`
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.1.10
101
102 # Location of Mozilla tree for the MAR tools
103 MOZILLA := ~/mozilla
104
105 # Location for build staging
106 #   The base of this path must exist before running make
107 BUILD := ~/Desktop/builds/$(INTL)
108
109 # Location for application bundle staging
110 APP := $(BUILD)/Flickr\ Uploadr.app
111
112 # Location for resource file (chrome, components, etc) staging
113 RES := $(APP)/Contents/Resources
114
115 # Location to output finished DMGs
116 OUT := ~/Desktop
117
118 # End Mac configuration
119 ########################################################################
120
121 endif
122
123 # End configuration
124 ########################################################################
125 ########################################################################
126
127
128
129 dummy:
130         @echo "Nothing happens if you don't give some arguments!"
131         @echo "  win all, mac all:   Build the whole thing"
132         @echo "  build, mar: Build a single package or update but requires"
133         @echo "              de-de, en-US, es-us, fr-fr, it-it, ko-kr, pt-br, or zh-hk"
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 build
144         make $(PLATFORM) en-US build
145         make $(PLATFORM) es-us build
146         make $(PLATFORM) fr-fr build
147         make $(PLATFORM) it-it build
148         make $(PLATFORM) ko-kr build
149         make $(PLATFORM) pt-br build
150         make $(PLATFORM) zh-hk build
151         make $(PLATFORM) ja-jp build
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
184
185
186 build:
187
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/*.* $(BUILD)/jar/content/uploadr/
260         mkdir $(BUILD)/jar/content/hacks
261 ifeq (mac, $(PLATFORM))
262         mkdir $(BUILD)/jar/content/hacks/mac
263         cp $(SRC)/Resources/chrome/content/hacks/mac/*.xul $(BUILD)/jar/content/hacks/mac/
264 #       cp $(SRC)/Resources/chrome/content/hacks/mac/*.js $(BUILD)/jar/content/hacks/mac/
265 endif
266 ifeq (win, $(PLATFORM))
267         mkdir $(BUILD)/jar/content/hacks/win
268         cp $(SRC)/Resources/chrome/content/hacks/win/*.xul $(BUILD)/jar/content/hacks/win/
269 #       cp $(SRC)/Resources/chrome/content/hacks/win/*.js $(BUILD)/jar/content/hacks/win/
270 endif
271 ifeq (linux, $(PLATFORM))
272         mkdir content/hacks/unix
273         cp $(SRC)/Resources/chrome/content/hacks/unix/*.xul $(BUILD)/jar/content/hacks/unix/
274 #       cp $(SRC)/Resources/chrome/content/hacks/unix/*.js $(BUILD)/jar/content/hacks/unix/
275 endif
276         mkdir $(BUILD)/jar/locale
277         mkdir $(BUILD)/jar/locale/branding
278         cp $(SRC)/Resources/chrome/locale/branding/*.* $(BUILD)/jar/locale/branding/
279         mkdir $(BUILD)/jar/locale/$(INTL)
280         cp $(SRC)/Resources/chrome/locale/$(INTL)/*.* $(BUILD)/jar/locale/$(INTL)/
281         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/chrome/chrome.manifest.prod > \
282                 $(RES)/chrome/chrome.manifest
283         mkdir $(BUILD)/jar/skin
284 #ifeq (mac, $(PLATFORM))
285 #       mkdir $(BUILD)/jar/skin/hacks
286 #       mkdir $(BUILD)/jar/skin/hacks/mac
287 #       cp $(SRC)/Resources/chrome/skin/hacks/mac/hacks.css $(BUILD)/jar/skin/hacks/mac/
288 #endif
289 #ifeq (win, $(PLATFORM))
290 #       mkdir $(BUILD)/jar/skin/hacks/win
291 #       cp $(SRC)/Resources/chrome/skin/hacks/win/hacks.css $(BUILD)/jar/skin/hacks/win/
292 #endif
293 #ifeq (linux, $(PLATFORM))
294 #       mkdir $(BUILD)/jar/skin/hacks/unix
295 #       cp $(SRC)/Resources/chrome/skin/hacks/unix/hacks.css $(BUILD)/jar/skin/hacks/unix/
296 #endif
297         mkdir $(BUILD)/jar/skin/uploadr
298         cp $(SRC)/Resources/chrome/skin/uploadr/*.css $(BUILD)/jar/skin/uploadr/
299         cp $(SRC)/Resources/chrome/skin/uploadr/*.gif $(BUILD)/jar/skin/uploadr/
300         cp $(SRC)/Resources/chrome/skin/uploadr/*.png $(BUILD)/jar/skin/uploadr/
301 ifeq (win, $(PLATFORM))
302         cd $(BUILD)/jar/ && zip uploadr.zip -r content locale skin
303 else
304         cd $(BUILD)/jar/ && zip uploadr -r content locale skin
305 endif
306         mv $(BUILD)/jar/uploadr.zip $(RES)/chrome/uploadr.jar
307         rm -rf $(BUILD)/jar
308
309         @# Non-JAR'd Chrome
310         mkdir $(RES)/chrome/icons
311         mkdir $(RES)/chrome/icons/default
312         cp $(SRC)/Resources/chrome/icons/default/*.ico $(RES)/chrome/icons/default/
313
314         @# XPCOM
315         mkdir $(RES)/components
316         cp $(SRC)/Resources/components/*.xpt $(RES)/components/
317 ifeq (mac, $(PLATFORM))
318         cp $(SRC)/Resources/components/*.dylib $(RES)/components/
319 endif
320 ifeq (win, $(PLATFORM))
321         cp $(SRC)/Resources/components/*.dll $(RES)/components/
322 endif
323 ifeq (linux, $(PLATFORM))
324         cp $(SRC)/Resources/components/*.so $(RES)/components/
325 endif
326         cp $(SRC)/Resources/components/*.js $(RES)/components/
327
328         @# Create DMG for Macs
329 ifeq (mac, $(PLATFORM))
330         ln -s /Applications $(BUILD)/Applications
331         cp mac_installer/install-pane-$(INTL_SHORT).png $(BUILD)/.i.png
332         cp mac_installer/DS_Store $(BUILD)/.DS_Store
333         rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
334         hdiutil create -srcfolder $(BUILD) -volname "Flickr Uploadr $(VER)" \
335                 -format UDZO -imagekey zlib-level=9 \
336                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
337 endif
338
339         @# Create NSIS installer for Windows
340 ifeq (win, $(PLATFORM))
341
342         perl win_installer/strsub.pl win_installer/strings.nsh \
343                 $(SRC)/Resources/chrome/locale/$(INTL)/installer.properties > \
344                 $(BUILD)/strings-temp.nsh
345         perl win_installer/utf16.pl \
346                 $(BUILD)/strings-temp.nsh > \
347                 $(BUILD)/strings.nsh
348         rm $(BUILD)/strings-temp.nsh
349
350         perl win_installer/strsub.pl win_installer/config.ini \
351                 $(SRC)/Resources/chrome/locale/$(INTL)/installer.properties > \
352                 $(BUILD)/config-temp.ini
353         perl win_installer/utf16.pl \
354                 $(BUILD)/config-temp.ini > \
355                 $(BUILD)/config.ini
356         rm $(BUILD)/config-temp.ini
357
358         perl win_installer/utf16.pl \
359                 win_installer/build.nsi > \
360                 $(BUILD)/build.nsi
361
362         cp win_installer/vcredist_x86.exe $(BUILD)/vcredist_x86.exe
363
364         $(MAKE_NSIS) -DVERSION=$(VER) \
365                 -DVERSION_DATE=$(VER_DATE) \
366                 $(BUILD)/build.nsi
367
368         mv $(BUILD)/FlickrUploadr-$(VER)-XX.exe \
369                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).exe
370
371         rm $(BUILD)/build.nsi
372         rm $(BUILD)/strings.nsh
373         rm $(BUILD)/config.ini
374         rm $(BUILD)/vcredist_x86.exe
375 endif
376
377         @# Create ??? for Linux
378 ifeq (linux, $(PLATFORM))
379 endif
380
381
382
383 mar:
384
385         @# Making MAR files
386 ifeq (mac, $(PLATFORM))
387         @ln -s Flickr\ Uploadr.app $(BUILD)/new
388 endif
389 ifeq (win, $(PLATFORM))
390         @# In Windows, `ln -s ...` == `cp -R ...`
391         @ln -s $(BUILD)/Flickr\ Uploadr $(BUILD)/new
392 endif
393 ifeq (linux, $(PLATFORM))
394         @ln -s Flickr\ Uploadr $(BUILD)/new
395 endif
396         @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar
397         @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
398                 $(MOZILLA)/tools/update-packaging/make_full_update.sh \
399                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar \
400                 $(BUILD)/new &> /dev/null
401 #       @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar
402 #       @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
403 #               $(MOZILLA)/tools/update-packaging/make_incremental_update.sh \
404 #               $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar \
405 #               $(BUILD)/old $(BUILD)/new &> /dev/null
406 ifeq (win, $(PLATFORM))
407         @rm -rf $(BUILD)/new
408 else
409         @rm $(BUILD)/new
410 endif
411
412         @# Size and hash for the XML file
413 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
414 #               awk '{print "$(INTL) complete size: ",$$5}'
415 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
416 #               awk '{print "$(INTL) complete MD5:  ",$$4}'
417 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
418 #               awk '{print "$(INTL) partial size: ",$$5}'
419 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
420 #               awk '{print "$(INTL) partial MD5:  ",$$4}'
Note: See TracBrowser for help on using the browser.