luci-proto-nebula: prepare migration to APK
[project/luci.git] / luci.mk
diff --git a/luci.mk b/luci.mk
index cc77b9c60084433adecb33ca041c1fe3d7be91d2..12cdd6de901cfa5dbda1f119afd8f715018f6de2 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -18,7 +18,7 @@ LUCI_MINIFY_LUA?=1
 LUCI_MINIFY_CSS?=1
 LUCI_MINIFY_JS?=1
 
-# Language code titles
+#LUCI_LANG_START
 LUCI_LANG.ar=العربية (Arabic)
 LUCI_LANG.bg=български (Bulgarian)
 LUCI_LANG.bn_BD=বাংলা (Bengali)
@@ -36,13 +36,14 @@ LUCI_LANG.hu=Magyar (Hungarian)
 LUCI_LANG.it=Italiano (Italian)
 LUCI_LANG.ja=日本語 (Japanese)
 LUCI_LANG.ko=한국어 (Korean)
+LUCI_LANG.lt=Lietuvių (Lithuanian)
 LUCI_LANG.mr=Marāṭhī (Marathi)
 LUCI_LANG.ms=Bahasa Melayu (Malay)
 LUCI_LANG.nb_NO=Norsk (Norwegian)
 LUCI_LANG.nl=Nederlands (Dutch)
 LUCI_LANG.pl=Polski (Polish)
-LUCI_LANG.pt_BR=Português do Brasil (Brazilian Portuguese)
 LUCI_LANG.pt=Português (Portuguese)
+LUCI_LANG.pt_BR=Português do Brasil (Brazilian Portuguese)
 LUCI_LANG.ro=Română (Romanian)
 LUCI_LANG.ru=Русский (Russian)
 LUCI_LANG.sk=Slovenčina (Slovak)
@@ -52,6 +53,7 @@ LUCI_LANG.uk=Українська (Ukrainian)
 LUCI_LANG.vi=Tiếng Việt (Vietnamese)
 LUCI_LANG.zh_Hans=简体中文 (Chinese Simplified)
 LUCI_LANG.zh_Hant=繁體中文 (Chinese Traditional)
+#LUCI_LANG_END
 
 # Submenu titles
 LUCI_MENU.col=1. Collections
@@ -72,6 +74,7 @@ LUCI_LC_ALIAS.zh_Hant=zh-tw
 HTDOCS = /www
 LUA_LIBRARYDIR = /usr/lib/lua
 LUCI_LIBRARYDIR = $(LUA_LIBRARYDIR)/luci
+UCODE_LIBRARYDIR = /usr/share/ucode/luci
 
 
 # 1: everything expect po subdir or only po subdir
@@ -82,7 +85,7 @@ define findrev
       if [ -n "$$1" ]; then
         secs="$$(($$1 % 86400))"; \
         yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
-        printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2"; \
+        printf 'git-%s.%05d~%s' "$$yday" "$$secs" "$$2"; \
       else \
         echo "unknown"; \
       fi; \
@@ -113,9 +116,8 @@ PKG_SRC_VERSION?=$(if $(DUMP),x,$(strip $(call findrev,1)))
 PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \
        variant="LuCI"; \
        if git log -1 >/dev/null 2>/dev/null; then \
