root/trunk/uploadr/Makefile

Revision 469, 12.3 kB (checked in by jdecq, 1 year ago)

For some reason build is not a working keyword on my config: replaced by packaging

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.2.5
101
102 # Location of Mozilla tree for the MAR tools
103 MOZILLA := ~/devel/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 "  packaging, 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 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
184 packaging:
185         @echo "Build step"
186         @# Make sure the package directory exists
187         mkdir -p $(BUILD)
188
189         @# Saving the previous version for the partial MAR
190 #       rm -rf $(BUILD)/old
191 #       mv $(APP) $(BUILD)/old
192         rm -rf $(APP)
193 ifeq (mac, $(PLATFORM))
194         rm -f $(BUILD)/Applications
195 endif
196
197         @# Package structure
198 ifeq (mac, $(PLATFORM))
199         mkdir -p $(APP)/Contents
200         mkdir $(APP)/Contents/lib
201         mkdir $(APP)/Contents/Frameworks
202         mkdir $(APP)/Contents/MacOS
203         mkdir $(RES)
204         cp $(SRC)/Info.plist $(APP)/Contents/
205 else
206         mkdir $(APP)
207 endif
208
209         @# GraphicsMagick config files
210 ifeq (mac, $(PLATFORM))
211         mkdir $(APP)/Contents/lib/GraphicsMagick-$(GM_VER)
212         mkdir $(APP)/Contents/lib/GraphicsMagick-$(GM_VER)/config
213         cp $(SRC)/lib/GraphicsMagick-$(GM_VER)/config/*.mgk \
214                 $(APP)/Contents/lib/GraphicsMagick-$(GM_VER)/config/
215 else
216         cp $(SRC)/Resources/*.mgk $(RES)/
217 endif
218
219         @# XULRunner
220         cp $(SRC)/Resources/application.ini $(RES)/
221         cp $(SRC)/Resources/LICENSE.txt $(RES)/
222 ifeq (mac, $(PLATFORM))
223         cp -R $(SRC)/Frameworks/XUL.framework $(APP)/Contents/Frameworks/
224         cp $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/xulrunner \
225                 $(APP)/Contents/MacOS/xulrunner
226         cp $(SRC)/Resources/icons.icns $(RES)/
227 endif
228 ifeq (win, $(PLATFORM))
229         cp -R $(SRC)/Resources/xulrunner $(RES)/
230         cp $(SRC)/Resources/Flickr\ Uploadr.exe $(RES)/
231         cp $(SRC)/Resources/libexpat.dll $(RES)/
232         cp $(SRC)/Resources/icons.ico $(RES)/
233 endif
234
235         @# XULRunner preferences
236         mkdir -p $(RES)/defaults/preferences
237         cp $(SRC)/Resources/defaults/preferences/*.js \
238                 $(RES)/defaults/preferences/
239         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/defaults/preferences/prefs.js > \
240                 $(RES)/defaults/preferences/prefs.js
241
242         @# XULRunner locale
243 ifeq (mac, $(PLATFORM))
244         rm $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/??-??.*
245         cp ./xulrunner_locales/$(INTL).* \
246                 $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/
247 else
248         rm $(RES)/xulrunner/chrome/??-??.*
249         cp ./xulrunner_locales/$(INTL).* $(RES)/xulrunner/chrome/
250 endif
251
252         @# Chrome
253         mkdir $(RES)/chrome
254         mkdir $(BUILD)/jar
255         mkdir $(BUILD)/jar/content
256         mkdir $(BUILD)/jar/content/uploadr
257         cp $(SRC)/Resources/chrome/content/uploadr/*.* $(BUILD)/jar/content/uploadr/
258         mkdir $(BUILD)/jar/content/hacks
259 ifeq (mac, $(PLATFORM))
260         mkdir $(BUILD)/jar/content/hacks/mac
261         cp $(SRC)/Resources/chrome/content/hacks/mac/*.xul $(BUILD)/jar/content/hacks/mac/
262 #       cp $(SRC)/Resources/chrome/content/hacks/mac/*.js $(BUILD)/jar/content/hacks/mac/
263 endif
264 ifeq (win, $(PLATFORM))
265         mkdir $(BUILD)/jar/content/hacks/win
266         cp $(SRC)/Resources/chrome/content/hacks/win/*.xul $(BUILD)/jar/content/hacks/win/
267 #       cp $(SRC)/Resources/chrome/content/hacks/win/*.js $(BUILD)/jar/content/hacks/win/
268 endif
269 ifeq (linux, $(PLATFORM))
270         mkdir content/hacks/unix
271         cp $(SRC)/Resources/chrome/content/hacks/unix/*.xul $(BUILD)/jar/content/hacks/unix/
272 #       cp $(SRC)/Resources/chrome/content/hacks/unix/*.js $(BUILD)/jar/content/hacks/unix/
273 endif
274         mkdir $(BUILD)/jar/locale
275         mkdir $(BUILD)/jar/locale/branding
276         cp $(SRC)/Resources/chrome/locale/branding/*.* $(BUILD)/jar/locale/branding/
277         mkdir $(BUILD)/jar/locale/$(INTL)
278         cp $(SRC)/Resources/chrome/locale/$(INTL)/*.* $(BUILD)/jar/locale/$(INTL)/
279         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/chrome/chrome.manifest.prod > \
280                 $(RES)/chrome/chrome.manifest
281         mkdir $(BUILD)/jar/skin
282 #ifeq (mac, $(PLATFORM))
283 #       mkdir $(BUILD)/jar/skin/hacks
284 #       mkdir $(BUILD)/jar/skin/hacks/mac
285 #       cp $(SRC)/Resources/chrome/skin/hacks/mac/hacks.css $(BUILD)/jar/skin/hacks/mac/
286 #endif
287 #ifeq (win, $(PLATFORM))
288 #       mkdir $(BUILD)/jar/skin/hacks/win
289 #       cp $(SRC)/Resources/chrome/skin/hacks/win/hacks.css $(BUILD)/jar/skin/hacks/win/
290 #endif
291 #ifeq (linux, $(PLATFORM))
292 #       mkdir $(BUILD)/jar/skin/hacks/unix
293 #       cp $(SRC)/Resources/chrome/skin/hacks/unix/hacks.css $(BUILD)/jar/skin/hacks/unix/
294 #endif
295         mkdir $(BUILD)/jar/skin/uploadr
296         cp $(SRC)/Resources/chrome/skin/uploadr/*.css $(BUILD)/jar/skin/uploadr/
297         cp $(SRC)/Resources/chrome/skin/uploadr/*.gif $(BUILD)/jar/skin/uploadr/
298         cp $(SRC)/Resources/chrome/skin/uploadr/*.png $(BUILD)/jar/skin/uploadr/
299 ifeq (win, $(PLATFORM))
300         cd $(BUILD)/jar/ && zip uploadr.zip -r content locale skin
301 else
302         cd $(BUILD)/jar/ && zip uploadr -r content locale skin
303 endif
304         mv $(BUILD)/jar/uploadr.zip $(RES)/chrome/uploadr.jar
305         rm -rf $(BUILD)/jar
306
307         @# Non-JAR'd Chrome
308         mkdir $(RES)/chrome/icons
309         mkdir $(RES)/chrome/icons/default
310         cp $(SRC)/Resources/chrome/icons/default/*.ico $(RES)/chrome/icons/default/
311
312         @# XPCOM
313         mkdir $(RES)/components
314         cp $(SRC)/Resources/components/*.xpt $(RES)/components/
315 ifeq (mac, $(PLATFORM))
316         cp $(SRC)/Resources/components/*.dylib $(RES)/components/
317 endif
318 ifeq (win, $(PLATFORM))
319         cp $(SRC)/Resources/components/*.dll $(RES)/components/
320 endif
321 ifeq (linux, $(PLATFORM))
322         cp $(SRC)/Resources/components/*.so $(RES)/components/
323 endif
324         cp $(SRC)/Resources/components/*.js $(RES)/components/
325
326         @# Create DMG for Macs
327 ifeq (mac, $(PLATFORM))
328         ln -s /Applications $(BUILD)/Applications
329         cp mac_installer/install-pane-$(INTL_SHORT).png $(BUILD)/.i.png
330         cp mac_installer/DS_Store $(BUILD)/.DS_Store
331         rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
332         hdiutil create -srcfolder $(BUILD) -volname "Flickr Uploadr $(VER)" \
333                 -format UDZO -imagekey zlib-level=9 \
334                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
335 endif
336
337         @# Create NSIS installer for Windows
338 ifeq (win, $(PLATFORM))
339
340         perl win_installer/strsub.pl win_installer/strings.nsh \
341                 $(SRC)/Resources/chrome/locale/$(INTL)/installer.properties > \
342                 $(BUILD)/strings-temp.nsh
343         perl win_installer/utf16.pl \
344                 $(BUILD)/strings-temp.nsh > \
345                 $(BUILD)/strings.nsh
346         rm $(BUILD)/strings-temp.nsh
347
348         perl win_installer/strsub.pl win_installer/config.ini \
349                 $(SRC)/Resources/chrome/locale/$(INTL)/installer.properties > \
350                 $(BUILD)/config-temp.ini
351         perl win_installer/utf16.pl \
352                 $(BUILD)/config-temp.ini > \
353                 $(BUILD)/config.ini
354         rm $(BUILD)/config-temp.ini
355
356         perl win_installer/utf16.pl \
357                 win_installer/build.nsi > \
358                 $(BUILD)/build.nsi
359
360         cp win_installer/vcredist_x86.exe $(BUILD)/vcredist_x86.exe
361
362         $(MAKE_NSIS) -DVERSION=$(VER) \
363                 -DVERSION_DATE=$(VER_DATE) \
364                 $(BUILD)/build.nsi
365
366         mv $(BUILD)/FlickrUploadr-$(VER)-XX.exe \
367                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).exe
368
369         rm $(BUILD)/build.nsi
370         rm $(BUILD)/strings.nsh
371         rm $(BUILD)/config.ini
372         rm $(BUILD)/vcredist_x86.exe
373 endif
374
375         @# Create ??? for Linux
376 ifeq (linux, $(PLATFORM))
377 endif
378
379
380
381 mar:
382
383         @echo "MAR step"
384         @# Making MAR files
385 ifeq (mac, $(PLATFORM))
386         @ln -s Flickr\ Uploadr.app $(BUILD)/new
387 endif
388 ifeq (win, $(PLATFORM))
389         @# In Windows, `ln -s ...` == `cp -R ...`
390         @ln -s $(BUILD)/Flickr\ Uploadr $(BUILD)/new
391 endif
392 ifeq (linux, $(PLATFORM))
393         @ln -s Flickr\ Uploadr $(BUILD)/new
394 endif
395         @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar
396         @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
397                 $(MOZILLA)/tools/update-packaging/make_full_update.sh \
398                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar \
399                 $(BUILD)/new &> /dev/null
400 #       @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar
401 #       @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
402 #               $(MOZILLA)/tools/update-packaging/make_incremental_update.sh \
403 #               $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar \
404 #               $(BUILD)/old $(BUILD)/new &> /dev/null
405 ifeq (win, $(PLATFORM))
406         @rm -rf $(BUILD)/new
407 else
408         @rm $(BUILD)/new
409 endif
410
411         @# Size and hash for the XML file
412 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
413 #               awk '{print "$(INTL) complete size: ",$$5}'
414 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
415 #               awk '{print "$(INTL) complete MD5:  ",$$4}'
416 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
417 #               awk '{print "$(INTL) partial size: ",$$5}'
418 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
419 #               awk '{print "$(INTL) partial MD5:  ",$$4}'
Note: See TracBrowser for help on using the browser.