root/trunk/uploadr/Makefile

Revision 355, 11.4 kB (checked in by calh, 2 years ago)

no longer need version numbers in the makefile (pulled from application.ini). rearranged windows config stuff to have less options and be more sensible. build the uploadr.jar inside the builds folder instead of in the source 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 DMGs
75 OUT := /c/code/uploadr
76
77 # below here, don't modify anything
78
79 # Dated version for the NSIS installer - this comes from application.ini
80 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/'`;
81
82 # Location for build staging
83 BUILD := $(OUT)/builds/$(INTL)
84
85 # Location for application bundle staging
86 APP := $(BUILD)/$(APPNAME)
87
88 # Location for resource file (chrome, components, etc) staging
89 RES := $(APP)
90
91 # End Windows configuration
92 ########################################################################
93
94 ########################################################################
95 # Mac configuration
96
97 else
98 PLATFORM := mac
99
100 # GraphicsMagick version for stupid directory structure
101 GM_VER := 1.1.10
102
103 # Location of Mozilla tree for the MAR tools
104 MOZILLA := ~/mozilla
105
106 # Location for build staging
107 #   The base of this path must exist before running make
108 BUILD := ~/Desktop/builds/$(INTL)
109
110 # Location for application bundle staging
111 APP := $(BUILD)/Flickr\ Uploadr.app
112
113 # Location for resource file (chrome, components, etc) staging
114 RES := $(APP)/Contents/Resources
115
116 # Location to output finished DMGs
117 OUT := ~/Desktop
118
119 # End Mac configuration
120 ########################################################################
121
122 endif
123
124 # End configuration
125 ########################################################################
126 ########################################################################
127
128
129
130 dummy:
131         @echo "Nothing happens if you don't give some arguments!"
132         @echo "  win all, mac all:   Build the whole thing"
133         @echo "  build, mar: Build a single package or update but requires"
134         @echo "              de-de, en-US, es-us, fr-fr, it-it, ko-kr, pt-br, or zh-hk"
135
136 all: all-build all-mar
137
138 mac:
139         @echo "Building for Mac"
140 win:
141         @echo "Building for Windows"
142
143 all-build:
144         make $(PLATFORM) de-de build
145         make $(PLATFORM) en-US build
146         make $(PLATFORM) es-us build
147         make $(PLATFORM) fr-fr build
148         make $(PLATFORM) it-it build
149         make $(PLATFORM) ko-kr build
150         make $(PLATFORM) pt-br build
151         make $(PLATFORM) zh-hk 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
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
182
183
184 build:
185
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 ifeq (mac, $(PLATFORM))
221         cp -R $(SRC)/Frameworks/XUL.framework $(APP)/Contents/Frameworks/
222         cp $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/xulrunner \
223                 $(APP)/Contents/MacOS/xulrunner
224         cp $(SRC)/Resources/application.ini $(RES)/
225         cp $(SRC)/Resources/LICENSE.txt $(RES)/
226         cp $(SRC)/Resources/icons.icns $(RES)/
227 else
228         cp -R $(SRC)/Resources/xulrunner $(RES)/
229         cp $(SRC)/Resources/Flickr\ Uploadr.exe $(RES)/
230 endif
231
232         @# XULRunner preferences
233         mkdir -p $(RES)/defaults/preferences
234         cp $(SRC)/Resources/defaults/preferences/*.js \
235                 $(RES)/defaults/preferences/
236         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/defaults/preferences/prefs.js > \
237                 $(RES)/defaults/preferences/prefs.js
238
239         @# XULRunner locale
240 ifeq (mac, $(PLATFORM))
241         rm $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/??-??.*
242         cp ./xulrunner_locales/$(INTL).* \
243                 $(APP)/Contents/Frameworks/XUL.framework/Versions/Current/chrome/
244 else
245         rm $(RES)/xulrunner/chrome/??-??.*
246         cp ./xulrunner_locales/$(INTL).* $(RES)/xulrunner/chrome/
247 endif
248
249         @# Chrome
250         mkdir $(RES)/chrome
251         mkdir $(BUILD)/jar
252         mkdir $(BUILD)/jar/content
253         mkdir $(BUILD)/jar/content/uploadr
254         cp $(SRC)/Resources/chrome/content/uploadr/*.* $(BUILD)/jar/content/uploadr/
255         mkdir $(BUILD)/jar/content/hacks
256 ifeq (mac, $(PLATFORM))
257         mkdir $(BUILD)/jar/content/hacks/mac
258         cp $(SRC)/Resources/chrome/content/hacks/mac/*.xul $(BUILD)/jar/content/hacks/mac/
259 #       cp $(SRC)/Resources/chrome/content/hacks/mac/*.js $(BUILD)/jar/content/hacks/mac/
260 endif
261 ifeq (win, $(PLATFORM))
262         mkdir $(BUILD)/jar/content/hacks/win
263         cp $(SRC)/Resources/chrome/content/hacks/win/*.xul $(BUILD)/jar/content/hacks/win/
264 #       cp $(SRC)/Resources/chrome/content/hacks/win/*.js $(BUILD)/jar/content/hacks/win/
265 endif
266 ifeq (linux, $(PLATFORM))
267         mkdir content/hacks/unix
268         cp $(SRC)/Resources/chrome/content/hacks/unix/*.xul $(BUILD)/jar/content/hacks/unix/
269 #       cp $(SRC)/Resources/chrome/content/hacks/unix/*.js $(BUILD)/jar/content/hacks/unix/
270 endif
271         mkdir $(BUILD)/jar/locale
272         mkdir $(BUILD)/jar/locale/branding
273         cp $(SRC)/Resources/chrome/locale/branding/*.* $(BUILD)/jar/locale/branding/
274         mkdir $(BUILD)/jar/locale/$(INTL)
275         cp $(SRC)/Resources/chrome/locale/$(INTL)/*.* $(BUILD)/jar/locale/$(INTL)/
276         sed 's/en-US/$(INTL)/g' $(SRC)/Resources/chrome/chrome.manifest.prod > \
277                 $(RES)/chrome/chrome.manifest
278         mkdir $(BUILD)/jar/skin
279 #ifeq (mac, $(PLATFORM))
280 #       mkdir $(BUILD)/jar/skin/hacks
281 #       mkdir $(BUILD)/jar/skin/hacks/mac
282 #       cp $(SRC)/Resources/chrome/skin/hacks/mac/hacks.css $(BUILD)/jar/skin/hacks/mac/
283 #endif
284 #ifeq (win, $(PLATFORM))
285 #       mkdir $(BUILD)/jar/skin/hacks/win
286 #       cp $(SRC)/Resources/chrome/skin/hacks/win/hacks.css $(BUILD)/jar/skin/hacks/win/
287 #endif
288 #ifeq (linux, $(PLATFORM))
289 #       mkdir $(BUILD)/jar/skin/hacks/unix
290 #       cp $(SRC)/Resources/chrome/skin/hacks/unix/hacks.css $(BUILD)/jar/skin/hacks/unix/
291 #endif
292         mkdir $(BUILD)/jar/skin/uploadr
293         cp $(SRC)/Resources/chrome/skin/uploadr/*.css $(BUILD)/jar/skin/uploadr/
294         cp $(SRC)/Resources/chrome/skin/uploadr/*.gif $(BUILD)/jar/skin/uploadr/
295         cp $(SRC)/Resources/chrome/skin/uploadr/*.png $(BUILD)/jar/skin/uploadr/
296 ifeq (win, $(PLATFORM))
297         cd $(BUILD)/jar/ && zip uploadr.zip -r content locale skin
298 else
299         cd $(BUILD)/jar/ && zip uploadr -r content locale skin
300 endif
301         mv $(BUILD)/jar/uploadr.zip $(RES)/chrome/uploadr.jar
302         rm -rf $(BUILD)/jar
303
304         @# XPCOM
305         mkdir $(RES)/components
306         cp $(SRC)/Resources/components/*.xpt $(RES)/components/
307 ifeq (mac, $(PLATFORM))
308         cp $(SRC)/Resources/components/*.dylib $(RES)/components/
309 endif
310 ifeq (win, $(PLATFORM))
311         cp $(SRC)/Resources/components/*.dll $(RES)/components/
312 endif
313 ifeq (linux, $(PLATFORM))
314         cp $(SRC)/Resources/components/*.so $(RES)/components/
315 endif
316         cp $(SRC)/Resources/components/*.js $(RES)/components/
317
318         @# Create DMG for Macs
319 ifeq (mac, $(PLATFORM))
320         ln -s /Applications $(BUILD)/Applications
321         cp mac_installer/install-pane-$(INTL_SHORT).png $(BUILD)/.i.png
322         cp mac_installer/DS_Store $(BUILD)/.DS_Store
323         rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
324         hdiutil create -srcfolder $(BUILD) -volname "Flickr Uploadr $(VER)" \
325                 -format UDZO -imagekey zlib-level=9 \
326                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).dmg
327 endif
328
329         @# Create NSIS installer for Windows
330 ifeq (win, $(PLATFORM))
331
332         @# TODO: This is broken in Windows because the *.nsi and *.nsh files
333         @# are stored as Windows Unicode, which is UTF-16 or UCS-2
334         sed 's/English/$(INTL_WIN)/g' windows_install_build.nsi > \
335                 windows_install_build-$(INTL_SHORT).nsi
336
337         /c/Program\ Files/NSISUnicode/makensis.exe -DVERSION=$(VER) \
338                 -DVERSION_DATE=$(VER_DATE) windows_install_build-$(INTL_SHORT).nsi
339         mv FlickrUploadr-$(VER)-XX.exe \
340                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).exe
341 #       rm windows_install_build-$(INTL_SHORT).nsi
342 endif
343
344         @# Create ??? for Linux
345 ifeq (linux, $(PLATFORM))
346 endif
347
348
349
350 mar:
351
352         @# Making MAR files
353 ifeq (mac, $(PLATFORM))
354         @ln -s Flickr\ Uploadr.app $(BUILD)/new
355 endif
356 ifeq (win, $(PLATFORM))
357         @# In Windows, `ln -s ...` == `cp -R ...`
358         @ln -s $(BUILD)/Flickr\ Uploadr $(BUILD)/new
359 endif
360 ifeq (linux, $(PLATFORM))
361         @ln -s Flickr\ Uploadr $(BUILD)/new
362 endif
363         @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar
364         @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
365                 $(MOZILLA)/tools/update-packaging/make_full_update.sh \
366                 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar \
367                 $(BUILD)/new &> /dev/null
368 #       @rm -f $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar
369 #       @PATH="$(PATH):$(MOZILLA)/other-licenses/bsdiff:$(MOZILLA)/modules/libmar/tool" \
370 #               $(MOZILLA)/tools/update-packaging/make_incremental_update.sh \
371 #               $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar \
372 #               $(BUILD)/old $(BUILD)/new &> /dev/null
373 ifeq (win, $(PLATFORM))
374         @rm -rf $(BUILD)/new
375 else
376         @rm $(BUILD)/new
377 endif
378
379         @# Size and hash for the XML file
380 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
381 #               awk '{print "$(INTL) complete size: ",$$5}'
382 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).complete.mar | \
383 #               awk '{print "$(INTL) complete MD5:  ",$$4}'
384 #       @ls -l $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
385 #               awk '{print "$(INTL) partial size: ",$$5}'
386 #       @md5 $(OUT)/FlickrUploadr-$(VER)-$(INTL_SHORT).partial.mar | \
387 #               awk '{print "$(INTL) partial MD5:  ",$$4}'
Note: See TracBrowser for help on using the browser.