-               branch=$$(git branch --remote --no-abbrev --contains 2>/dev/null | tail -n1); \
-               branch=$${branch:-$$(git branch --no-abbrev --contains 2>/dev/null)}; \
-               branch=$${branch#? }; branch=$${branch#*/}; \
+               branch=$$(git branch --format='%(refname:strip=3)' --remote --no-abbrev --contains 2>/dev/null | tail -n1); \
+               branch=$${branch:-$$(git branch --format='%(refname:strip=2)' --no-abbrev --contains 2>/dev/null | tail -n1)}; \
                if [ "$$branch" != "master" ]; then \
                        variant="LuCI $${branch:-unknown} branch"; \
                else \
@@ -129,14 +131,20 @@ include $(INCLUDE_DIR)/package.mk
 
 # LUCI_SUBMENU: the submenu-item below the LuCI top-level menu inside OpenWrt menuconfig
 #               usually one of the LUCI_MENU.* definitions
-# LUCI_SUBMENU_DEFAULT: the regular SUBMENU defined by LUCI_TYPE or derrived from the packagename
-# LUCI_SUBMENU_FORCED: manually forced value SUBMENU to set to by explicit definiton
+# LUCI_SUBMENU_DEFAULT: the regular SUBMENU defined by LUCI_TYPE or derived from the packagename
+# LUCI_SUBMENU_FORCED: manually forced value SUBMENU to set to by explicit definition
 #                      can be any string, "none" disables the creation of a submenu
-#                      most usefull in combination with LUCI_CATEGORY, to make the package appear
+#                      most useful in combination with LUCI_CATEGORY, to make the package appear
 #                      anywhere in the menu structure
 LUCI_SUBMENU_DEFAULT=$(if $(LUCI_MENU.$(LUCI_TYPE)),$(LUCI_MENU.$(LUCI_TYPE)),$(LUCI_MENU.app))
 LUCI_SUBMENU=$(if $(LUCI_SUBMENU_FORCED),$(LUCI_SUBMENU_FORCED),$(LUCI_SUBMENU_DEFAULT))
 
+ifneq ($(wildcard ${CURDIR}/luasrc/*),)
+ ifneq ($(filter-out luci-lib-base luci-lua-runtime,$(PKG_NAME)),)
+  LUCI_DEPENDS += +luci-lua-runtime
+ endif
+endif
+
 define Package/$(PKG_NAME)
   SECTION:=$(LUCI_SECTION)
   CATEGORY:=$(LUCI_CATEGORY)
@@ -160,7 +168,7 @@ ifneq ($(LUCI_DESCRIPTION),)
 endif
 
 define Build/Prepare
-       for d in luasrc htdocs root src; do \
+       for d in luasrc ucode htdocs root src; do \
          if [ -d ./$$$$d ]; then \
            mkdir -p $(PKG_BUILD_DIR)/$$$$d; \
                $(CP) ./$$$$d/* $(PKG_BUILD_DIR)/$$$$d/; \
@@ -193,6 +201,11 @@ define Package/$(PKG_NAME)/install
        $(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true)
        $(call SubstituteVersion,$(1)$(LUCI_LIBRARYDIR)/)
  endif
+ ifneq ($(wildcard ${CURDIR}/ucode),)
+         $(INSTALL_DIR) $(1)$(UCODE_LIBRARYDIR)
+         cp -pR $(PKG_BUILD_DIR)/ucode/* $(1)$(UCODE_LIBRARYDIR)/
+         $(call SubstituteVersion,$(1)$(UCODE_LIBRARYDIR)/)
+ endif
  ifneq ($(wildcard ${CURDIR}/htdocs),)
        $(INSTALL_DIR) $(1)$(HTDOCS)
        cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/
@@ -212,7 +225,7 @@ endef
 ifndef Package/$(PKG_NAME)/postinst
 define Package/$(PKG_NAME)/postinst
 [ -n "$${IPKG_INSTROOT}" ] || { \
-       rm -f /tmp/luci-indexcache
+       rm -f /tmp/luci-indexcache.*
        rm -rf /tmp/luci-modulecache/
        killall -HUP rpcd 2>/dev/null
        exit 0
@@ -265,6 +278,11 @@ define SubstituteVersion
                $(SED) 's/<%# *\([^ ]*\)PKG_VERSION *%>/\1$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))/g' \
                    -e 's/"\(<%= *\(media\|resource\) *%>[^"]*\.\(js\|css\)\)"/"\1?v=$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))"/g' \
                        "$$$$src"; \
+       done; \
+       $(FIND) $(1) -type f -name '*.ut' | while read src; do \
+               $(SED) 's/{# *\([^ ]*\)PKG_VERSION *#}/\1$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))/g' \
+                   -e 's/"\({{ *\(media\|resource\) *}}[^"]*\.\(js\|css\)\)"/"\1?v=$(if $(PKG_VERSION),$(PKG_VERSION),$(PKG_SRC_VERSION))"/g' \
+                       "$$$$src"; \
        done
 endef