1 # vim:set ts=8 sw=8 sts=8 noet:
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # Shared makefile that can be used to easily kick off l10n builds
8 # of Mozilla applications.
9 # This makefile should be included, and then assumes that the including
10 # makefile defines the following targets:
12 # This target should call into the various l10n targets that this
13 # application depends on.
15 # This target should list all required targets, a typical rule would be
16 # installers-%: clobber-% langpack-% repackage-zip-%
17 # @echo "repackaging done"
18 # to initially clobber the locale staging area, and then to build the
19 # language pack and zip package.
20 # Other targets like windows installers might be listed, too, and should
21 # be defined in the including makefile.
22 # The installer-% targets should not set AB_CD, so that the unpackaging
23 # step finds the original package.
24 # The including makefile should provide values for the variables
25 # MOZ_APP_VERSION and MOZ_LANGPACK_EID.
28 run_for_effects
:= $(shell if
test ! -d
$(DIST
); then
$(NSINSTALL
) -D
$(DIST
); fi
)
30 # This makefile uses variable overrides from the l10n-% target to
31 # build non-default locales to non-default dist/ locations. Be aware!
33 LPROJ_ROOT
= $(firstword $(subst -, ,$(AB_CD
)))
34 ifeq (cocoa
,$(MOZ_WIDGET_TOOLKIT
))
36 LPROJ_ROOT
:= $(subst -,_
,$(AB_CD
))
40 # These are defaulted to be compatible with the files the wget-en-US target
41 # pulls. You may override them if you provide your own files.
42 ZIP_IN ?
= $(ABS_DIST
)/$(PACKAGE
)
43 WIN32_INSTALLER_IN ?
= $(ABS_DIST
)/$(PKG_INST_PATH
)$(PKG_INST_BASENAME
).exe
45 # Allows overriding the final destination of the repackaged file
46 ZIP_OUT ?
= $(ABS_DIST
)/$(PACKAGE
)
50 -DMOZ_LANGPACK_EID
=$(MOZ_LANGPACK_EID
) \
51 -DMOZ_APP_ID
='$(MOZ_APP_ID)' \
52 -DMOZ_APP_VERSION
=$(MOZ_APP_VERSION
) \
53 -DMOZ_APP_MAXVERSION
=$(MOZ_APP_MAXVERSION
) \
54 -DLOCALE_SRCDIR
=$(abspath
$(LOCALE_SRCDIR
)) \
55 -DPKG_BASENAME
='$(PKG_BASENAME)' \
56 -DPKG_INST_BASENAME
='$(PKG_INST_BASENAME)' \
59 # export some global defines for l10n repacks
60 BASE_MERGE
:=$(CURDIR
)/merge-dir
61 export REAL_LOCALE_MERGEDIR
=$(BASE_MERGE
)/$(AB_CD
)
62 # is an l10n repack step:
63 export IS_LANGUAGE_REPACK
69 $(RM
) -rf
$(DIST
)/xpi-stage
/locale-
$*
74 ifeq (cocoa
,$(MOZ_WIDGET_TOOLKIT
))
75 STAGEDIST
= $(ABS_DIST
)/l10n-stage
/$(MOZ_PKG_DIR
)/$(_APPNAME
)/Contents
/Resources
77 STAGEDIST
= $(ABS_DIST
)/l10n-stage
/$(MOZ_PKG_DIR
)
79 UNPACKED_INSTALLER
= $(ABS_DIST
)/unpacked-installer
81 include $(MOZILLA_DIR
)/toolkit
/mozapps
/installer
/packager.mk
83 PACKAGE_BASE_DIR
= $(ABS_DIST
)/l10n-stage
85 $(UNPACKED_INSTALLER
): AB_CD
:=en-US
86 $(UNPACKED_INSTALLER
): UNPACKAGE
=$(call ESCAPE_WILDCARD
,$(ZIP_IN
))
87 $(UNPACKED_INSTALLER
): $(call ESCAPE_WILDCARD
,$(ZIP_IN
))
88 # only mac needs to remove the parent of STAGEDIST...
89 ifeq (cocoa
,$(MOZ_WIDGET_TOOLKIT
))
90 $(RM
) -r
-v
$(UNPACKED_INSTALLER
)
92 # ... and windows doesn't like removing STAGEDIST itself, remove all children
93 find
$(UNPACKED_INSTALLER
) -maxdepth
1 -print0 | xargs
-0 $(RM
) -r
95 $(NSINSTALL
) -D
$(UNPACKED_INSTALLER
)
96 $(call INNER_UNMAKE_PACKAGE
,$(UNPACKED_INSTALLER
))
98 unpack
: $(UNPACKED_INSTALLER
)
99 ifeq ($(OS_ARCH
), WINNT
)
100 $(RM
) -r
-f
$(ABS_DIST
)/l10n-stage
101 $(NSINSTALL
) -D
$(ABS_DIST
)/l10n-stage
102 $(call copy_dir
, $(UNPACKED_INSTALLER
), $(ABS_DIST
)/l10n-stage
)
104 rsync
-rav
--delete
$(UNPACKED_INSTALLER
)/ $(ABS_DIST
)/l10n-stage
107 # The path to the object dir for the mozilla-central build system,
108 # may be overridden if necessary.
111 repackage-zip
: UNPACKAGE
='$(ZIP_IN)'
113 $(PYTHON3
) $(MOZILLA_DIR
)/toolkit
/mozapps
/installer
/l10n-repack.py
'$(STAGEDIST)' $(DIST
)/xpi-stage
/locale-
$(AB_CD
) \
114 $(MOZ_PKG_EXTRAL10N
) \
115 $(if
$(MOZ_PACKAGER_MINIFY
),--minify
) \
116 $(if
$(filter omni
,$(MOZ_PACKAGER_FORMAT
)),$(if
$(NON_OMNIJAR_FILES
),--non-resource
$(NON_OMNIJAR_FILES
)))
118 ifeq (cocoa
,$(MOZ_WIDGET_TOOLKIT
))
119 ifneq (en
,$(LPROJ_ROOT
))
120 mv
'$(STAGEDIST)'/en.lproj
'$(STAGEDIST)'/$(LPROJ_ROOT
).lproj
122 ifdef MOZ_CRASHREPORTER
123 # On Mac OS X, the crashreporter.ini file needs to be moved from under the
124 # application bundle's Resources directory where all other l10n files are
125 # located to the crash reporter bundle's Resources directory.
126 mv
'$(STAGEDIST)'/crashreporter.app
/Contents
/Resources
/crashreporter.ini \
127 '$(STAGEDIST)'/..
/MacOS
/crashreporter.app
/Contents
/Resources
/crashreporter.ini
128 $(RM
) -rf
'$(STAGEDIST)'/crashreporter.app
131 ifeq (WINNT
,$(OS_ARCH
))
132 $(MAKE
) -C ..
/installer
/windows CONFIG_DIR
=l10ngen l10ngen
/helper.exe
133 cp ..
/installer
/windows
/l10ngen
/helper.exe
$(STAGEDIST
)/uninstall
136 $(NSINSTALL
) -D
$(DIST
)/l10n-stage
/$(PKG_PATH
)
137 $(call MAKE_PACKAGE
,$(DIST
)/l10n-stage
)
138 # packaging done, undo l10n stuff
139 ifneq (en
,$(LPROJ_ROOT
))
140 ifeq (cocoa
,$(MOZ_WIDGET_TOOLKIT
))
141 mv
'$(STAGEDIST)'/$(LPROJ_ROOT
).lproj
'$(STAGEDIST)'/en.lproj
144 $(NSINSTALL
) -D
$(DIST
)/$(PKG_PATH
)
145 mv
-f
'$(DIST)/l10n-stage/$(PACKAGE)' '$(ZIP_OUT)'
146 if
test -f
'$(DIST)/l10n-stage/$(PACKAGE).asc'; then mv
-f
'$(DIST)/l10n-stage/$(PACKAGE).asc' '$(ZIP_OUT).asc'; fi
148 repackage-zip-
%: unpack
149 @
$(MAKE
) repackage-zip AB_CD
=$* ZIP_IN
='$(ZIP_IN)'
151 # Dealing with app sub dirs: If DIST_SUBDIRS is defined it contains a
152 # listing of app sub-dirs we should include in langpack xpis. If not,
153 # check DIST_SUBDIR, and if that isn't present, just package the default
154 # chrome directory and top-level localization for Fluent.
155 PKG_ZIP_DIRS
= chrome localization
$(or
$(DIST_SUBDIRS
),$(DIST_SUBDIR
))
157 # Clone a l10n repository, either via hg or git
158 # Make this a variable as it's embedded in a sh conditional
159 ifeq ($(VCS_CHECKOUT_TYPE
),hg
)
160 L10N_CO
= $(HG
) --cwd
$(L10NBASEDIR
) clone https
://hg.mozilla.org
/l10n-central
/$(AB_CD
)/
162 ifeq ($(VCS_CHECKOUT_TYPE
),git
)
163 L10N_CO
= $(GIT
) -C
$(L10NBASEDIR
) clone hg
://hg.mozilla.org
/l10n-central
/$(AB_CD
)/
165 L10N_CO
= $(error You need to use either hg or git
)
169 merge-
%: IS_LANGUAGE_REPACK
=1
172 # For nightly builds, we automatically check out missing localizations
173 # from l10n-central. We never automatically check out in automation:
174 # automation builds check out revisions that have been signed-off by
175 # l10n drivers prior to use.
177 if
! test -d
$(L10NBASEDIR
)/$(AB_CD
) ; then \
178 echo
'Error: Automation requires l10n repositories to be checked out: $(L10NBASEDIR)/$(AB_CD)' ; \
183 if
! test -d
$(L10NBASEDIR
)/$(AB_CD
) ; then \
184 echo
'Checking out $(L10NBASEDIR)/$(AB_CD)' ; \
185 $(NSINSTALL
) -D
$(L10NBASEDIR
) ; \
189 $(RM
) -rf
$(REAL_LOCALE_MERGEDIR
)
190 -$(PYTHON3
) $(MOZILLA_DIR
)/mach compare-locales
--merge
$(BASE_MERGE
) $(srcdir)/l10n.toml
$(L10NBASEDIR
) $*
191 # Hunspell dictionaries are interesting, as we don't ship the en-US
192 # dictionary in repacks. Thus we can't use the merge logic from
193 # compare-locales above, which would add en-US.dic and en-US.aff to
194 # the merge directory.
195 # Copy them to the merge dir, if exist. The repackaged app can still decide
196 # on whether to package them or not in `l10n-%` and `chrome-%`.
197 if
test -d
$(L10NBASEDIR
)/$(AB_CD
)/extensions
/spellcheck
; then \
198 $(NSINSTALL
) -D
$(REAL_LOCALE_MERGEDIR
)/extensions
/spellcheck
/hunspell
; \
199 cp
$(L10NBASEDIR
)/$(AB_CD
)/extensions
/spellcheck
/hunspell
/*.
* $(REAL_LOCALE_MERGEDIR
)/extensions
/spellcheck
/hunspell
; \
202 LANGPACK_METADATA
= $(LOCALE_SRCDIR
)/langpack-metadata.ftl
204 langpack-
%: IS_LANGUAGE_REPACK
=1
205 langpack-
%: IS_LANGPACK
=1
207 langpack-
%: clobber-
%
208 @echo
'Making langpack $(LANGPACK_FILE)'
209 @
$(MAKE
) l10n-
$(AB_CD
)
210 @
$(MAKE
) package-langpack-
$(AB_CD
)
212 package-langpack-
%: LANGPACK_FILE
=$(ABS_DIST
)/$(PKG_LANGPACK_PATH
)$(PKG_LANGPACK_BASENAME
).xpi
213 package-langpack-
%: XPI_NAME
=locale-
$*
214 package-langpack-
%: AB_CD
=$*
216 $(NSINSTALL
) -D
$(DIST
)/$(PKG_LANGPACK_PATH
)
217 $(call py_action
,langpack_manifest
$(AB_CD
),--locales
$(AB_CD
) --app-version
$(MOZ_APP_VERSION
) --max-app-ver
$(MOZ_APP_MAXVERSION
) --app-name
'$(MOZ_APP_DISPLAYNAME)' --l10n-basedir
'$(L10NBASEDIR)' --metadata
$(LANGPACK_METADATA
) --langpack-eid
'$(MOZ_LANGPACK_EID)' --input
$(DIST
)/xpi-stage
/locale-
$(AB_CD
))
218 $(call py_action
,zip
$(PKG_LANGPACK_BASENAME
).xpi
,-C
$(DIST
)/xpi-stage
/locale-
$(AB_CD
) -x
**/*.manifest
-x
**/*.js
-x
**/*.ini
$(LANGPACK_FILE
) $(PKG_ZIP_DIRS
) manifest.json
)
220 # This variable is to allow the wget-en-US target to know which ftp server to download from
221 ifndef EN_US_BINARY_URL
222 EN_US_BINARY_URL
= $(error You must set EN_US_BINARY_URL
)
225 # Allow the overriding of PACKAGE format so we can get an EN_US build with a different
226 # PACKAGE format than we are creating l10n packages with.
227 EN_US_PACKAGE_NAME ?
= $(PACKAGE
)
229 # This make target allows us to wget the latest en-US binary from a specified website
230 # The make installers-% target needs the en-US binary in dist/
231 # and for the windows repackages we need the .installer.exe in dist/sea
234 $(error Wget not installed
)
236 $(NSINSTALL
) -D
$(ABS_DIST
)/$(PKG_PATH
)
237 (cd
$(ABS_DIST
)/$(PKG_PATH
) && \
238 $(WGET
) --no-cache
-nv
--no-iri
-N
-O
$(PACKAGE
) '$(EN_US_BINARY_URL)/$(EN_US_PACKAGE_NAME)')
239 @echo
'Downloaded $(EN_US_BINARY_URL)/$(EN_US_PACKAGE_NAME) to $(ABS_DIST)/$(PKG_PATH)/$(PACKAGE)'