3
3
BUILD_DATE = $(shell date "+% Y/% m/% d % H:% M:% S")
4
4
COMMON_DIR = ../common
5
5
6
- LOCALEDIR = locale
7
- ifeq ($(LOCALE ) ,)
8
- LOCALEDIR = locale/en-US
9
- else
10
- LOCALEDIR = locale/en-US locale/$(LOCALE)
11
- endif
12
- DOC_FILES = $(foreach dir,$(LOCALEDIR ) ,$(wildcard $(dir ) /* .xml) )
6
+ DOC_FILES = $(foreach dir,locale/en-US,$(wildcard $(dir ) /* .xml) )
13
7
14
8
XPI_FILES = install.rdf TODO AUTHORS NEWS chrome.manifest ../License.txt
15
9
XPI_DIRS = components $(COMMON_DIR ) /components
26
20
XPI_FILE = downloads/$(XPI_NAME).xpi
27
21
endif
28
22
23
+ # ## Locales
24
+ L1 = $(shell ls locale)
25
+ L2 = $(shell ls ../common/locale)
26
+ L1_LEN = $(shell echo $(L1 ) | wc -c)
27
+ L2_LEN = $(shell echo $(L2 ) | wc -c)
28
+ OPTION = $(shell test $(L1_LEN ) -gt $(L2_LEN ) && echo 1)
29
+
30
+ ifeq ($(OPTION ) ,1)
31
+ SUPPORTED_LOCALES = $(L1)
32
+ else
33
+ SUPPORTED_LOCALES = $(L2)
34
+ endif
35
+
36
+ LOCALE_MAP = . locale $(NAME ) \n.. common/locale liberator\n
37
+
29
38
.SILENT :
30
39
31
40
# ### rules
@@ -45,13 +54,12 @@ help:
45
54
@echo " make info - show some info about the system"
46
55
@echo " make xpi - build an XPI ($( XPI_NAME) )"
47
56
@echo " make clean - clean up"
48
- @echo
49
- @echo " running some commands with V=1 will show more build details"
50
57
51
58
info :
52
59
@echo " version $( VERSION) "
53
60
@echo " release file $( XPI) "
54
61
@echo " doc files $( DOC_FILES) "
62
+ @echo " supported locales $( SUPPORTED_LOCALES) "
55
63
@echo " xpi files $( XPI_FILES) "
56
64
57
65
clean :
67
75
# Copy top level files
68
76
cp -L $(XPI_FILES) $(XPI_PATH)
69
77
70
- @echo "Update chrome.manifest for paths used inside the XPI..."
71
- sed -i -e 's# ../common/#common/#' $(XPI_PATH)/chrome.manifest
72
-
73
- if [ "x$(LOCALE)" != "x" ]; then \
74
- echo "locale $(NAME) $(LOCALE) locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
75
- echo "locale liberator $(LOCALE) common/locale/$(LOCALE)/" >> $(XPI_PATH)/chrome.manifest; \
76
- fi
77
-
78
78
# Copy components and modules directories
79
79
cp -LR $(XPI_DIRS) $(XPI_PATH)
80
80
81
81
# Copy all chrome files from commmon/ folder
82
82
cd $(COMMON_DIR) && \
83
- cp -LR $(COMMON_CHROME_DIRS) $(XPI_PATH)/common && \
84
- cp -LR $(LOCALEDIR) $(XPI_PATH)/common/locale || true
83
+ cp -LR $(COMMON_CHROME_DIRS) $(XPI_PATH)/common
85
84
86
85
# Copy all chrome files from vimperator|muttator folder
87
86
cp -LR $(CHROME_DIRS) $(XPI_PATH)
88
- cp -LR $(LOCALEDIR) $(XPI_PATH)/locale || true
87
+
88
+ # Remove existing locale entries from the manifest file
89
+ for locale in $(SUPPORTED_LOCALES); do \
90
+ sed -i -e "/$$locale/d" $(XPI_PATH)/chrome.manifest; \
91
+ done
92
+
93
+ # Package up locale specific documentation files
94
+ # * Create a folder for the requested locale in the build directory
95
+ # * Copy the English version of the documentation files there
96
+ # * Overwrite them with documentation files from the requested locale
97
+ # * Add an entry for the requested locale in the chrome.manifest file
98
+ for locale in $(SUPPORTED_LOCALES); do \
99
+ echo "Including $$locale documentation"; \
100
+ printf "$(LOCALE_MAP)" | \
101
+ while read parent dir name; do\
102
+ src=$$parent/$$dir/$$locale; \
103
+ dest=$(XPI_PATH)/$$dir/$$locale; \
104
+ mkdir -p $$dest; \
105
+ cp -LR $$parent/$$dir/en-US/. $$dest; \
106
+ test -d $$src && \
107
+ cp -LR $$src/. $$dest; \
108
+ echo "locale $$name $$locale $$dir/$$locale/" >> $(XPI_PATH)/chrome.manifest; \
109
+ done;\
110
+ done
111
+
112
+ # Update locale paths in manifest file
113
+ sed -i -e 's# ./locale/# locale/#' $(XPI_PATH)/chrome.manifest
114
+ sed -i -e 's# ../common/#common/#' $(XPI_PATH)/chrome.manifest
89
115
90
116
@echo "Replacing # ##VERSION### and ###DATE### tags"
91
117
for file in `grep -rl -e "# ##VERSION###" -e "###DATE###" $(XPI_PATH)`; do \
124
150
rm -rf ../downloads/common
125
151
126
152
@echo "SUCCESS: $(XPI_FILE)"
127
-
0 commit comments