root/trunk/uploadr/Makefile

Revision 357, 11.7 kB (checked in by calh, 2 years ago)

further towards a working windows installer build - moving the NSIS files into one place trying to build only in the build tree

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 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/application.ini $(RES)/
229         cp $(SRC)/Resources/LICENSE.txt $(RES)/
230         cp $(SRC)/Resources/icons.icns $(RES)/
231 else
232         cp -R $(SRC)/Resources/xulrunner $(RES)/
233         cp $(SRC)/Resources/Flickr\ Uploadr.exe $(RES)/
234 endif
235
236         @# XULRunner preferences
237         mkdir -p $(RES)/defaults/preferences
238         cp $(SRC)/Resources/defaults/preferences/*.js \
239                 $(RES)/defaults/preferences/
240         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/defaults/preferences/prefs.js > \
241                 $(RES)/defaults/preferences/prefs.js
242
243         @# XULRunner locale
244 ifeq (mac, $(PLATFORM))
245         rm $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/??-??.*
246         cp ./xulrunner_locales/$(INTL).* \
247                 $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/
248 else
249         rm $(RES)/xulrunner/chrome/??-??.*
250         cp ./xulrunner_locales/$(INTL).* $(RES)/xulrunner/chrome/
251 endif
252
253         @# Chrome
254         mkdir $(RES)/chrome
255         mkdir $(BUILD)/jar
256         mkdir $(BUILD)/jar/content
257         mkdir $(BUILD)/jar/content/uploadr
258         cp $(SRC)/Resources/chrome/content/uploadr/*.* $(BUILD)/jar/content/uploadr/
259         mkdir $(BUILD)/jar/content/hacks
260 ifeq (mac, $(PLATFORM))
261         mkdir $(BUILD)/jar/content/hacks/mac
262         cp $(SRC)/Resources/chrome/content/hacks/mac/*.xul $(BUILD)/jar/content/hacks/mac/
263 #       cp $(SRC)/Resources/chrome/content/hacks/mac/*.js $(BUILD)/jar/content/hacks/mac/
264 endif
265 ifeq (win, $(PLATFORM))
266         mkdir $(BUILD)/jar/content/hacks/win
267         cp $(SRC)/Resources/chrome/content/hacks/win/*.xul $(BUILD)/jar/content/hacks/win/
268 #       cp $(SRC)/Resources/chrome/content/hacks/win/*.js $(BUILD)/jar/content/hacks/win/
269 endif
270 ifeq (linux, $(PLATFORM))
271         mkdir content/hacks/unix
272         cp $(SRC)/Resources/chrome/content/hacks/unix/*.xul $(BUILD)/jar/content/hacks/unix/
273 #       cp $(SRC)/Resources/chrome/content/hacks/unix/*.js $(BUILD)/jar/content/hacks/unix/
274 endif
275         mkdir $(BUILD)/jar/locale
276         mkdir $(BUILD)/jar/locale/branding
277         cp $(SRC)/Resources/chrome/locale/branding/*.* $(BUILD)/jar/locale/branding/
278         mkdir $(BUILD)/jar/locale/$(INTL)
279         cp $(SRC)/Resources/chrome/locale/$(INTL)/*.* $(BUILD)/jar/locale/$(INTL)/
280         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/chrome/chrome.manifest.prod > \
281                 $(RES)/chrome/chrome.manifest
282         mkdir $(BUILD)/jar/skin
283 #ifeq (mac, $(PLATFORM))
284 #       mkdir $(BUILD)/jar/skin/hacks
285 #       mkdir $(BUILD)/jar/skin/hacks/mac
286 #       cp $(SRC)/Resources/chrome/skin/hacks/mac/hacks.css $(BUILD)/jar/skin/hacks/mac/
287 #endif
288 #ifeq (win, $(PLATFORM))
289 #       mkdir $(BUILD)/jar/skin/hacks/win
290 #       cp $(SRC)/Resources/chrome/skin/hacks/win/hacks.css $(BUILD)/jar/skin/hacks/win/
291 #endif
292 #ifeq (linux, $(PLATFORM))
293 #       mkdir $(BUILD)/jar/skin/hacks/unix
294 #       cp $(SRC)/Resources/chrome/skin/hacks/unix/hacks.css $(BUILD)/jar/skin/hacks/unix/
295 #endif
296         mkdir $(BUILD)/jar/skin/uploadr
297         cp $(SRC)/Resources/chrome/skin/uploadr/*.css $(BUILD)/jar/skin/uploadr/
298         cp $(SRC)/Resources/chrome/skin/uploadr/*.gif $(BUILD)/jar/skin/uploadr/
299         cp $(SRC)/Resources/chrome/skin/uploadr/*.png $(BUILD)/jar/skin/uploadr/
300 ifeq (win, $(PLATFORM))
301         cd $(BUILD)/jar/ && zip uploadr.zip -r content locale skin
302 else
303         cd $(BUILD)/jar/ && zip uploadr -r content locale skin
304 endif
305         mv $(BUILD)/jar/uploadr.zip $(RES)/chrome/uploadr.jar
306         rm -rf $(BUILD)/jar
307
308         @# XPCOM
309         mkdir $(RES)/components
310         cp $(SRC)/Resources/components/*.xpt $(RES)/components/
311 ifeq (mac, $(PLATFORM))
312         cp $(SRC)/Resources/components/*.dylib $(RES)/components/
313 endif
314 ifeq (win, $(PLATFORM))
315         cp $(SRC)/Resources/components/*.dll $(RES)/components/
316 endif
317 ifeq (linux, $(PLATFORM))
318         cp $(SRC)/Resources/components/*.so $(RES)/components/
319 endif
320         cp $(SRC)/Resources/components/*.js $(RES)/components/
321
322         @# Create DMG for Macs
323 ifeq (mac, $(PLATFORM))
324         ln -s /Applications $(BUILD)/Applications
325         cp mac_installer/install-pane-$(INTL_SHORT).png $(BUILD)/.i.png
326         cp mac_installer/DS_Store $(BUILD)/.DS_Store
327         rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
328         hdiutil create -srcfolder $(BUILD) -volname "Flickr Uploadr $(VER)" \
329                 -format UDZO -imagekey zlib-level=9 \
330                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
331 endif
332
333         @# Create NSIS installer for Windows
334 ifeq (win, $(PLATFORM))
335
336         #
337         # build the NSIS config file. convert it to UCS-2
338         #
339
340         sed 's/English/$(INTL_WIN)/g' win_installer/build.nsi > \
341                 $(BUILD)/windows_install.temp
342         perl -e 'print chr(255).chr(254)' > \
343                 $(BUILD)/windows_install_build-$(INTL_SHORT).nsi
344
345         perl -pe 's/(.)/$$1\0/sg' $(BUILD)/windows_install.temp >> \
346                 $(BUILD)/windows_install_build-$(INTL_SHORT).nsi
347         rm $(BUILD)/windows_install.temp
348
349         cp win_installer/strings-$(INTL_WIN).nsh $(BUILD)/strings-$(INTL_WIN).nsh
350
351         $(MAKE_NSIS) -DVERSION=$(VER) \
352                 -DVERSION_DATE=$(VER_DATE) $(BUILD)/windows_install_build-$(INTL_SHORT).nsi
353
354         mv $(BUILD)/FlickrUploadr-$(VER)-XX.exe \
355                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).exe
356
357         rm $(BUILD)/windows_install_build-$(INTL_SHORT).nsi
358         rm $(BUILD)/strings-$(INTL_WIN).nsh
359 endif
360
361         @# Create ??? for Linux
362 ifeq (linux, $(PLATFORM))
363 endif
364
365
366
367 mar:
368
369         @# Making MAR files
370 ifeq (mac, $(PLATFORM))
371         @ln -s Flickr\ Uploadr.app $(BUILD)/new
372 endif
373 ifeq (win, $(PLATFORM))
374         @# In Windows, `ln -s ...` == `cp -R ...`
375         @ln -s $(BUILD)/Flickr\ Uploadr $(BUILD)/new
376 endif
377 ifeq (linux, $(PLATFORM))
378         @ln -s Flickr\ Uploadr $(BUILD)/new
379 endif
380         @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar
381         @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
382                 $(MOZILLA)/tools/update-packaging/make_full_update.sh \
383                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar \
384                 $(BUILD)/new &> /dev/null
385 #       @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar
386 #       @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
387 #               $(MOZILLA)/tools/update-packaging/make_incremental_update.sh \
388 #               $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar \
389 #               $(BUILD)/old $(BUILD)/new &> /dev/null
390 ifeq (win, $(PLATFORM))
391         @rm -rf $(BUILD)/new
392 else
393         @rm $(BUILD)/new
394 endif
395
396         @# Size and hash for the XML file
397 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
398 #               awk '{print "$(INTL) complete size: ",$$5}'
399 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
400 #               awk '{print "$(INTL) complete MD5:  ",$$4}'
401 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
402 #               awk '{print "$(INTL) partial size: ",$$5}'
403 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
404 #               awk '{print "$(INTL) partial MD5:  ",$$4}'
Note: See TracBrowser for help on using the browser.