CLOSED TREE: TraceMonkey merge head. (a=blockers)
[mozilla-central.git] / toolkit / locales / l10n.mk
blob5e43dc3e9357fee8aacee9750beab4102db41a5e
1 # vim:set ts=8 sw=8 sts=8 noet:
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
13 # License.
15 # The Original Code is the Mozilla Browser code.
17 # The Initial Developer of the Original Code is
18 # Benjamin Smedberg <bsmedberg@covad.net>
19 # Portions created by the Initial Developer are Copyright (C) 2004
20 # the Initial Developer. All Rights Reserved.
22 # Contributor(s):
23 # Axel Hecht <l10n@mozilla.com>
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
40 # Shared makefile that can be used to easily kick off l10n builds
41 # of Mozilla applications.
42 # This makefile should be included, and then assumes that the including
43 # makefile defines the following targets:
44 # clobber-zip
45 # This target should remove all language dependent-files from $(STAGEDIST),
46 # depending on $(AB_CD) set to the locale code.
47 # $(AB_CD) will be en-US on the initial unpacking of the package
48 # libs-%
49 # This target should call into the various libs targets that this
50 # application depends on.
51 # Make sure to set BOTH_MANIFESTS=1, as this will be called only once
52 # for both packages and language packs.
53 # installer-%
54 # This target should list all required targets, a typical rule would be
55 # installers-%: clobber-% langpack-% repackage-zip-%
56 # @echo "repackaging done"
57 # to initially clobber the locale staging area, and then to build the
58 # language pack and zip package.
59 # Other targets like windows installers might be listed, too, and should
60 # be defined in the including makefile.
61 # The including makefile should provide values for the variables
62 # MOZ_APP_VERSION and MOZ_LANGPACK_EID.
65 run_for_effects := $(shell if test ! -d $(DIST); then $(NSINSTALL) -D $(DIST); fi)
66 _ABS_DIST := $(shell cd $(DIST) && pwd)
69 # This makefile uses variable overrides from the libs-% target to
70 # build non-default locales to non-default dist/ locations. Be aware!
72 AB = $(firstword $(subst -, ,$(AB_CD)))
74 core_abspath = $(if $(findstring :,$(1)),$(1),$(if $(filter /%,$(1)),$(1),$(CURDIR)/$(1)))
76 # These are defaulted to be compatible with the files the wget-en-US target
77 # pulls. You may override them if you provide your own files. You _must_
78 # override them when MOZ_PKG_PRETTYNAMES is defined - the defaults will not
79 # work in that case.
80 ZIP_IN ?= $(_ABS_DIST)/$(PACKAGE)
81 WIN32_INSTALLER_IN ?= $(_ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe
83 # Allows overriding the final destination of the repackaged file
84 ZIP_OUT ?= $(_ABS_DIST)/$(PACKAGE)
86 DEFINES += \
87 -DAB_CD=$(AB_CD) \
88 -DMOZ_LANGPACK_EID=$(MOZ_LANGPACK_EID) \
89 -DMOZ_APP_VERSION=$(MOZ_APP_VERSION) \
90 -DLOCALE_SRCDIR=$(call core_abspath,$(LOCALE_SRCDIR)) \
91 -DPKG_BASENAME="$(PKG_BASENAME)" \
92 -DPKG_INST_BASENAME="$(PKG_INST_BASENAME)" \
93 $(NULL)
96 clobber-%:
97 $(RM) -rf $(DIST)/xpi-stage/locale-$*
100 PACKAGER_NO_LIBS = 1
101 include $(MOZILLA_DIR)/toolkit/mozapps/installer/packager.mk
104 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
105 STAGEDIST = $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/MacOS
106 else
107 STAGEDIST = $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_DIR)
108 endif
110 $(STAGEDIST): AB_CD:=en-US
111 $(STAGEDIST): UNPACKAGE=$(ZIP_IN)
112 $(STAGEDIST): $(ZIP_IN)
113 # only mac needs to remove the parent of STAGEDIST...
114 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
115 $(RM) -r -v $(DIST)/l10n-stage
116 else
117 # ... and windows doesn't like removing STAGEDIST itself, remove all children
118 find $(STAGEDIST) -maxdepth 1 -print0 | xargs -0 $(RM) -r
119 endif
120 $(NSINSTALL) -D $(DIST)/l10n-stage
121 cd $(DIST)/l10n-stage && \
122 $(UNMAKE_PACKAGE)
123 $(MAKE) clobber-zip AB_CD=en-US
126 unpack: $(STAGEDIST)
127 @echo done unpacking
129 # The path to the object dir for the mozilla-central build system,
130 # may be overridden if necessary.
131 MOZDEPTH ?= $(DEPTH)
133 repackage-zip: UNPACKAGE="$(ZIP_IN)"
134 repackage-zip:
135 # Adjust jar logs with the new locale (can't use sed -i because of bug 373784)
136 -$(PERL) -pi -e "s/en-US/$(AB_CD)/g" $(_ABS_DIST)/jarlog/*.jar.log
137 # call a hook for apps to put their uninstall helper.exe into the package
138 $(UNINSTALLER_PACKAGE_HOOK)
139 # copy xpi-stage over, but not install.rdf and chrome.manifest,
140 # those are just for language packs
141 cd $(DIST)/xpi-stage/locale-$(AB_CD) && \
142 tar --exclude=install.rdf --exclude=chrome.manifest $(TAR_CREATE_FLAGS) - * | ( cd $(STAGEDIST) && tar -xf - )
143 mv $(STAGEDIST)/chrome/$(AB_CD).manifest $(STAGEDIST)/chrome/localized.manifest
144 ifneq (en,$(AB))
145 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
146 mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/en.lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/$(AB).lproj
147 endif
148 endif
149 $(NSINSTALL) -D $(DIST)/l10n-stage/$(PKG_PATH)
150 cd $(DIST)/l10n-stage; \
151 $(MAKE_PACKAGE)
152 ifeq (WINCE,$(OS_ARCH))
153 cd $(DIST)/l10n-stage; \
154 $(MAKE_CAB)
155 endif
156 ifdef MOZ_MAKE_COMPLETE_MAR
157 $(MAKE) -C $(MOZDEPTH)/tools/update-packaging full-update AB_CD=$(AB_CD) \
158 MOZ_PKG_PRETTYNAMES=$(MOZ_PKG_PRETTYNAMES) \
159 PACKAGE_BASE_DIR="$(_ABS_DIST)/l10n-stage" \
160 DIST="$(_ABS_DIST)"
161 endif
162 # packaging done, undo l10n stuff
163 ifneq (en,$(AB))
164 ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
165 mv $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/$(AB).lproj $(_ABS_DIST)/l10n-stage/$(MOZ_PKG_APPNAME)/$(_APPNAME)/Contents/Resources/en.lproj
166 endif
167 endif
168 ifdef MOZ_OMNIJAR
169 @(cd $(STAGEDIST) && $(UNPACK_OMNIJAR))
170 endif
171 $(MAKE) clobber-zip AB_CD=$(AB_CD)
172 $(NSINSTALL) -D $(DIST)/$(PKG_PATH)
173 mv -f "$(DIST)/l10n-stage/$(PACKAGE)" "$(ZIP_OUT)"
174 ifeq (WINCE,$(OS_ARCH))
175 mv -f "$(DIST)/l10n-stage/$(PKG_BASENAME).cab" "$(DIST)/$(PKG_PATH)$(PKG_BASENAME).cab"
176 endif
178 repackage-zip-%: $(ZIP_IN) $(STAGEDIST) libs-%
179 @$(MAKE) repackage-zip AB_CD=$* ZIP_IN=$(ZIP_IN)
181 APP_DEFINES = $(firstword $(wildcard $(LOCALE_SRCDIR)/defines.inc) \
182 $(srcdir)/en-US/defines.inc)
183 TK_DEFINES = $(firstword \
184 $(wildcard $(call EXPAND_LOCALE_SRCDIR,toolkit/locales)/defines.inc) \
185 $(MOZILLA_DIR)/toolkit/locales/en-US/defines.inc)
187 langpack-%: LANGPACK_FILE=$(_ABS_DIST)/$(PKG_LANGPACK_PATH)$(PKG_LANGPACK_BASENAME).xpi
188 langpack-%: AB_CD=$*
189 langpack-%: XPI_NAME=locale-$*
190 langpack-%: libs-%
191 @echo "Making langpack $(LANGPACK_FILE)"
192 $(NSINSTALL) -D $(DIST)/$(PKG_LANGPACK_PATH)
193 $(PERL) $(MOZILLA_DIR)/config/preprocessor.pl $(DEFINES) $(ACDEFINES) -I$(TK_DEFINES) -I$(APP_DEFINES) $(srcdir)/generic/install.rdf > $(FINAL_TARGET)/install.rdf
194 cd $(DIST)/xpi-stage/locale-$(AB_CD) && \
195 $(ZIP) -r9D $(LANGPACK_FILE) install.rdf chrome chrome.manifest -x chrome/$(AB_CD).manifest
198 # This variable is to allow the wget-en-US target to know which ftp server to download from
199 ifndef EN_US_BINARY_URL
200 EN_US_BINARY_URL = $(error You must set EN_US_BINARY_URL)
201 endif
203 # This make target allows us to wget the latest en-US binary from a specified website
204 # The make installers-% target needs the en-US binary in dist/
205 # and for the windows repackages we need the .installer.exe in dist/sea
206 wget-en-US:
207 ifndef WGET
208 $(error Wget not installed)
209 endif
210 (cd $(_ABS_DIST) && $(WGET) -nv -N $(EN_US_BINARY_URL)/$(PACKAGE))
211 @echo "Downloaded $(EN_US_BINARY_URL)/$(PACKAGE) to $(_ABS_DIST)/$(PACKAGE)"
212 ifdef RETRIEVE_WINDOWS_INSTALLER
213 ifeq ($(OS_ARCH), WINNT)
214 $(NSINSTALL) -D $(_ABS_DIST)/$(PKG_INST_PATH)
215 (cd $(_ABS_DIST)/$(PKG_INST_PATH) && $(WGET) -nv -N "$(EN_US_BINARY_URL)/$(PKG_PATH)$(PKG_INST_BASENAME).exe")
216 @echo "Downloaded $(EN_US_BINARY_URL)/$(PKG_PATH)$(PKG_INST_BASENAME).exe to $(_ABS_DIST)/$(PKG_INST_PATH)$(PKG_INST_BASENAME).exe"
217 endif
218 endif
220 generate-snippet-%:
221 $(PYTHON) $(MOZILLA_DIR)/tools/update-packaging/generatesnippet.py \
222 --mar-path=$(_ABS_DIST)/update \
223 --application-ini-file=$(STAGEDIST)/application.ini \
224 --locale=$* \
225 --product=$(MOZ_PKG_APPNAME) \
226 --platform=$(MOZ_PKG_PLATFORM) \
227 --download-base-URL=$(DOWNLOAD_BASE_URL) \
228 --verbose