bug 313956: expand installer .exe contents to make complete mar. r=ted.
[gecko.git] / toolkit / mozapps / installer / packager.mk
blobb9f3559e03fbf4eaf6fe230625477d044fbbd8e4
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, $(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) core && \
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 removed-files \
183 $(NULL)
185 NON_DIST_FILES = \
186 classes.dex \
187 $(NULL)
189 UPLOAD_EXTRA_FILES += gecko-unsigned-unaligned.apk
191 include $(topsrcdir)/ipc/app/defs.mk
193 ifdef MOZ_IPC
194 DIST_FILES += $(MOZ_CHILD_PROCESS_NAME)
195 endif
197 ifdef MOZ_THUMB2
198 ABI_DIR = armeabi-v7a
199 else
200 ABI_DIR = armeabi
201 endif
203 PKG_SUFFIX = .apk
204 INNER_MAKE_PACKAGE = \
205 make -C ../embedding/android gecko.ap_ && \
206 cp ../embedding/android/gecko.ap_ $(_ABS_DIST) && \
207 ( cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && \
208 rm -rf lib && \
209 mkdir -p lib/$(ABI_DIR) && \
210 cp lib*.so lib && \
211 mv lib/libmozutils.so lib/$(ABI_DIR) && \
212 rm -f lib.id && \
213 for SOMELIB in lib/*.so ; \
214 do \
215 printf "`basename $$SOMELIB`:`$(_ABS_DIST)/host/bin/file_id $$SOMELIB`\n" >> lib.id ; \
216 done && \
217 unzip -o $(_ABS_DIST)/gecko.ap_ && \
218 rm $(_ABS_DIST)/gecko.ap_ && \
219 $(ZIP) -r9D $(_ABS_DIST)/gecko.ap_ $(DIST_FILES) -x $(NON_DIST_FILES) ) && \
220 rm -f $(_ABS_DIST)/gecko.apk && \
221 $(APKBUILDER) $(_ABS_DIST)/gecko.apk -v $(APKBUILDER_FLAGS) -z $(_ABS_DIST)/gecko.ap_ -f $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/classes.dex && \
222 cp $(_ABS_DIST)/gecko.apk $(_ABS_DIST)/gecko-unsigned-unaligned.apk && \
223 $(JARSIGNER) $(_ABS_DIST)/gecko.apk && \
224 $(ZIPALIGN) -f -v 4 $(_ABS_DIST)/gecko.apk $(PACKAGE)
225 INNER_UNMAKE_PACKAGE = \
226 mkdir $(MOZ_PKG_DIR) && \
227 cd $(MOZ_PKG_DIR) && \
228 $(UNZIP) $(UNPACKAGE) && \
229 mv lib/$(ABI_DIR)/*.so . && \
230 mv lib/*.so . && \
231 rm -rf lib
232 endif
233 ifeq ($(MOZ_PKG_FORMAT),DMG)
234 ifndef _APPNAME
235 ifdef MOZ_DEBUG
236 _APPNAME = $(MOZ_APP_DISPLAYNAME)Debug.app
237 else
238 _APPNAME = $(MOZ_APP_DISPLAYNAME).app
239 endif
240 endif
241 ifndef _BINPATH
242 _BINPATH = /$(_APPNAME)/Contents/MacOS
243 endif # _BINPATH
244 PKG_SUFFIX = .dmg
245 PKG_DMG_FLAGS =
246 ifneq (,$(MOZ_PKG_MAC_DSSTORE))
247 PKG_DMG_FLAGS += --copy "$(MOZ_PKG_MAC_DSSTORE):/.DS_Store"
248 endif
249 ifneq (,$(MOZ_PKG_MAC_BACKGROUND))
250 PKG_DMG_FLAGS += --mkdir /.background --copy "$(MOZ_PKG_MAC_BACKGROUND):/.background"
251 endif
252 ifneq (,$(MOZ_PKG_MAC_ICON))
253 PKG_DMG_FLAGS += --icon "$(MOZ_PKG_MAC_ICON)"
254 endif
255 ifneq (,$(MOZ_PKG_MAC_RSRC))
256 PKG_DMG_FLAGS += --resource "$(MOZ_PKG_MAC_RSRC)"
257 endif
258 ifneq (,$(MOZ_PKG_MAC_EXTRA))
259 PKG_DMG_FLAGS += $(MOZ_PKG_MAC_EXTRA)
260 endif
261 _ABS_MOZSRCDIR = $(shell cd $(MOZILLA_DIR) && pwd)
262 ifdef UNIVERSAL_BINARY
263 STAGEPATH = universal/
264 endif
265 ifndef PKG_DMG_SOURCE
266 PKG_DMG_SOURCE = $(STAGEPATH)$(MOZ_PKG_DIR)
267 endif
268 INNER_MAKE_PACKAGE = $(_ABS_MOZSRCDIR)/build/package/mac_osx/pkg-dmg \
269 --source "$(PKG_DMG_SOURCE)" --target "$(PACKAGE)" \
270 --volname "$(MOZ_APP_DISPLAYNAME)" $(PKG_DMG_FLAGS)
271 INNER_UNMAKE_PACKAGE = \
272 set -ex; \
273 rm -rf $(_ABS_DIST)/unpack.tmp; \
274 mkdir -p $(_ABS_DIST)/unpack.tmp; \
275 $(_ABS_MOZSRCDIR)/build/package/mac_osx/unpack-diskimage $(UNPACKAGE) /tmp/$(MOZ_PKG_APPNAME)-unpack $(_ABS_DIST)/unpack.tmp; \
276 rsync -a "$(_ABS_DIST)/unpack.tmp/$(_APPNAME)" $(MOZ_PKG_DIR); \
277 test -n "$(MOZ_PKG_MAC_DSSTORE)" && \
278 rsync -a "$(_ABS_DIST)/unpack.tmp/.DS_Store" "$(MOZ_PKG_MAC_DSSTORE)"; \
279 test -n "$(MOZ_PKG_MAC_BACKGROUND)" && \
280 rsync -a "$(_ABS_DIST)/unpack.tmp/.background/`basename "$(MOZ_PKG_MAC_BACKGROUND)"`" "$(MOZ_PKG_MAC_BACKGROUND)"; \
281 test -n "$(MOZ_PKG_MAC_ICON)" && \
282 rsync -a "$(_ABS_DIST)/unpack.tmp/.VolumeIcon.icns" "$(MOZ_PKG_MAC_ICON)"; \
283 rm -rf $(_ABS_DIST)/unpack.tmp; \
284 if test -n "$(MOZ_PKG_MAC_RSRC)" ; then \
285 cp $(UNPACKAGE) $(MOZ_PKG_APPNAME).tmp.dmg && \
286 hdiutil unflatten $(MOZ_PKG_APPNAME).tmp.dmg && \
287 { /Developer/Tools/DeRez -skip plst -skip blkx $(MOZ_PKG_APPNAME).tmp.dmg > "$(MOZ_PKG_MAC_RSRC)" || { rm -f $(MOZ_PKG_APPNAME).tmp.dmg && false; }; } && \
288 rm -f $(MOZ_PKG_APPNAME).tmp.dmg; \
290 # The plst and blkx resources are skipped because they belong to each
291 # individual dmg and are created by hdiutil.
292 SDK_SUFFIX = .tar.bz2
293 SDK = $(MOZ_PKG_APPNAME)-$(MOZ_PKG_VERSION).$(AB_CD).mac-$(TARGET_CPU).sdk$(SDK_SUFFIX)
294 ifeq ($(MOZ_APP_NAME),xulrunner)
295 SDK = $(SDK_PATH)$(MOZ_APP_NAME)-$(MOZ_PKG_VERSION).$(AB_CD).mac-$(TARGET_CPU).sdk$(SDK_SUFFIX)
296 endif
297 MAKE_SDK = $(CREATE_FINAL_TAR) - $(MOZ_APP_NAME)-sdk | bzip2 -vf > $(SDK)
298 endif
300 ifdef MOZ_OMNIJAR
301 GENERATE_CACHE ?= true
303 OMNIJAR_FILES = \
304 chrome \
305 chrome.manifest \
306 components/*.js \
307 components/*.xpt \
308 components/*.manifest \
309 modules \
310 res \
311 defaults \
312 greprefs.js \
313 jsloader \
314 $(NULL)
316 NON_OMNIJAR_FILES += \
317 chrome/icons/\* \
318 defaults/pref/channel-prefs.js \
319 res/cursors/\* \
320 res/MainMenu.nib/\* \
321 $(NULL)
323 PACK_OMNIJAR = \
324 rm -f omni.jar components/binary.manifest && \
325 grep -h '^binary-component' components/*.manifest > binary.manifest ; \
326 sed -e 's/^binary-component/\#binary-component/' components/components.manifest > components.manifest && \
327 mv components.manifest components && \
328 find . | xargs touch -t 201001010000 && \
329 zip -r9mX omni.jar $(OMNIJAR_FILES) -x $(NON_OMNIJAR_FILES) && \
330 $(GENERATE_CACHE) && \
331 $(OPTIMIZE_JARS_CMD) --optimize $(_ABS_DIST)/jarlog/ ./ ./ && \
332 mv binary.manifest components && \
333 printf "manifest components/binary.manifest\n" > chrome.manifest
334 UNPACK_OMNIJAR = \
335 $(OPTIMIZE_JARS_CMD) --deoptimize $(_ABS_DIST)/jarlog/ ./ ./ && \
336 unzip -o omni.jar && \
337 rm -f components/binary.manifest && \
338 sed -e 's/^\#binary-component/binary-component/' components/components.manifest > components.manifest && \
339 mv components.manifest components
341 MAKE_PACKAGE = (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR)) && $(INNER_MAKE_PACKAGE)
342 UNMAKE_PACKAGE = $(INNER_UNMAKE_PACKAGE) && (cd $(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(UNPACK_OMNIJAR))
343 else
344 MAKE_PACKAGE = $(INNER_MAKE_PACKAGE)
345 UNMAKE_PACKAGE = $(INNER_UNMAKE_PACKAGE)
346 endif
348 # dummy macro if we don't have PSM built
349 SIGN_NSS =
350 ifneq (1_,$(if $(CROSS_COMPILE),1,0)_$(UNIVERSAL_BINARY))
351 ifdef MOZ_PSM
352 SIGN_NSS = @echo signing nss libraries;
354 NSS_DLL_SUFFIX = $(DLL_SUFFIX)
355 ifdef UNIVERSAL_BINARY
356 NATIVE_ARCH = $(shell uname -p | sed -e s/powerpc/ppc/)
357 NATIVE_DIST = $(DIST:$(DEPTH)/%=$(DEPTH)/../$(NATIVE_ARCH)/%)
358 SIGN_CMD = $(NATIVE_DIST)/bin/run-mozilla.sh $(NATIVE_DIST)/bin/shlibsign -v -i
359 else
360 ifeq ($(OS_ARCH),OS2)
361 # uppercase extension to get the correct output file from shlibsign
362 NSS_DLL_SUFFIX = .DLL
363 SIGN_CMD = $(MOZILLA_DIR)/toolkit/mozapps/installer/os2/sign.cmd $(DIST)
364 else
365 SIGN_CMD = $(RUN_TEST_PROGRAM) $(DIST)/bin/shlibsign$(BIN_SUFFIX) -v -i
366 endif
367 endif
369 SOFTOKN = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)softokn3$(NSS_DLL_SUFFIX)
370 NSSDBM = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)nssdbm3$(NSS_DLL_SUFFIX)
371 FREEBL = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl3$(NSS_DLL_SUFFIX)
372 FREEBL_32FPU = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_32fpu_3$(DLL_SUFFIX)
373 FREEBL_32INT = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_32int_3$(DLL_SUFFIX)
374 FREEBL_32INT64 = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_32int64_3$(DLL_SUFFIX)
375 FREEBL_64FPU = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_64fpu_3$(DLL_SUFFIX)
376 FREEBL_64INT = $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/$(DLL_PREFIX)freebl_64int_3$(DLL_SUFFIX)
378 SIGN_NSS += $(SIGN_CMD) $(SOFTOKN); \
379 $(SIGN_CMD) $(NSSDBM); \
380 if test -f $(FREEBL); then $(SIGN_CMD) $(FREEBL); fi; \
381 if test -f $(FREEBL_32FPU); then $(SIGN_CMD) $(FREEBL_32FPU); fi; \
382 if test -f $(FREEBL_32INT); then $(SIGN_CMD) $(FREEBL_32INT); fi; \
383 if test -f $(FREEBL_32INT64); then $(SIGN_CMD) $(FREEBL_32INT64); fi; \
384 if test -f $(FREEBL_64FPU); then $(SIGN_CMD) $(FREEBL_64FPU); fi; \
385 if test -f $(FREEBL_64INT); then $(SIGN_CMD) $(FREEBL_64INT); fi;
387 endif # MOZ_PSM
388 endif # !CROSS_COMPILE
390 NO_PKG_FILES += \
391 core \
392 bsdecho \
393 gtscc \
394 js \
395 js-config \
396 jscpucfg \
397 nsinstall \
398 viewer \
399 TestGtkEmbed \
400 codesighs* \
401 elf-dynstr-gc \
402 mangle* \
403 maptsv* \
404 mfc* \
405 mkdepend* \
406 msdump* \
407 msmap* \
408 nm2tsv* \
409 nsinstall* \
410 res/samples \
411 res/throbber \
412 shlibsign* \
413 ssltunnel* \
414 certutil* \
415 pk12util* \
416 winEmbed.exe \
417 chrome/chrome.rdf \
418 chrome/app-chrome.manifest \
419 chrome/overlayinfo \
420 components/compreg.dat \
421 components/xpti.dat \
422 content_unit_tests \
423 necko_unit_tests \
424 *.dSYM \
425 $(NULL)
427 # browser/locales/Makefile uses this makefile for its variable defs, but
428 # doesn't want the libs:: rule.
429 ifndef PACKAGER_NO_LIBS
430 libs:: make-package
431 endif
433 DEFINES += -DDLL_PREFIX=$(DLL_PREFIX) -DDLL_SUFFIX=$(DLL_SUFFIX) -DBIN_SUFFIX=$(BIN_SUFFIX)
435 ifdef MOZ_PKG_REMOVALS
436 MOZ_PKG_REMOVALS_GEN = removed-files
438 $(MOZ_PKG_REMOVALS_GEN): $(MOZ_PKG_REMOVALS) $(GLOBAL_DEPS)
439 cat $(MOZ_PKG_REMOVALS) | \
440 sed -e 's/^[ \t]*//' | \
441 $(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py -Fsubstitution $(DEFINES) $(ACDEFINES) > $(MOZ_PKG_REMOVALS_GEN)
443 GARBAGE += $(MOZ_PKG_REMOVALS_GEN)
444 endif
446 GARBAGE += $(DIST)/$(PACKAGE) $(PACKAGE)
448 ifeq ($(OS_ARCH),IRIX)
449 STRIP_FLAGS = -f
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 elfhack:
499 ifdef USE_ELF_HACK
500 @echo ===
501 @echo === If you get failures below, please file a bug describing the error
502 @echo === and your environment \(compiler and linker versions\), and use
503 @echo === --disable-elf-hack until this is fixed.
504 @echo ===
505 cd $(DIST)/bin; find . -name "*$(DLL_SUFFIX)" | xargs $(DEPTH)/build/unix/elfhack/elfhack
506 endif
508 stage-package: $(MOZ_PKG_MANIFEST) $(MOZ_PKG_REMOVALS_GEN) elfhack
509 @rm -rf $(DIST)/$(MOZ_PKG_DIR) $(DIST)/$(PKG_PATH)$(PKG_BASENAME).tar $(DIST)/$(PKG_PATH)$(PKG_BASENAME).dmg $@ $(EXCLUDE_LIST)
510 # NOTE: this must be a tar now that dist links into the tree so that we
511 # do not strip the binaries actually in the tree.
512 @echo "Creating package directory..."
513 @mkdir $(DIST)/$(MOZ_PKG_DIR)
514 ifndef UNIVERSAL_BINARY
515 # If UNIVERSAL_BINARY, the package will be made from an already-prepared
516 # STAGEPATH
517 ifdef MOZ_PKG_MANIFEST
518 $(RM) -rf $(DIST)/xpt $(DIST)/manifests
519 $(call PACKAGER_COPY, "$(call core_abspath,$(DIST))",\
520 "$(call core_abspath,$(DIST)/$(MOZ_PKG_DIR))", \
521 "$(MOZ_PKG_MANIFEST)", "$(PKGCP_OS)", 1, 0, 1)
522 $(PERL) $(MOZILLA_DIR)/xpinstall/packager/xptlink.pl -s $(DIST) -d $(DIST)/xpt -f $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/components -v -x "$(XPIDL_LINK)"
523 $(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
524 $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/components/components.manifest \
525 $(patsubst %,$(DIST)/manifests/%/components,$(MOZ_NONLOCALIZED_PKG_LIST))
526 $(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
527 $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome/nonlocalized.manifest \
528 $(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_NONLOCALIZED_PKG_LIST))
529 $(PYTHON) $(MOZILLA_DIR)/toolkit/mozapps/installer/link-manifests.py \
530 $(DIST)/$(MOZ_PKG_DIR)/$(_BINPATH)/chrome/localized.manifest \
531 $(patsubst %,$(DIST)/manifests/%/chrome,$(MOZ_LOCALIZED_PKG_LIST))
532 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
533 else # !MOZ_PKG_MANIFEST
534 ifeq ($(MOZ_PKG_FORMAT),DMG)
535 ifndef STAGE_SDK
536 @cd $(DIST) && rsync -auv --copy-unsafe-links $(_APPNAME) $(MOZ_PKG_DIR)
537 @echo "Linking XPT files..."
538 @rm -rf $(DIST)/xpt
539 @$(NSINSTALL) -D $(DIST)/xpt
540 @($(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...
541 else
542 @cd $(DIST)/bin && tar $(TAR_CREATE_FLAGS) - * | (cd ../$(MOZ_PKG_DIR); tar -xf -)
543 endif
544 else
545 @cd $(DIST)/bin && tar $(TAR_CREATE_FLAGS) - * | (cd ../$(MOZ_PKG_DIR); tar -xf -)
546 @echo "Linking XPT files..."
547 @rm -rf $(DIST)/xpt
548 @$(NSINSTALL) -D $(DIST)/xpt
549 @($(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...
550 endif # DMG
551 endif # MOZ_PKG_MANIFEST
552 endif # UNIVERSAL_BINARY
553 $(OPTIMIZE_JARS_CMD) --optimize $(DIST)/jarlog/ $(DIST)/bin/chrome $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)/chrome
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) make-sourcestamp-file
597 @echo "Compressing..."
598 cd $(DIST) && $(MAKE_PACKAGE)
600 make-sourcestamp-file::
601 $(NSINSTALL) -D $(DIST)/$(PKG_PATH)
602 @echo "$(BUILDID)" > $(MOZ_SOURCESTAMP_FILE)
603 @echo "$(MOZ_SOURCE_REPO)/rev/$(MOZ_SOURCE_STAMP)" >> $(MOZ_SOURCESTAMP_FILE)
605 # The install target will install the application to prefix/lib/appname-version
606 # In addition if INSTALL_SDK is set, it will install the development headers,
607 # libraries, and IDL files as follows:
608 # dist/include -> prefix/include/appname-version
609 # dist/idl -> prefix/share/idl/appname-version
610 # dist/sdk/lib -> prefix/lib/appname-devel-version/lib
611 # prefix/lib/appname-devel-version/* symlinks to the above directories
612 install:: stage-package
613 ifneq (,$(filter WINNT WINCE,$(OS_ARCH)))
614 $(error "make install" is not supported on this platform. Use "make package" instead.)
615 endif
616 ifeq (bundle,$(MOZ_FS_LAYOUT))
617 $(error "make install" is not supported on this platform. Use "make package" instead.)
618 endif
619 ifdef MOZ_OMNIJAR
620 cd $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH) && $(PACK_OMNIJAR)
621 endif
622 $(NSINSTALL) -D $(DESTDIR)$(installdir)
623 (cd $(DIST)/$(MOZ_PKG_DIR) && tar $(TAR_CREATE_FLAGS) - .) | \
624 (cd $(DESTDIR)$(installdir) && tar -xf -)
625 $(NSINSTALL) -D $(DESTDIR)$(bindir)
626 $(RM) -f $(DESTDIR)$(bindir)/$(MOZ_APP_NAME)
627 ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
628 ifdef INSTALL_SDK # Here comes the hard part
629 $(NSINSTALL) -D $(DESTDIR)$(includedir)
630 (cd $(DIST)/include && tar $(TAR_CREATE_FLAGS) - .) | \
631 (cd $(DESTDIR)$(includedir) && tar -xf -)
632 $(NSINSTALL) -D $(DESTDIR)$(idldir)
633 (cd $(DIST)/idl && tar $(TAR_CREATE_FLAGS) - .) | \
634 (cd $(DESTDIR)$(idldir) && tar -xf -)
635 # SDK directory is the libs + a bunch of symlinks
636 $(NSINSTALL) -D $(DESTDIR)$(sdkdir)/sdk/lib
637 if test -f $(DIST)/include/xpcom-config.h; then \
638 $(SYSINSTALL) $(IFLAGS1) $(DIST)/include/xpcom-config.h $(DESTDIR)$(sdkdir); \
640 (cd $(DIST)/sdk/lib && tar $(TAR_CREATE_FLAGS) - .) | (cd $(DESTDIR)$(sdkdir)/sdk/lib && tar -xf -)
641 $(RM) -f $(DESTDIR)$(sdkdir)/lib $(DESTDIR)$(sdkdir)/bin $(DESTDIR)$(sdkdir)/include $(DESTDIR)$(sdkdir)/include $(DESTDIR)$(sdkdir)/sdk/idl $(DESTDIR)$(sdkdir)/idl
642 ln -s $(sdkdir)/sdk/lib $(DESTDIR)$(sdkdir)/lib
643 ln -s $(installdir) $(DESTDIR)$(sdkdir)/bin
644 ln -s $(includedir) $(DESTDIR)$(sdkdir)/include
645 ln -s $(idldir) $(DESTDIR)$(sdkdir)/idl
646 endif # INSTALL_SDK
648 make-sdk:
649 $(MAKE) stage-package UNIVERSAL_BINARY= STAGE_SDK=1 MOZ_PKG_DIR=sdk-stage
650 @echo "Packaging SDK..."
651 $(RM) -rf $(DIST)/$(MOZ_APP_NAME)-sdk
652 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/bin
653 (cd $(DIST)/sdk-stage && tar $(TAR_CREATE_FLAGS) - .) | \
654 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/bin && tar -xf -)
655 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/host/bin
656 (cd $(DIST)/host/bin && tar $(TAR_CREATE_FLAGS) - .) | \
657 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/host/bin && tar -xf -)
658 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/sdk
659 (cd $(DIST)/sdk && tar $(TAR_CREATE_FLAGS) - .) | \
660 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/sdk && tar -xf -)
661 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/include
662 (cd $(DIST)/include && tar $(TAR_CREATE_FLAGS) - .) | \
663 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/include && tar -xf -)
664 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/idl
665 (cd $(DIST)/idl && tar $(TAR_CREATE_FLAGS) - .) | \
666 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/idl && tar -xf -)
667 $(NSINSTALL) -D $(DIST)/$(MOZ_APP_NAME)-sdk/lib
668 # sdk/lib is the same as sdk/sdk/lib
669 (cd $(DIST)/sdk/lib && tar $(TAR_CREATE_FLAGS) - .) | \
670 (cd $(DIST)/$(MOZ_APP_NAME)-sdk/lib && tar -xf -)
671 $(NSINSTALL) -D $(DIST)/$(SDK_PATH)
672 cd $(DIST) && $(MAKE_SDK)
674 ifeq ($(OS_TARGET), WINNT)
675 INSTALLER_PACKAGE = $(DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
676 endif
677 ifeq ($(OS_TARGET), WINCE)
678 INSTALLER_PACKAGE = $(DIST)/$(PKG_PATH)$(PKG_BASENAME).cab
679 endif
681 # These are necessary because some of our packages/installers contain spaces
682 # in their filenames and GNU Make's $(wildcard) function doesn't properly
683 # deal with them.
684 empty :=
685 space = $(empty) $(empty)
686 QUOTED_WILDCARD = $(if $(wildcard $(subst $(space),?,$(1))),"$(1)")
687 ESCAPE_SPACE = $(subst $(space),\$(space),$(1))
689 # This variable defines which OpenSSL algorithm to use to
690 # generate checksums for files that we upload
691 CHECKSUM_ALGORITHM = 'sha512'
693 # This variable defines where the checksum file will be located
694 CHECKSUM_FILE = "$(DIST)/$(PKG_PATH)/$(PKG_BASENAME).checksums"
696 UPLOAD_FILES= \
697 $(call QUOTED_WILDCARD,$(DIST)/$(PACKAGE)) \
698 $(call QUOTED_WILDCARD,$(INSTALLER_PACKAGE)) \
699 $(call QUOTED_WILDCARD,$(DIST)/$(COMPLETE_MAR)) \
700 $(call QUOTED_WILDCARD,$(DIST)/$(LANGPACK)) \
701 $(call QUOTED_WILDCARD,$(wildcard $(DIST)/$(PARTIAL_MAR))) \
702 $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(TEST_PACKAGE)) \
703 $(call QUOTED_WILDCARD,$(DIST)/$(PKG_PATH)$(SYMBOL_ARCHIVE_BASENAME).zip) \
704 $(call QUOTED_WILDCARD,$(DIST)/$(SDK)) \
705 $(call QUOTED_WILDCARD,$(MOZ_SOURCESTAMP_FILE)) \
706 $(if $(UPLOAD_EXTRA_FILES), $(foreach f, $(UPLOAD_EXTRA_FILES), $(wildcard $(DIST)/$(f))))
708 checksum:
709 @$(PYTHON) $(MOZILLA_DIR)/build/checksums.py \
710 -o $(CHECKSUM_FILE) \
711 -d $(CHECKSUM_ALGORITHM) \
712 -s $(call QUOTED_WILDCARD,$(DIST)) \
713 $(UPLOAD_FILES)
714 @echo "CHECKSUM FILE START"
715 @cat $(CHECKSUM_FILE)
716 @echo "CHECKSUM FILE END"
719 upload: checksum
720 $(PYTHON) $(MOZILLA_DIR)/build/upload.py --base-path $(DIST) \
721 $(UPLOAD_FILES) \
722 $(CHECKSUM_FILE)
724 ifndef MOZ_PKG_SRCDIR
725 MOZ_PKG_SRCDIR = $(topsrcdir)
726 endif
728 DIR_TO_BE_PACKAGED ?= ../$(notdir $(topsrcdir))
729 SRC_TAR_EXCLUDE_PATHS += \
730 --exclude=".hg*" \
731 --exclude="CVS" \
732 --exclude=".cvs*" \
733 --exclude=".mozconfig*" \
734 --exclude="*.pyc" \
735 --exclude="$(MOZILLA_DIR)/Makefile" \
736 --exclude="$(MOZILLA_DIR)/dist"
737 ifdef MOZ_OBJDIR
738 SRC_TAR_EXCLUDE_PATHS += --exclude="$(MOZ_OBJDIR)"
739 endif
740 CREATE_SOURCE_TAR = $(TAR) -c --owner=0 --group=0 --numeric-owner \
741 --mode="go-w" $(SRC_TAR_EXCLUDE_PATHS) -f
743 # source-package creates a source tarball from the files in MOZ_PKG_SRCDIR,
744 # which is either set to a clean checkout or defaults to $topsrcdir
745 source-package:
746 @echo "Packaging source tarball..."
747 mkdir -p $(DIST)/$(PKG_SRCPACK_PATH)
748 (cd $(MOZ_PKG_SRCDIR) && $(CREATE_SOURCE_TAR) - $(DIR_TO_BE_PACKAGED)) | bzip2 -vf > $(DIST)/$(PKG_SRCPACK_PATH)$(PKG_SRCPACK_BASENAME).tar.bz2