luci.mk: cosmetic change for translation description
[project/luci.git] / luci.mk
1 #
2 # Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
3 #
4 # This is free software, licensed under the Apache License, Version 2.0 .
5 #
6
7 LUCI_NAME?=$(notdir ${CURDIR})
8 LUCI_TYPE?=$(word 2,$(subst -, ,$(LUCI_NAME)))
9 LUCI_BASENAME?=$(patsubst luci-$(LUCI_TYPE)-%,%,$(LUCI_NAME))
10 LUCI_LANGUAGES:=$(filter-out templates,$(notdir $(wildcard ${CURDIR}/po/*)))
11 LUCI_DEFAULTS:=$(notdir $(wildcard ${CURDIR}/root/etc/uci-defaults/*))
12
13 # Language code titles
14 LUCI_LANG.ca=Català (Catalan)
15 LUCI_LANG.cs=Čeština (Czech)
16 LUCI_LANG.de=Deutsch (German)
17 LUCI_LANG.el=Ελληνικά (Greek)
18 LUCI_LANG.en=English
19 LUCI_LANG.es=Español (Spanish)
20 LUCI_LANG.fr=Français (French)
21 LUCI_LANG.he=עִבְרִית (Hebrew)
22 LUCI_LANG.hu=Magyar (Hungarian)
23 LUCI_LANG.it=Italiano (Italian)
24 LUCI_LANG.ja=日本語 (Japanese)
25 LUCI_LANG.ms=Bahasa Melayu (Malay)
26 LUCI_LANG.no=Norsk (Norwegian)
27 LUCI_LANG.pl=Polski (Polish)
28 LUCI_LANG.pt-br=Português do Brasil (Brazialian Portuguese)
29 LUCI_LANG.pt=Português (Portuguese)
30 LUCI_LANG.ro=Română (Romanian)
31 LUCI_LANG.ru=Русский (Russian)
32 LUCI_LANG.sk=Slovenčina (Slovene)
33 LUCI_LANG.sv=Svenska (Swedish)
34 LUCI_LANG.tr=Türkçe (Turkish)
35 LUCI_LANG.uk=украї́нська (Ukrainian)
36 LUCI_LANG.vi=Tiếng Việt (Vietnamese)
37 LUCI_LANG.zh-cn=普通话 (Chinese)
38 LUCI_LANG.zh-tw=臺灣華語 (Taiwanese)
39
40 # Submenu titles
41 LUCI_MENU.col=1. Collections
42 LUCI_MENU.mod=2. Modules
43 LUCI_MENU.app=3. Applications
44 LUCI_MENU.theme=4. Themes
45 LUCI_MENU.proto=5. Protocols
46 LUCI_MENU.lib=6. Libraries
47
48
49 PKG_NAME?=$(LUCI_NAME)
50
51 PKG_VERSION?=$(if $(DUMP),x,$(strip $(shell \
52 if svn info >/dev/null 2>/dev/null; then \
53 revision="svn-r$$(LC_ALL=C svn info | sed -ne 's/^Revision: //p')"; \
54 elif git log -1 >/dev/null 2>/dev/null; then \
55 revision="svn-r$$(LC_ALL=C git log -1 | sed -ne 's/.*git-svn-id: .*@\([0-9]\+\) .*/\1/p')"; \
56 if [ "$$revision" = "svn-r" ]; then \
57 set -- $$(git log -1 --format="%ct %h"); \
58 secs="$$(($$1 % 86400))"; \
59 yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
60 revision="$$(printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2")"; \
61 fi; \
62 else \
63 revision="unknown"; \
64 fi; \
65 echo "$$revision" \
66 )))
67
68 PKG_RELEASE?=1
69 PKG_INSTALL:=$(if $(realpath src/Makefile),1)
70 PKG_BUILD_DEPENDS += lua/host luci-base/host $(LUCI_BUILD_DEPENDS)
71 PKG_CONFIG_DEPENDS += CONFIG_LUCI_SRCDIET
72
73 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
74
75 include $(INCLUDE_DIR)/package.mk
76
77 define Package/$(PKG_NAME)
78 SECTION:=luci
79 CATEGORY:=LuCI
80 SUBMENU:=$(if $(LUCI_MENU.$(LUCI_TYPE)),$(LUCI_MENU.$(LUCI_TYPE)),$(LUCI_MENU.app))
81 TITLE:=$(if $(LUCI_TITLE),$(LUCI_TITLE),LuCI $(LUCI_NAME) $(LUCI_TYPE))
82 DEPENDS:=$(LUCI_DEPENDS)
83 endef
84
85 ifneq ($(LUCI_DESCRIPTION),)
86 define Package/$(PKG_NAME)/description
87 $(strip $(LUCI_DESCRIPTION))
88 endef
89 endif
90
91 # Language selection for luci-base
92 ifeq ($(PKG_NAME),luci-base)
93 define Package/luci-base/config
94 config LUCI_SRCDIET
95 bool "Minify Lua sources"
96 default n
97
98 menu "Translations"$(foreach lang,$(LUCI_LANGUAGES),
99
100 config LUCI_LANG_$(lang)
101 tristate "$(shell echo '$(LUCI_LANG.$(lang))' | sed -e 's/^.* (\(.*\))$$/\1/') ($(lang))")
102
103 endmenu
104 endef
105 endif
106
107 define Build/Prepare
108 for d in luasrc htdocs root src; do \
109 if [ -d ./$$$$d ]; then \
110 mkdir -p $(PKG_BUILD_DIR)/$$$$d; \
111 $(CP) ./$$$$d/* $(PKG_BUILD_DIR)/$$$$d/; \
112 fi; \
113 done
114 $(call Build/Prepare/Default)
115 endef
116
117 define Build/Configure
118 endef
119
120 ifneq ($(wildcard ${CURDIR}/src/Makefile),)
121 MAKE_PATH := src/
122 MAKE_VARS += FPIC="$(FPIC)" LUCI_VERSION="$(PKG_VERSION)"
123
124 define Build/Compile
125 $(call Build/Compile/Default,clean compile)
126 endef
127 else
128 define Build/Compile
129 endef
130 endif
131
132 HTDOCS = /www
133 LUA_LIBRARYDIR = /usr/lib/lua
134 LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci
135
136 define SrcDiet
137 $(FIND) $(1) -type f -name '*.lua' | while read src; do \
138 if $(STAGING_DIR_HOST)/bin/lua $(STAGING_DIR_HOST)/bin/LuaSrcDiet \
139 --noopt-binequiv -o "$$$$src.o" "$$$$src"; \
140 then mv "$$$$src.o" "$$$$src"; fi; \
141 done
142 endef
143
144 define Package/$(PKG_NAME)/install
145 if [ -d $(PKG_BUILD_DIR)/luasrc ]; then \
146 $(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR); \
147 cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/; \
148 $(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true); \
149 else true; fi
150 if [ -d $(PKG_BUILD_DIR)/htdocs ]; then \
151 $(INSTALL_DIR) $(1)$(HTDOCS); \
152 cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/; \
153 else true; fi
154 if [ -d $(PKG_BUILD_DIR)/root ]; then \
155 $(INSTALL_DIR) $(1)/; \
156 cp -pR $(PKG_BUILD_DIR)/root/* $(1)/; \
157 else true; fi
158 if [ -d $(PKG_BUILD_DIR)/src ]; then \
159 $(call Build/Install/Default) \
160 $(CP) $(PKG_INSTALL_DIR)/* $(1)/; \
161 else true; fi
162 endef
163
164 ifneq ($(LUCI_DEFAULTS),)
165 define Package/$(PKG_NAME)/postinst
166 [ -n "$${IPKG_INSTROOT}" ] || {$(foreach script,$(LUCI_DEFAULTS),
167 (. /etc/uci-defaults/$(script)) && rm -f /etc/uci-defaults/$(script))
168 exit 0
169 }
170 endef
171 endif
172
173
174 LUCI_BUILD_PACKAGES := $(PKG_NAME)
175
176 define LuciTranslation
177 define Package/luci-i18n-$(LUCI_BASENAME)-$(1)
178 SECTION:=luci
179 CATEGORY:=LuCI
180 TITLE:=$(PKG_NAME) - $(1) translation
181 HIDDEN:=1
182 DEFAULT:=LUCI_LANG_$(1)||ALL
183 DEPENDS:=$(PKG_NAME)
184 endef
185
186 define Package/luci-i18n-$(LUCI_BASENAME)-$(1)/description
187 Translation for $(PKG_NAME) - $(LUCI_LANG.$(1))
188 endef
189
190 define Package/luci-i18n-$(LUCI_BASENAME)-$(1)/install
191 $$(INSTALL_DIR) $$(1)/etc/uci-defaults
192 echo "uci set luci.languages.$(subst -,_,$(1))='$(LUCI_LANG.$(1))'; uci commit luci" \
193 > $$(1)/etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)
194 $$(INSTALL_DIR) $$(1)$(LUCI_LIBRARYDIR)/i18n
195 $(foreach po,$(wildcard ${CURDIR}/po/$(1)/*.po), \
196 po2lmo $(po) \
197 $$(1)$(LUCI_LIBRARYDIR)/i18n/$(basename $(notdir $(po))).$(1).lmo;)
198 endef
199
200 define Package/luci-i18n-$(LUCI_BASENAME)-$(1)/postinst
201 [ -n "$$$${IPKG_INSTROOT}" ] || {
202 (. /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)) && rm -f /etc/uci-defaults/luci-i18n-$(LUCI_BASENAME)-$(1)
203 exit 0
204 }
205 endef
206
207 LUCI_BUILD_PACKAGES += luci-i18n-$(LUCI_BASENAME)-$(1)
208
209 endef
210
211 $(foreach lang,$(LUCI_LANGUAGES),$(eval $(call LuciTranslation,$(lang))))
212 $(foreach pkg,$(LUCI_BUILD_PACKAGES),$(eval $(call BuildPackage,$(pkg))))