summaryrefslogtreecommitdiffstats
path: root/mobile/android/base/locales/Makefile.in
blob: ce0636c12609d4a14c659745aab72bc0ae047be4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

include $(topsrcdir)/config/config.mk

# special case some locale codes, he and id
# http://code.google.com/p/android/issues/detail?id=3639
AB_rCD = $(if $(filter he, $(AB_CD)),iw,$(if $(filter id, $(AB_CD)),in,$(subst -,-r,$(AB_CD))))

# The search strings path is always passed to strings.xml.in; the
# decision to include is made based on the feature flag at the
# inclusion site.
SEARCHSTRINGSPATH = $(abspath $(call MERGE_FILE,search_strings.dtd))

SYNCSTRINGSPATH = $(abspath $(call MERGE_FILE,sync_strings.dtd))
STRINGSPATH = $(abspath $(call MERGE_FILE,android_strings.dtd))
ifeq (,$(XPI_NAME))
BRANDPATH = $(topobjdir)/dist/bin/chrome/$(AB_CD)/locale/branding/brand.dtd
else
BRANDPATH = $(ABS_DIST)/xpi-stage/$(XPI_NAME)/chrome/$(AB_CD)/locale/branding/brand.dtd
endif
$(warnIfEmpty,AB_CD) # todo: $(errorIfEmpty )

dir-res-values := ../res/values
strings-xml    := $(dir-res-values)/strings.xml
strings-xml-in := $(srcdir)/../strings.xml.in

GARBAGE += $(strings-xml)

dir-res-raw := ../res/raw
suggestedsites := $(dir-res-raw)/suggestedsites.json
browsersearch := $(dir-res-raw)/browsersearch.json

libs realchrome:: \
  $(strings-xml) \
  $(NULL)

chrome-%:: AB_CD=$*
chrome-%::
	@$(MAKE) \
	  $(dir-res-values)-$(AB_rCD)/strings.xml \
	  $(dir-res-raw)-$(AB_rCD)/suggestedsites.json \
	  $(dir-res-raw)-$(AB_rCD)/browsersearch.json \
	  AB_CD=$*

# Determine the ../res/values[-*]/ path
strings-xml-bypath  = $(filter %/strings.xml,$(MAKECMDGOALS))
ifeq (,$(strip $(strings-xml-bypath)))
  strings-xml-bypath = $(strings-xml)
endif
dir-strings-xml = $(patsubst %/,%,$(dir $(strings-xml-bypath)))

strings-xml-preqs =\
  $(strings-xml-in) \
  $(BRANDPATH) \
  $(STRINGSPATH) \
  $(SEARCHSTRINGSPATH) \
  $(SYNCSTRINGSPATH) \
  $(if $(IS_LANGUAGE_REPACK),FORCE) \
  $(NULL)

$(dir-strings-xml)/strings.xml: $(strings-xml-preqs)
	$(call py_action,preprocessor, \
      $(DEFINES) \
      $(ACDEFINES) \
	  -DANDROID_PACKAGE_NAME=$(ANDROID_PACKAGE_NAME) \
	  -DBRANDPATH='$(BRANDPATH)' \
	  -DMOZ_APP_DISPLAYNAME='@MOZ_APP_DISPLAYNAME@' \
	  -DSTRINGSPATH='$(STRINGSPATH)' \
	  -DSYNCSTRINGSPATH='$(SYNCSTRINGSPATH)' \
	  -DSEARCHSTRINGSPATH='$(SEARCHSTRINGSPATH)' \
      $< \
	  -o $@)

# Arg 1: Valid Make identifier, like suggestedsites.
# Arg 2: File name, like suggestedsites.json.
define generated_file_template

# Determine the ../res/raw[-*] path.  This can be ../res/raw when no
# locale is explicitly specified.
$(1)-bypath = $(filter %/$(2),$(MAKECMDGOALS))
ifeq (,$$(strip $$($(1)-bypath)))
  $(1)-bypath = $($(1))
endif
$(1)-dstdir-raw = $$(patsubst %/,%,$$(dir $$($(1)-bypath)))

GARBAGE += $($(1))

libs realchrome:: $($(1))
endef

# L10NBASEDIR is not defined for en-US.
l10n-srcdir := $(if $(filter en-US,$(AB_CD)),,$(or $(realpath $(L10NBASEDIR)),$(abspath $(L10NBASEDIR)))/$(AB_CD)/mobile/chrome)

$(eval $(call generated_file_template,suggestedsites,suggestedsites.json))

$(suggestedsites-dstdir-raw)/suggestedsites.json: FORCE
	$(call py_action,generate_suggestedsites, \
		--verbose \
		--android-package-name=$(ANDROID_PACKAGE_NAME) \
		--resources=$(srcdir)/../resources \
		$(if $(filter en-US,$(AB_CD)),,--srcdir=$(l10n-srcdir)) \
		--srcdir=$(topsrcdir)/mobile/locales/en-US/chrome \
		$@)

$(eval $(call generated_file_template,browsersearch,browsersearch.json))

$(browsersearch-dstdir-raw)/browsersearch.json: FORCE
	$(call py_action,generate_browsersearch, \
		--verbose \
		$(if $(filter en-US,$(AB_CD)),,--srcdir=$(l10n-srcdir)) \
		--srcdir=$(topsrcdir)/mobile/locales/en-US/chrome \
		$@)