2 # Copyright (C) 2008-2015 The LuCI Team <luci@lists.subsignal.org>
4 # This is free software, licensed under the Apache License, Version 2.0 .
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 LUCI_PKGARCH?
=$(if
$(realpath src
/Makefile
),,all)
14 # Language code titles
15 LUCI_LANG.ca
=Català
(Catalan
)
16 LUCI_LANG.cs
=Čeština
(Czech
)
17 LUCI_LANG.de
=Deutsch
(German
)
18 LUCI_LANG.el
=Ελληνικά
(Greek
)
20 LUCI_LANG.es
=Español
(Spanish
)
21 LUCI_LANG.fr
=Français
(French
)
22 LUCI_LANG.he
=עִבְרִית
(Hebrew
)
23 LUCI_LANG.hu
=Magyar
(Hungarian
)
24 LUCI_LANG.it
=Italiano
(Italian
)
25 LUCI_LANG.ja
=日本語
(Japanese
)
26 LUCI_LANG.ms
=Bahasa Melayu
(Malay
)
27 LUCI_LANG.no
=Norsk
(Norwegian
)
28 LUCI_LANG.pl
=Polski
(Polish
)
29 LUCI_LANG.pt-br
=Português do Brasil
(Brazialian Portuguese
)
30 LUCI_LANG.pt
=Português
(Portuguese
)
31 LUCI_LANG.ro
=Română
(Romanian
)
32 LUCI_LANG.ru
=Русский
(Russian
)
33 LUCI_LANG.sk
=Slovenčina
(Slovene
)
34 LUCI_LANG.sv
=Svenska
(Swedish
)
35 LUCI_LANG.tr
=Türkçe
(Turkish
)
36 LUCI_LANG.uk
=украї́нська
(Ukrainian
)
37 LUCI_LANG.vi
=Tiếng Việt
(Vietnamese
)
38 LUCI_LANG.zh-cn
=普通话
(Chinese
)
39 LUCI_LANG.zh-tw
=臺灣華語
(Taiwanese
)
42 LUCI_MENU.col
=1. Collections
43 LUCI_MENU.mod
=2. Modules
44 LUCI_MENU.app
=3. Applications
45 LUCI_MENU.theme
=4. Themes
46 LUCI_MENU.proto
=5. Protocols
47 LUCI_MENU.lib
=6. Libraries
50 PKG_NAME?
=$(LUCI_NAME
)
52 PKG_VERSION?
=$(if
$(DUMP
),x
,$(strip $(shell \
53 if svn
info >/dev
/null
2>/dev
/null
; then \
54 revision
="svn-r$$(LC_ALL=C svn info | sed -ne 's/^Revision: //p')"; \
55 elif git log
-1 >/dev
/null
2>/dev
/null
; then \
56 revision
="svn-r$$(LC_ALL=C git log -1 | sed -ne 's/.*git-svn-id: .*@\([0-9]\+\) .*/\1/p')"; \
57 if
[ "$$revision" = "svn-r" ]; then \
58 set
-- $$(git log
-1 --format
="%ct %h"); \
59 secs
="$$(($$1 % 86400))"; \
60 yday
="$$(date --utc --date="@
$$1" "+%y.
%j
")"; \
61 revision
="$$(printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2")"; \
70 PKG_INSTALL
:=$(if
$(realpath src
/Makefile
),1)
71 PKG_BUILD_DEPENDS
+= lua
/host luci-base
/host
$(LUCI_BUILD_DEPENDS
)
72 PKG_CONFIG_DEPENDS
+= CONFIG_LUCI_SRCDIET
74 PKG_BUILD_DIR
:=$(BUILD_DIR
)/$(PKG_NAME
)
76 include $(INCLUDE_DIR
)/package.mk
78 define Package
/$(PKG_NAME
)
81 SUBMENU
:=$(if
$(LUCI_MENU.
$(LUCI_TYPE
)),$(LUCI_MENU.
$(LUCI_TYPE
)),$(LUCI_MENU.app
))
82 TITLE
:=$(if
$(LUCI_TITLE
),$(LUCI_TITLE
),LuCI
$(LUCI_NAME
) $(LUCI_TYPE
))
83 DEPENDS
:=$(LUCI_DEPENDS
)
84 $(if
$(LUCI_PKGARCH
),PKGARCH
:=$(LUCI_PKGARCH
))
87 ifneq ($(LUCI_DESCRIPTION
),)
88 define Package
/$(PKG_NAME
)/description
89 $(strip $(LUCI_DESCRIPTION
))
93 # Language selection for luci-base
94 ifeq ($(PKG_NAME
),luci-base
)
95 define Package
/luci-base
/config
97 bool
"Minify Lua sources"
100 menu
"Translations"$(foreach lang
,$(LUCI_LANGUAGES
),
102 config LUCI_LANG_
$(lang
)
103 tristate
"$(shell echo '$(LUCI_LANG.$(lang))' | sed -e 's/^.* (\(.*\))$$/\1/') ($(lang))")
110 for d in luasrc htdocs root src
; do \
111 if
[ -d .
/$$$$d ]; then \
112 mkdir
-p
$(PKG_BUILD_DIR
)/$$$$d; \
113 $(CP
) .
/$$$$d/* $(PKG_BUILD_DIR
)/$$$$d/; \
116 $(call Build
/Prepare
/Default
)
119 define Build
/Configure
122 ifneq ($(wildcard ${CURDIR}/src
/Makefile
),)
124 MAKE_VARS
+= FPIC
="$(FPIC)" LUCI_VERSION
="$(PKG_VERSION)"
127 $(call Build
/Compile
/Default
,clean compile
)
135 LUA_LIBRARYDIR
= /usr
/lib
/lua
136 LUCI_LIBRARYDIR
= $(LUA_LIBRARYDIR
)/luci
139 $(FIND
) $(1) -type f
-name
'*.lua' | while read src
; do \
140 if
$(STAGING_DIR_HOST
)/bin
/lua
$(STAGING_DIR_HOST
)/bin
/LuaSrcDiet \
141 --noopt-binequiv
-o
"$$$$src.o" "$$$$src"; \
142 then mv
"$$$$src.o" "$$$$src"; fi
; \
146 define Package
/$(PKG_NAME
)/install
147 if
[ -d
$(PKG_BUILD_DIR
)/luasrc
]; then \
148 $(INSTALL_DIR
) $(1)$(LUCI_LIBRARYDIR
); \
149 cp
-pR
$(PKG_BUILD_DIR
)/luasrc
/* $(1)$(LUCI_LIBRARYDIR
)/; \
150 $(if
$(CONFIG_LUCI_SRCDIET
),$(call SrcDiet
,$(1)$(LUCI_LIBRARYDIR
)/),true
); \
152 if
[ -d
$(PKG_BUILD_DIR
)/htdocs
]; then \
153 $(INSTALL_DIR
) $(1)$(HTDOCS
); \
154 cp
-pR
$(PKG_BUILD_DIR
)/htdocs
/* $(1)$(HTDOCS
)/; \
156 if
[ -d
$(PKG_BUILD_DIR
)/root
]; then \
157 $(INSTALL_DIR
) $(1)/; \
158 cp
-pR
$(PKG_BUILD_DIR
)/root
/* $(1)/; \
160 if
[ -d
$(PKG_BUILD_DIR
)/src
]; then \
161 $(call Build
/Install
/Default
) \
162 $(CP
) $(PKG_INSTALL_DIR
)/* $(1)/; \
166 ifneq ($(LUCI_DEFAULTS
),)
167 define Package
/$(PKG_NAME
)/postinst
168 [ -n
"$${IPKG_INSTROOT}" ] ||
{$(foreach script
,$(LUCI_DEFAULTS
),
169 (.
/etc
/uci-defaults
/$(script
)) && rm -f
/etc
/uci-defaults
/$(script
))
176 LUCI_BUILD_PACKAGES
:= $(PKG_NAME
)
178 define LuciTranslation
179 define Package
/luci-i18n-
$(LUCI_BASENAME
)-$(1)
182 TITLE
:=$(PKG_NAME
) - $(1) translation
184 DEFAULT
:=LUCI_LANG_
$(1)||ALL
189 define Package
/luci-i18n-
$(LUCI_BASENAME
)-$(1)/description
190 Translation for
$(PKG_NAME
) - $(LUCI_LANG.
$(1))
193 define Package
/luci-i18n-
$(LUCI_BASENAME
)-$(1)/install
194 $$(INSTALL_DIR
) $$(1)/etc
/uci-defaults
195 echo
"uci set luci.languages.$(subst -,_,$(1))='$(LUCI_LANG.$(1))'; uci commit luci" \
196 > $$(1)/etc
/uci-defaults
/luci-i18n-
$(LUCI_BASENAME
)-$(1)
197 $$(INSTALL_DIR
) $$(1)$(LUCI_LIBRARYDIR
)/i18n
198 $(foreach po
,$(wildcard ${CURDIR}/po
/$(1)/*.po
), \
200 $$(1)$(LUCI_LIBRARYDIR
)/i18n
/$(basename $(notdir $(po
))).
$(1).lmo
;)
203 define Package
/luci-i18n-
$(LUCI_BASENAME
)-$(1)/postinst
204 [ -n
"$$$${IPKG_INSTROOT}" ] ||
{
205 (.
/etc
/uci-defaults
/luci-i18n-
$(LUCI_BASENAME
)-$(1)) && rm -f
/etc
/uci-defaults
/luci-i18n-
$(LUCI_BASENAME
)-$(1)
210 LUCI_BUILD_PACKAGES
+= luci-i18n-
$(LUCI_BASENAME
)-$(1)
214 $(foreach lang
,$(LUCI_LANGUAGES
),$(eval
$(call LuciTranslation
,$(lang
))))
215 $(foreach pkg
,$(LUCI_BUILD_PACKAGES
),$(eval
$(call BuildPackage
,$(pkg
))))