Backed out changeset 0d93633ce739 due to bug 631006, a=LegNeato
[mozilla-central.git] / toolkit / mozapps / installer / packager.mk
blob6be7577c0ccc15ac82db733f80cf212e12317325
1 # ***** BEGIN LICENSE BLOCK *****
2 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 # The contents of this file are subject to the Mozilla Public License Version
5 # 1.1 (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 # http://www.mozilla.org/MPL/
9 # Software distributed under the License is distributed on an "AS IS" basis,
10 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 # for the specific language governing rights and limitations under the
12 # License.
14 # The Original Code is Mozilla Communicator client code, released
15 # March 31, 1998.
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 1998
20 # the Initial Developer. All Rights Reserved.
22 # Contributor(s):
23 # Benjamin Smedberg <bsmedberg@covad.net>
24 # Arthur Wiebe <artooro@gmail.com>
25 # Mark Mentovai <mark@moxienet.com>
27 # Alternatively, the contents of this file may be used under the terms of
28 # either of the GNU General Public License Version 2 or later (the "GPL"),
29 # or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 # in which case the provisions of the GPL or the LGPL are applicable instead
31 # of those above. If you wish to allow use of your version of this file only
32 # under the terms of either the GPL or the LGPL, and not to allow others to
33 # use your version of this file under the terms of the MPL, indicate your
34 # decision by deleting the provisions above and replace them with the notice
35 # and other provisions required by the GPL or the LGPL. If you do not delete
36 # the provisions above, a recipient may use your version of this file under
37 # the terms of any one of the MPL, the GPL or the LGPL.
39 # ***** END LICENSE BLOCK *****
41 include $(MOZILLA_DIR)/toolkit/mozapps/installer/package-name.mk
43 # This is how we create the binary packages we release to the public.
45 ifndef MOZ_PKG_FORMAT
46 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
47 MOZ_PKG_FORMAT = DMG
48 else
49 ifeq (,$(filter-out OS2 WINNT WINCE BeOS, $(OS_ARCH)))
50 MOZ_PKG_FORMAT = ZIP
51 else
52 ifeq (,$(filter-out SunOS, $(OS_ARCH)))
53 MOZ_PKG_FORMAT = BZ2
54 else
55 ifeq (,$(filter-out gtk2 qt, $(MOZ_WIDGET_TOOLKIT)))
56 MOZ_PKG_FORMAT = BZ2
57 else
58 ifeq (Android,$(OS_TARGET))
59 MOZ_PKG_FORMAT = APK
60 else
61 MOZ_PKG_FORMAT = TGZ
62 endif
63 endif
64 endif
65 endif
66 endif
67 endif # MOZ_PKG_FORMAT
69 ifeq ($(OS_ARCH),OS2)
70 INSTALLER_DIR = os2
71 else
72 ifneq (,$(filter WINNT WINCE,$(OS_ARCH)))
73 INSTALLER_DIR = windows
74 else
75 ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))
76 INSTALLER_DIR = unix
77 endif
78 endif
79 endif
81 PACKAGE = $(PKG_PATH)$(PKG_BASENAME)$(PKG_SUFFIX)
83 # By default, the SDK uses the same packaging type as the main bundle,
84 # but on mac it is a .tar.bz2
85 SDK_PATH = $(PKG_PATH)
86 ifeq ($(MOZ_APP_NAME),xulrunner)
87 SDK_PATH = sdk/
88 endif
89 SDK_SUFFIX = $(PKG_SUFFIX)
90 SDK = $(SDK_PATH)$(PKG_BASENAME).sdk$(SDK_SUFFIX)
92 MAKE_PACKAGE = $(error What is a $(MOZ_PKG_FORMAT) package format?);
93 MAKE_CAB = $(error Don't know how to make a CAB!);
94 _ABS_DIST = $(call core_abspath,$(DIST))
96 ifdef WINCE
97 ifndef WINCE_WINDOWS_MOBILE
98 CABARGS += -s
99 endif
100 ifdef MOZ_FASTSTART
101 CABARGS += -faststart
102 endif
103 VSINSTALLDIR ?= $(error VSINSTALLDIR not set, must be set to the Visual Studio install directory)
104 MAKE_CAB = $(PYTHON) $(MOZILLA_DIR)/build/package/wince/make_wince_cab.py \
105 $(CABARGS) "$(VSINSTALLDIR)/SmartDevices/SDK/SDKTools/cabwiz.exe" \
106 "$(MOZ_PKG_DIR)" "$(MOZ_APP_DISPLAYNAME)" "$(PKG_PATH)$(PKG_BASENAME).cab"
107 endif
109 CREATE_FINAL_TAR = $(TAR) -c --owner=0 --group=0 --numeric-owner \
110 --mode="go-w" -f
111 UNPACK_TAR = tar -xf-
113 ifeq ($(MOZ_PKG_FORMAT),TAR)
114 PKG_SUFFIX = .tar
115 INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) > $(PACKAGE)
116 INNER_UNMAKE_PACKAGE = $(UNPACK_TAR) < $(UNPACKAGE)
117 MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk > $(SDK)
118 endif
119 ifeq ($(MOZ_PKG_FORMAT),TGZ)
120 PKG_SUFFIX = .tar.gz
121 INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) | gzip -vf9 > $(PACKAGE)
122 INNER_UNMAKE_PACKAGE = gunzip -c $(UNPACKAGE) | $(UNPACK_TAR)
123 MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | gzip -vf9 > $(SDK)
124 endif
125 ifeq ($(MOZ_PKG_FORMAT),BZ2)
126 PKG_SUFFIX = .tar.bz2
127 INNER_MAKE_PACKAGE = $(CREATE_FINAL_TAR) - $(MOZ_PKG_DIR) | bzip2 -vf > $(PACKAGE)
128 INNER_UNMAKE_PACKAGE = bunzip2 -c $(UNPACKAGE) | $(UNPACK_TAR)
129 MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | bzip2 -vf > $(SDK)
130 endif
131 ifeq ($(MOZ_PKG_FORMAT),ZIP)
132 PKG_SUFFIX = .zip
133 INNER_MAKE_PACKAGE = $(ZIP) -r9D $(PACKAGE) $(MOZ_PKG_DIR)
134 INNER_UNMAKE_PACKAGE = $(UNZIP) $(UNPACKAGE)
135 MAKE_SDK = $(ZIP) -r9D $(SDK) $(MOZ_APP_NAME)-sdk
136 endif
137 ifeq ($(MOZ_PKG_FORMAT),CAB)
138 PKG_SUFFIX = .cab
139 INNER_MAKE_PACKAGE = $(MAKE_CAB)
140 INNER_UNMAKE_PACKAGE = $(error Unpacking CAB files is not supported)
141 endif
142 ifeq ($(MOZ_PKG_FORMAT),SFX7Z)
143 PKG_SUFFIX = .exe
144 INNER_MAKE_PACKAGE = rm -f app.7z && \
145 mv $(MOZ_PKG_DIR) core && \
146 $(CYGWIN_WRAPPER) 7z a -r -t7z app.7z -mx -m0=BCJ2 -m1=LZMA:d24 \
147 -m2=LZMA:d19 -m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3 && \
148 mv core $(MOZ_PKG_DIR) && \
149 cat $(SFX_HEADER) app.7z > $(PACKAGE) && \
150 chmod 0755 $(PACKAGE)
151 INNER_UNMAKE_PACKAGE = $(CYGWIN_WRAPPER) 7z x $(UNPACKAGE) && \
152 mv core $(MOZ_PKG_DIR)
153 endif
154 ifeq ($(MOZ_PKG_FORMAT),APK)
156 # we have custom stuff for Android
157 MOZ_OMNIJAR =
159 JAVA_CLASSPATH = $(ANDROID_SDK)/android.jar
160 include $(topsrcdir)/config/android-common.mk
162 JARSIGNER ?= echo
164 DIST_FILES = \
165 resources.arsc \
166 AndroidManifest.xml \
167 chrome \
168 components \
169 defaults \
170 modules \
171 res \
172 lib \
173 lib.id \
174 extensions \
175 application.ini \
176 platform.ini \
177 greprefs.js \
178 browserconfig.properties \
179 blocklist.xml \
180 chrome.manifest \
181 update.locale \
182 $(NULL)
184 NON_DIST_FILES = \
185 classes.dex \
186 $(NULL)
188 UPLOAD_EXTRA_FILES += gecko-unsigned-unaligned.apk
190 include $(topsrcdir)/ipc/app/defs.mk
192 ifdef MOZ_IPC
193 DIST_FILES += $(MOZ_CHILD_PROCESS_NAME)
194 endif
196 ifdef MOZ_THUMB2
197 ABI_DIR = armeabi-v7a
198 else
199 ABI_DIR = armeabi
200 endif
202 PKG_SUFFIX = .apk
203 INNER_MAKE_PACKAGE = \
204 make -C ../embedding/android gecko.ap_ && \
205 cp ../embedding/android/gecko.ap_ $(_ABS_DIST) && \
206 ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \
207 rm -rf lib && \
208 mkdir -p lib/$(ABI_DIR) && \
209 cp lib*.so lib && \
210 mv lib/libmozutils.so lib/$(ABI_DIR) && \
211 rm -f lib.id && \
212 for SOMELIB in lib/*.so ; \
213 do \
214 printf "`basename $$SOMELIB`:`$(_ABS_DIST)/host/bin/file_id $$SOMELIB`\n" >> lib.id ; \
215 done && \
216 unzip -o $(_ABS_DIST)/gecko.ap_ && \
217 rm $(_ABS_DIST)/gecko.ap_ && \
218 $(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) ) && \
219 rm -f $(_ABS_DIST)/gecko.apk && \
220 $(APKBUILDER) $(_ABS_DIST)/gecko.apk -v $(APKBUILDER_FLAGS) -z $(_ABS_DIST)/gecko.ap_ -f $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex && \
221 cp $(_ABS_DIST)/gecko.apk $(_ABS_DIST)/gecko-unsigned-unaligned.apk && \
222 $(JARSIGNER) $(_ABS_DIST)/gecko.apk && \
223 $(ZIPALIGN) -f -v 4 $(_ABS_DIST)/gecko.apk $(PACKAGE)
224 INNER_UNMAKE_PACKAGE = \
225 mkdir $(MOZ_PKG_DIR) && \
226 cd $(MOZ_PKG_DIR) && \
227 $(UNZIP) $(UNPACKAGE) && \
228 mv lib/$(ABI_DIR)/*.so . && \
229 mv lib/*.so . && \
230 rm -rf lib
231 endif
232 ifeq ($(MOZ_PKG_FORMAT),DMG)
233 ifndef _APPNAME
234 ifdef MOZ_DEBUG
235 _APPNAME = $(MOZ_APP_DISPLAYNAME)Debug.app
236 else
237 _APPNAME = $(MOZ_APP_DISPLAYNAME).app
238 endif
239 endif
240 ifndef _BINPATH
241 _BINPATH = /$(_APPNAME)/Contents/MacOS
242 endif # _BINPATH
243 PKG_SUFFIX = .dmg
244 PKG_DMG_FLAGS =
245 ifneq (,$(MOZ_PKG_MAC_DSSTORE))
246 PKG_DMG_FLAGS += --copy "$(MOZ_PKG_MAC_DSSTORE):/.DS_Store"
247 endif
248 ifneq (,$(MOZ_PKG_MAC_BACKGROUND))
249 PKG_DMG_FLAGS += --mkdir /.background --copy "$(MOZ_PKG_MAC_BACKGROUND):/.background"
250 endif
251 ifneq (,$(MOZ_PKG_MAC_ICON))
252 PKG_DMG_FLAGS += --icon "$(MOZ_PKG_MAC_ICON)"
253 endif
254 ifneq (,$(MOZ_PKG_MAC_RSRC))
255 PKG_DMG_FLAGS += --resource "$(MOZ_PKG_MAC_RSRC)"
256 endif
257 ifneq (,$(MOZ_PKG_MAC_EXTRA))
258 PKG_DMG_FLAGS += $(MOZ_PKG_MAC_EXTRA)
259 endif
260 _ABS_MOZSRCDIR = $(shell cd $(MOZILLA_DIR) && pwd)
261 ifdef UNIVERSAL_BINARY
262 STAGEPATH = universal/
263 endif
264 ifndef PKG_DMG_SOURCE
265 PKG_DMG_SOURCE = $(STAGEPATH)$(MOZ_PKG_DIR)
266 endif
267 INNER_MAKE_PACKAGE = $(_ABS_MOZSRCDIR)/build/package/mac_osx/pkg-dmg \
268 --source "$(PKG_DMG_SOURCE)" --target "$(PACKAGE)" \
269 --volname "$(MOZ_APP_DISPLAYNAME)" $(PKG_DMG_FLAGS)
270 INNER_UNMAKE_PACKAGE = \
271 set -ex; \
272 rm -rf $(_ABS_DIST)/unpack.tmp; \
273 mkdir -p $(_ABS_DIST)/unpack.tmp; \
274 $(_ABS_MOZSRCDIR)/build/package/mac_osx/unpack-diskimage $(UNPACKAGE) /tmp/$(MOZ_PKG_APPNAME)-unpack $(_ABS_DIST)/unpack.tmp; \
275 rsync -a "$(_ABS_DIST)/unpack.tmp/$(_APPNAME)" $(MOZ_PKG_DIR); \
276 test -n "$(MOZ_PKG_MAC_DSSTORE)" && \
277 rsync -a "$(_ABS_DIST)/unpack.tmp/.DS_Store" "$(MOZ_PKG_MAC_DSSTORE)"; \
278 test -n "$(MOZ_PKG_MAC_BACKGROUND)" && \
279 rsync -a "$(_ABS_DIST)/unpack.tmp/.background/`basename "$(MOZ_PKG_MAC_BACKGROUND)"`" "$(MOZ_PKG_MAC_BACKGROUND)"; \
280 test -n "$(MOZ_PKG_MAC_ICON)" && \
281 rsync -a "$(_ABS_DIST)/unpack.tmp/.VolumeIcon.icns" "$(MOZ_PKG_MAC_ICON)"; \
282 rm -rf $(_ABS_DIST)/unpack.tmp; \
283 if test -n "$(MOZ_PKG_MAC_RSRC)" ; then \
284 cp $(UNPACKAGE) $(MOZ_PKG_APPNAME).tmp.dmg && \
285 hdiutil unflatten $(MOZ_PKG_APPNAME).tmp.dmg && \
286 { /Developer/Tools/DeRez -skip plst -skip blkx $(MOZ_PKG_APPNAME).tmp.dmg > "$(MOZ_PKG_MAC_RSRC)" || { rm -f $(MOZ_PKG_APPNAME).tmp.dmg && false; }; } && \
287 rm -f $(MOZ_PKG_APPNAME).tmp.dmg; \
289 # The plst and blkx resources are skipped because they belong to each
290 # individual dmg and are created by hdiutil.
291 SDK_SUFFIX = .tar.bz2
292 SDK = $(MOZ_PKG_APPNAME)-$(MOZ_PKG_VERSION).$(AB_CD).mac-$(TARGET_CPU).sdk$(SDK_SUFFIX)
293 ifeq ($(MOZ_APP_NAME),xulrunner)
294 SDK = $(SDK_PATH)$(MOZ_APP_NAME)-$(MOZ_PKG_VERSION).$(AB_CD).mac-$(TARGET_CPU).sdk$(SDK_SUFFIX)
295 endif
296 MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | bzip2 -vf > $(SDK)
297 endif
299 ifdef MOZ_OMNIJAR
300 OMNIJAR_FILES = \
301 chrome \
302 chrome.manifest \
303 components/*.js \
304 components/*.xpt \
305 components/*.manifest \
306 modules \
307 res \
308 defaults \
309 greprefs.js \
310 jsloader \
311 $(NULL)
313 NON_OMNIJAR_FILES += \
314 chrome/icons/\* \
315 defaults/pref/channel-prefs.js \
316 res/cursors/\* \
317 res/MainMenu.nib/\* \
318 $(NULL)
320 PACK_OMNIJAR = \
321 rm -f omni.jar components/binary.manifest && \
322 grep -h '^binary-component' components/*.manifest > binary.manifest ; \
323 sed -e 's/^binary-component/\#binary-component/' components/components.manifest > components.manifest && \
324 mv components.manifest components && \
325 find . | xargs touch -t 201001010000 && \
326 zip -r9mX omni.jar $(OMNIJAR_FILES) -x $(NON_OMNIJAR_FILES) && \
327 $(OPTIMIZE_JARS_CMD) --optimize $(_ABS_DIST)/jarlog/ ./ ./ && \
328 mv binary.manifest components && \
329 printf "manifest components/binary.manifest\n" > chrome.manifest
330 UNPACK_OMNIJAR = \
331 $(OPTIMIZE_JARS_CMD) --deoptimize $(_ABS_DIST)/jarlog/ ./ ./ && \
332 unzip -o omni.jar && \
333 rm -f components/binary.manifest && \
334 sed -e 's/^\#binary-component/binary-component/' components/components.manifest > components.manifest && \
335 mv components.manifest components
337 MAKE_PACKAGE = (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR)) && $(INNER_MAKE_PACKAGE)
338 UNMAKE_PACKAGE = $(INNER_UNMAKE_PACKAGE) && (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(UNPACK_OMNIJAR))
339 else
340 MAKE_PACKAGE = $(INNER_MAKE_PACKAGE)
341 UNMAKE_PACKAGE = $(INNER_UNMAKE_PACKAGE)
342 endif
344 # dummy macro if we don't have PSM built
345 SIGN_NSS =
346 ifneq (1_,$(if $(CROSS_COMPILE),1,0)_$(UNIVERSAL_BINARY))
347 ifdef MOZ_PSM
348 SIGN_NSS = @echo signing nss libraries;
350 NSS_DLL_SUFFIX = $(DLL_SUFFIX)
351 ifdef UNIVERSAL_BINARY
352 NATIVE_ARCH = $(shell uname -p | sed -e s/powerpc/ppc/)
353 NATIVE_DIST = $(DIST:$(DEPTH)/%=$(DEPTH)/../$(NATIVE_ARCH)/%)
354 SIGN_CMD = $(NATIVE_DIST)/bin/run-mozilla.sh $(NATIVE_DIST)/bin/shlibsign -v -i
355 else
356 ifeq ($(OS_ARCH),OS2)
357 # uppercase extension to get the correct output file from shlibsign
358 NSS_DLL_SUFFIX = .DLL
359 SIGN_CMD = $(MOZILLA_DIR)/toolkit/mozapps/installer/os2/sign.cmd $(DIST)
360 else
361 SIGN_CMD = $(RUN_TEST_PROGRAM) $(DIST)/bin/shlibsign$(BIN_SUFFIX) -v -i
362 endif
363 endif
365 SOFTOKN = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)softokn3$(NSS_DLL_SUFFIX)
366 NSSDBM = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)nssdbm3$(NSS_DLL_SUFFIX)
367 FREEBL = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl3$(NSS_DLL_SUFFIX)
368 FREEBL_32FPU = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_32fpu_3$(DLL_SUFFIX)
369 FREEBL_32INT = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_32int_3$(DLL_SUFFIX)
370 FREEBL_32INT64 = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_32int64_3$(DLL_SUFFIX)
371 FREEBL_64FPU = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_64fpu_3$(DLL_SUFFIX)
372 FREEBL_64INT = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_64int_3$(DLL_SUFFIX)
374 SIGN_NSS += $(SIGN_CMD) $(SOFTOKN); \
375 $(SIGN_CMD) $(NSSDBM); \
376 if test -f $(FREEBL); then $(SIGN_CMD) $(FREEBL); fi; \
377 if test -f $(FREEBL_32FPU); then $(SIGN_CMD) $(FREEBL_32FPU); fi; \
378 if test -f $(FREEBL_32INT); then $(SIGN_CMD) $(FREEBL_32INT); fi; \
379 if test -f $(FREEBL_32INT64); then $(SIGN_CMD) $(FREEBL_32INT64); fi; \
380 if test -f $(FREEBL_64FPU); then $(SIGN_CMD) $(FREEBL_64FPU); fi; \
381 if test -f $(FREEBL_64INT); then $(SIGN_CMD) $(FREEBL_64INT); fi;
383 endif # MOZ_PSM
384 endif # !CROSS_COMPILE
386 NO_PKG_FILES += \
387 core \
388 bsdecho \
389 gtscc \
390 js \
391 js-config \
392 jscpucfg \
393 nsinstall \
394 viewer \
395 TestGtkEmbed \
396 codesighs* \
397 elf-dynstr-gc \
398 mangle* \
399 maptsv* \
400 mfc* \
401 mkdepend* \
402 msdump* \
403 msmap* \
404 nm2tsv* \
405 nsinstall* \
406 res/samples \
407 res/throbber \
408 shlibsign* \
409 ssltunnel* \
410 certutil* \
411 pk12util* \
412 winEmbed.exe \
413 chrome/chrome.rdf \
414 chrome/app-chrome.manifest \
415 chrome/overlayinfo \
416 components/compreg.dat \
417 components/xpti.dat \
418 content_unit_tests \
419 necko_unit_tests \
420 *.dSYM \
421 $(NULL)
423 # browser/locales/Makefile uses this makefile for its variable defs, but
424 # doesn't want the libs:: rule.
425 ifndef PACKAGER_NO_LIBS
426 libs:: make-package
427 endif
429 DEFINES += -DDLL_PREFIX=$(DLL_PREFIX) -DDLL_SUFFIX=$(DLL_SUFFIX) -DBIN_SUFFIX=$(BIN_SUFFIX)
431 ifdef MOZ_PKG_REMOVALS
432 MOZ_PKG_REMOVALS_GEN = removed-files
434 $(MOZ_PKG_REMOVALS_GEN): $(MOZ_PKG_REMOVALS) $(GLOBAL_DEPS)
435 cat $(MOZ_PKG_REMOVALS) | \
436 sed -e 's/^[ \t]*//' | \
437 $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py -Fsubstitution $(DEFINES) $(ACDEFINES) > $(MOZ_PKG_REMOVALS_GEN)
439 GARBAGE += $(MOZ_PKG_REMOVALS_GEN)
440 endif
442 GARBAGE += $(DIST)/$(PACKAGE) $(PACKAGE)
444 ifeq ($(OS_ARCH),IRIX)
445 STRIP_FLAGS = -f
446 endif
447 ifeq ($(OS_ARCH),BeOS)
448 STRIP_FLAGS = -g
449 PLATFORM_EXCLUDE_LIST = ! -name "*.stub" ! -name "$(MOZ_PKG_APPNAME)-bin"
450 endif
451 ifeq ($(OS_ARCH),OS2)
452 STRIP = $(MOZILLA_DIR)/toolkit/mozapps/installer/os2/strip.cmd
453 STRIP_FLAGS =
454 PLATFORM_EXCLUDE_LIST = ! -name "*.ico" ! -name "$(MOZ_PKG_APPNAME).exe"
455 endif
457 ifneq (,$(filter WINNT WINCE OS2,$(OS_ARCH)))
458 PKGCP_OS = dos
459 else
460 PKGCP_OS = unix
461 endif
463 # The following target stages files into two directories: one directory for
464 # core files, and one for optional extensions based on the information in
465 # the MOZ_PKG_MANIFEST file and the following vars:
466 # MOZ_NONLOCALIZED_PKG_LIST
467 # MOZ_LOCALIZED_PKG_LIST
468 # MOZ_OPTIONAL_PKG_LIST
470 PKG_ARG = , "$(pkg)"
472 # Define packager macro to work around make 3.81 backslash issue (bug #339933)
473 define PACKAGER_COPY
474 $(PERL) -I$(MOZILLA_DIR)/xpinstall/packager -e 'use Packager; \
475 Packager::Copy($1,$2,$3,$4,$5,$6,$7);'
476 endef
478 installer-stage: stage-package
479 ifndef MOZ_PKG_MANIFEST
480 $(error MOZ_PKG_MANIFEST unspecified!)
481 endif
482 @rm -rf $(DEPTH)/installer-stage $(DIST)/xpt
483 @echo "Staging installer files..."
484 @$(NSINSTALL) -D $(DEPTH)/installer-stage/core
485 ifdef MOZ_OMNIJAR
486 @(cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR))
487 endif
488 @cp -av $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/. $(DEPTH)/installer-stage/core
489 ifdef MOZ_OPTIONAL_PKG_LIST
490 @$(NSINSTALL) -D $(DEPTH)/installer-stage/optional
491 $(call PACKAGER_COPY, "$(call core_abspath,$(DIST))",\
492 "$(call core_abspath,$(DEPTH)/installer-stage/optional)", \
493 "$(MOZ_PKG_MANIFEST)", "$(PKGCP_OS)", 1, 0, 1 \
494 $(foreach pkg,$(MOZ_OPTIONAL_PKG_LIST),$(PKG_ARG)) )
495 @cd $(DEPTH)/installer-stage/optional/extensions; find -maxdepth 1 -mindepth 1 -exec rm -r ../../core/extensions/{} \;
496 endif
498 stage-package: $(MOZ_PKG_MANIFEST) $(MOZ_PKG_REMOVALS_GEN)
499 @rm -rf $(DIST)/$(MOZ_PKG_DIR) $(DIST)/$(PKG_PATH)$(PKG_BASENAME).tar $(DIST)/$(PKG_PATH)$(PKG_BASENAME).dmg $@ $(EXCLUDE_LIST)
500 # NOTE: this must be a tar now that dist links into the tree so that we
501 # do not strip the binaries actually in the tree.
502 @echo "Creating package directory..."
503 @mkdir $(DIST)/$(MOZ_PKG_DIR)
504 ifndef UNIVERSAL_BINARY
505 # If UNIVERSAL_BINARY, the package will be made from an already-prepared
506 # STAGEPATH
507 ifdef MOZ_PKG_MANIFEST
508 $(RM) -rf $(DIST)/xpt $(RM) -rf $(DIST)/manifests
509 $(call PACKAGER_COPY, "$(call core_abspath,$(DIST))",\
510 "$(call core_abspath,$(DIST)/$(MOZ_PKG_DIR))", \
511 "$(MOZ_PKG_MANIFEST)", "$(PKGCP_OS)", 1, 0, 1)
512 $(PERL) $(MOZILLA_DIR)/xpinstall/packager/xptlink.pl -s $(DIST) -d $(DIST)/xpt -f $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/components -v -x "$(XPIDL_LINK)"
513 $(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
514 $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/components/components.manifest \
515 $(patsubst %,$(DIST)/manifests/%/components,$(MOZ_NONLOCALIZED_PKG_LIST))
516 $(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
517 $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome/nonlocalized.manifest \
518 $(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_NONLOCALIZED_PKG_LIST))
519 $(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
520 $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome/localized.manifest \
521 $(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_LOCALIZED_PKG_LIST))
522 printf "manifest components/interfaces.manifest\nmanifest components/components.manifest\nmanifest chrome/nonlocalized.manifest\nmanifest chrome/localized.manifest\n" > $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome.manifest
523 else # !MOZ_PKG_MANIFEST
524 ifeq ($(MOZ_PKG_FORMAT),DMG)
525 ifndef STAGE_SDK
526 @cd $(DIST) && rsync -auv --copy-unsafe-links $(_APPNAME) $(MOZ_PKG_DIR)
527 @echo "Linking XPT files..."
528 @rm -rf $(DIST)/xpt
529 @$(NSINSTALL) -D $(DIST)/xpt
530 @($(XPIDL_LINK) $(DIST)/xpt/$(MOZ_PKG_APPNAME).xpt $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/components/*.xpt && rm -f $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/components/*.xpt && cp $(DIST)/xpt/$(MOZ_PKG_APPNAME).xpt $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/components && printf "interfaces $(MOZ_PKG_APPNAME).xpt\n" >$(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/components/interfaces.manifest) || echo No *.xpt files found in: $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/components/. Continuing...
531 else
532 @cd $(DIST)/bin && tar $(TAR_CREATE_FLAGS) - * | (cd ../$(MOZ_PKG_DIR); tar -xf -)
533 endif
534 else
535 @cd $(DIST)/bin && tar $(TAR_CREATE_FLAGS) - * | (cd ../$(MOZ_PKG_DIR); tar -xf -)
536 @echo "Linking XPT files..."
537 @rm -rf $(DIST)/xpt
538 @$(NSINSTALL) -D $(DIST)/xpt
539 @($(XPIDL_LINK) $(DIST)/xpt/$(MOZ_PKG_APPNAME).xpt $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)/components/*.xpt && rm -f $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)/components/*.xpt && cp $(DIST)/xpt/$(MOZ_PKG_APPNAME).xpt $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)/components && printf "interfaces $(MOZ_PKG_APPNAME).xpt\n" >$(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)/components/interfaces.manifest) || echo No *.xpt files found in: $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)/components/. Continuing...
540 endif # DMG
541 endif # MOZ_PKG_MANIFEST
542 endif # UNIVERSAL_BINARY
543 $(OPTIMIZE_JARS_CMD) --optimize $(DIST)/jarlog/ $(DIST)/bin/chrome $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)/chrome
544 ifeq ($(USE_ELF_HACK)$(HOST_OS_ARCH)$(OS_ARCH),1LinuxLinux)
545 ifneq (,$(filter %86 x86_64 arm,$(OS_TEST)))
546 @echo ===
547 @echo === If you get failures below, please file a bug describing the error
548 @echo === and your environment \(compiler and linker versions\), and use
549 @echo === --disable-elf-hack until this is fixed.
550 @echo ===
551 cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR); find . -name "*$(DLL_SUFFIX)" | xargs $(DEPTH)/build/unix/elfhack/elfhack
552 endif
553 endif
554 ifndef PKG_SKIP_STRIP
555 @echo "Stripping package directory..."
556 @cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR); find . ! -type d \
557 ! -name "*.js" \
558 ! -name "*.xpt" \
559 ! -name "*.gif" \
560 ! -name "*.jpg" \
561 ! -name "*.png" \
562 ! -name "*.xpm" \
563 ! -name "*.txt" \
564 ! -name "*.rdf" \
565 ! -name "*.sh" \
566 ! -name "*.properties" \
567 ! -name "*.dtd" \
568 ! -name "*.html" \
569 ! -name "*.xul" \
570 ! -name "*.css" \
571 ! -name "*.xml" \
572 ! -name "*.jar" \
573 ! -name "*.dat" \
574 ! -name "*.tbl" \
575 ! -name "*.src" \
576 ! -name "*.reg" \
577 $(PLATFORM_EXCLUDE_LIST) \
578 -exec $(STRIP) $(STRIP_FLAGS) {} >/dev/null 2>&1 \;
579 $(SIGN_NSS)
580 else
581 ifdef UNIVERSAL_BINARY
582 # universal binaries will have had their .chk files removed prior to the unify
583 # step, and if they're also --disable-install-strip then they won't get
584 # re-signed in the block above.
585 $(SIGN_NSS)
586 endif # UNIVERSAL_BINARY
587 endif # PKG_SKIP_STRIP
588 @echo "Removing unpackaged files..."
589 ifdef NO_PKG_FILES
590 cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH); rm -rf $(NO_PKG_FILES)
591 endif
592 ifdef MOZ_PKG_REMOVALS
593 $(SYSINSTALL) $(IFLAGS1) $(MOZ_PKG_REMOVALS_GEN) $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)
594 endif # MOZ_PKG_REMOVALS
596 make-package: stage-package $(PACKAGE_XULRUNNER)
597 @echo "Compressing..."
598 $(NSINSTALL) -D $(DIST)/$(PKG_PATH)
599 cd $(DIST) && $(MAKE_PACKAGE)
600 @echo "$(BUILDID) $(MOZ_SOURCE_STAMP)" > $(DIST)/$(PKG_PATH)/$(PKG_BASENAME).txt
602 # The install target will install the application to prefix/lib/appname-version
603 # In addition if INSTALL_SDK is set, it will install the development headers,
604 # libraries, and IDL files as follows:
605 # dist/include -> prefix/include/appname-version
606 # dist/idl -> prefix/share/idl/appname-version
607 # dist/sdk/lib -> prefix/lib/appname-devel-version/lib
608 # prefix/lib/appname-devel-version/* symlinks to the above directories
609 install:: stage-package
610 ifneq (,$(filter WINNT WINCE,$(OS_ARCH)))
611 $(error "make install" is not supported on this platform. Use "make package" instead.)
612 endif
613 ifeq (bundle,$(MOZ_FS_LAYOUT))
614 $(error "make install" is not supported on this platform. Use "make package" instead.)
615 endif
616 ifdef MOZ_OMNIJAR
617 cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR)
618 endif
619 $(NSINSTALL) -D $(DESTDIR)$(installdir)
620 (cd $(DIST)/$(MOZ_PKG_DIR) && tar $(TAR_CREATE_FLAGS) - .) | \
621 (cd $(DESTDIR)$(installdir) && tar -xf -)
622 $(NSINSTALL) -D $(DESTDIR)$(bindir)
623 $(RM) -f $(DESTDIR)$(bindir)/$(MOZ_APP_NAME)
624 ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
625 ifdef INSTALL_SDK # Here comes the hard part
626 $(NSINSTALL) -D $(DESTDIR)$(includedir)
627 (cd $(DIST)/include && tar $(TAR_CREATE_FLAGS) - .) | \
628 (cd $(DESTDIR)$(includedir) && tar -xf -)
629 $(NSINSTALL) -D $(DESTDIR)$(idldir)
630 (cd $(DIST)/idl && tar $(TAR_CREATE_FLAGS) - .) | \
631 (cd $(DESTDIR)$(idldir) && tar -xf -)
632 # SDK directory is the libs + a bunch of symlinks
633 $(NSINSTALL) -D $(DESTDIR)$(sdkdir)/sdk/lib
634 if test -f $(DIST)/include/xpcom-config.h; then \
635 $(SYSINSTALL) $(IFLAGS1) $(DIST)/include/xpcom-config.h $(DESTDIR)$(sdkdir); \
637 (cd $(DIST)/sdk/lib && tar $(TAR_CREATE_FLAGS) - .) | (cd $(DESTDIR)$(sdkdir)/sdk/lib && tar -xf -)
638 $(RM) -f $(DESTDIR)$(sdkdir)/lib $(DESTDIR)$(sdkdir)/bin $(DESTDIR)$(sdkdir)/include $(DESTDIR)$(sdkdir)/include $(DESTDIR)$(sdkdir)/sdk/idl $(DESTDIR)$(sdkdir)/idl
639 ln -s $(sdkdir)/sdk/lib $(DESTDIR)$(sdkdir)/lib
640 ln -s $(installdir) $(DESTDIR)$(sdkdir)/bin
641 ln -s $(includedir) $(DESTDIR)$(sdkdir)/include
642 ln -s $(idldir) $(DESTDIR)$(sdkdir)/idl
643 endif # INSTALL_SDK
645 make-sdk:
646 $(MAKE) stage-package UNIVERSAL_BINARY= STAGE_SDK=1 MOZ_PKG_DIR=sdk-stage
647 @echo "Packaging SDK..."
648 $(RM) -rf $(DIST)/$(MOZ_APP_NAME)-sdk
649 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/bin
650 (cd $(DIST)/sdk-stage && tar $(TAR_CREATE_FLAGS) - .) | \
651 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/bin && tar -xf -)
652 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/host/bin
653 (cd $(DIST)/host/bin && tar $(TAR_CREATE_FLAGS) - .) | \
654 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/host/bin && tar -xf -)
655 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/sdk
656 (cd $(DIST)/sdk && tar $(TAR_CREATE_FLAGS) - .) | \
657 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/sdk && tar -xf -)
658 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/include
659 (cd $(DIST)/include && tar $(TAR_CREATE_FLAGS) - .) | \
660 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/include && tar -xf -)
661 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/idl
662 (cd $(DIST)/idl && tar $(TAR_CREATE_FLAGS) - .) | \
663 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/idl && tar -xf -)
664 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/lib
665 # sdk/lib is the same as sdk/sdk/lib
666 (cd $(DIST)/sdk/lib && tar $(TAR_CREATE_FLAGS) - .) | \
667 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/lib && tar -xf -)
668 $(NSINSTALL) -D $(DIST)/$(SDK_PATH)
669 cd $(DIST) && $(MAKE_SDK)
671 ifeq ($(OS_TARGET), WINNT)
672 INSTALLER_PACKAGE = $(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
673 endif
674 ifeq ($(OS_TARGET), WINCE)
675 INSTALLER_PACKAGE = $(DIST)/$(PKG_PATH)$(PKG_BASENAME).cab
676 endif
678 # These are necessary because some of our packages/installers contain spaces
679 # in their filenames and GNU Make's $(wildcard) function doesn't properly
680 # deal with them.
681 empty :=
682 space = $(empty) $(empty)
683 QUOTED_WILDCARD = $(if $(wildcard $(subst $(space),?,$(1))),"$(1)")
685 # This variable defines which OpenSSL algorithm to use to
686 # generate checksums for files that we upload
687 CHECKSUM_ALGORITHM = 'sha512'
689 # This variable defines where the checksum file will be located
690 CHECKSUM_FILE = "$(DIST)/$(PKG_PATH)/$(PKG_BASENAME).checksums"
692 UPLOAD_FILES= \
693 $(call QUOTED_WILDCARD,$(DIST)/$(PACKAGE)) \
694 $(call QUOTED_WILDCARD,$(INSTALLER_PACKAGE)) \
695 $(call QUOTED_WILDCARD,$(DIST)/$(COMPLETE_MAR)) \
696 $(call QUOTED_WILDCARD,$(DIST)/$(LANGPACK)) \
697 $(call QUOTED_WILDCARD,$(wildcard $(DIST)/$(PARTIAL_MAR))) \
698 $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(TEST_PACKAGE)) \
699 $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip) \
700 $(call QUOTED_WILDCARD,$(DIST)/$(SDK)) \
701 $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)/$(PKG_BASENAME).txt) \
702 $(if $(UPLOAD_EXTRA_FILES), $(foreach f, $(UPLOAD_EXTRA_FILES), $(wildcard $(DIST)/$(f))))
704 checksum:
705 @$(PYTHON) $(MOZILLA_DIR)/build/checksums.py \
706 -o $(CHECKSUM_FILE) \
707 -d $(CHECKSUM_ALGORITHM) \
708 -s $(call QUOTED_WILDCARD,$(DIST)) \
709 $(UPLOAD_FILES)
710 @echo "CHECKSUM FILE START"
711 @cat $(CHECKSUM_FILE)
712 @echo "CHECKSUM FILE END"
715 upload: checksum
716 $(PYTHON) $(MOZILLA_DIR)/build/upload.py --base-path $(DIST) \
717 $(UPLOAD_FILES) \
718 $(CHECKSUM_FILE)
720 ifndef MOZ_PKG_SRCDIR
721 MOZ_PKG_SRCDIR = $(topsrcdir)
722 endif
724 CREATE_SOURCE_TAR = $(TAR) -c --owner=0 --group=0 --numeric-owner \
725 --mode="go-w" --exclude=".hg*" --exclude="CVS" --exclude=".cvs*" -f
727 # source-package creates a source tarball from the files in MOZ_PKG_SRCDIR,
728 # which is either set to a clean checkout or defaults to $topsrcdir
729 source-package:
730 @echo "Packaging source tarball..."
731 (cd $(MOZ_PKG_SRCDIR) && $(CREATE_SOURCE_TAR) - .) | bzip2 -vf > $(DIST)/$(PKG_SRCPACK_PATH)$(PKG_SRCPACK_BASENAME).tar.bz2