root/trunk/uploadr/Makefile

Revision 359, 12.0 kB (checked in by calh, 2 years ago)

windows installer is nearly building (!!)

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