3a196b210e5df97d88d58547a18763d4c03f937b
[project/luci.git] / contrib / package / luci / Makefile
1 include $(TOPDIR)/rules.mk
2
3 LUCI_TOPDIR=../../..
4
5 PKG_NAME:=luci
6 PKG_RELEASE:=1
7
8 PKG_BUILD_PARALLEL:=0
9
10 PKG_VERSION:=$(shell $(LUCI_TOPDIR)/build/mkrevision.sh 2>/dev/null || echo unknown)
11
12 PKG_BUILD_DEPENDS:=$(if $(STAGING_DIR_ROOT),lua/host)
13 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
14 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
15 PKG_USE_MIPS16:=0
16
17 LUA_TARGET:=source
18 LUCI_CFLAGS:=
19 LUCI_BUILD_PACKAGES:=
20 LUCI_SELECTED_MODULES:=
21
22
23 ### Templates ###
24 define Package/luci/install/template
25         $(CP) -a $(PKG_BUILD_DIR)/$(2)/dist/* $(1)/ -R
26         $(CP) -a $(PKG_BUILD_DIR)/$(2)/ipkg/* $(1)/CONTROL/ 2>/dev/null || true
27 endef
28
29
30 ### Core package ###
31 define Package/luci-lib-core
32   SECTION:=luci
33   CATEGORY:=LuCI
34   TITLE:=LuCI - Lua Configuration Interface
35   URL:=http://luci.subsignal.org/
36   MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
37   SUBMENU:=8. Libraries
38   DEPENDS:=+lua +libuci-lua +libubus-lua
39   TITLE:=LuCI core libraries
40 endef
41
42 define Package/luci-lib-core/install
43         $(call Package/luci/install/template,$(1),libs/core)
44         $(PKG_BUILD_DIR)/build/mkversion.sh $(1)/usr/lib/lua/luci/version.lua \
45                 "OpenWrt Firmware" \
46                 "$(OPENWRTVERSION)" \
47                 "trunk" \
48                 "$(PKG_VERSION)"
49 endef
50
51 define Package/luci-lib-core/config
52        choice
53                prompt "Build Target"
54                default PACKAGE_luci-lib-core_source
55
56        config PACKAGE_luci-lib-core_compile
57                bool "Precompiled"
58
59        config PACKAGE_luci-lib-core_stripped
60                bool "Stripped"
61
62        config PACKAGE_luci-lib-core_srcdiet
63                bool "Compressed Source"
64
65        config PACKAGE_luci-lib-core_source
66                bool "Full Source"
67
68        endchoice
69 endef
70
71 ifneq ($(CONFIG_PACKAGE_luci-lib-core_compile),)
72   LUA_TARGET:=compile
73 endif
74
75 ifneq ($(CONFIG_PACKAGE_luci-lib-core_stripped),)
76   LUA_TARGET:=strip
77 endif
78
79 ifneq ($(CONFIG_PACKAGE_luci-lib-core_srcdiet),)
80   LUA_TARGET:=diet
81 endif
82
83 ifneq ($(CONFIG_PACKAGE_luci-lib-core),)
84   LUCI_SELECTED_MODULES+=libs/core
85 endif
86
87 LUCI_BUILD_PACKAGES += luci-lib-core
88
89
90 ### Libraries ###
91 define library
92   define Package/luci-lib-$(1)
93     SECTION:=luci
94     CATEGORY:=LuCI
95     TITLE:=LuCI - Lua Configuration Interface
96     URL:=http://luci.subsignal.org/
97     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
98     SUBMENU:=8. Libraries
99     TITLE:=$(if $(2),$(2),LuCI $(1) library)
100     $(if $(3),DEPENDS:=+luci-lib-core $(3))
101   endef
102
103   define Package/luci-lib-$(1)/install
104         $(call Package/luci/install/template,$$(1),libs/$(1))
105         $(call Package/luci-lib-$(1)/extra-install)
106   endef
107
108   ifneq ($(CONFIG_PACKAGE_luci-lib-$(1)),)
109     LUCI_SELECTED_MODULES+=libs/$(1)
110   endif
111
112   LUCI_BUILD_PACKAGES += luci-lib-$(1)
113 endef
114
115 define Package/luci-lib-web/conffiles
116 /etc/config/luci
117 endef
118
119 define Package/luci-lib-nixio/config
120         choice
121                 prompt "TLS Provider"
122                 default PACKAGE_luci-lib-nixio_notls
123
124                 config PACKAGE_luci-lib-nixio_notls
125                         bool "Disabled"
126
127                 config PACKAGE_luci-lib-nixio_axtls
128                         bool "Builtin (axTLS)"
129
130                 config PACKAGE_luci-lib-nixio_cyassl
131                         bool "CyaSSL"
132                         select PACKAGE_libcyassl
133
134                 config PACKAGE_luci-lib-nixio_openssl
135                         bool "OpenSSL"
136                         select PACKAGE_libopenssl
137         endchoice
138 endef
139
140
141 NIXIO_TLS:=
142
143 ifneq ($(CONFIG_PACKAGE_luci-lib-nixio_axtls),)
144   NIXIO_TLS:=axtls
145 endif
146
147 ifneq ($(CONFIG_PACKAGE_luci-lib-nixio_openssl),)
148   NIXIO_TLS:=openssl
149 endif
150
151 ifneq ($(CONFIG_PACKAGE_luci-lib-nixio_cyassl),)
152   NIXIO_TLS:=cyassl
153   LUCI_CFLAGS+=-I$(STAGING_DIR)/usr/include/cyassl
154 endif
155
156
157 $(eval $(call library,fastindex,Fastindex indexing module,+PACKAGE_luci-lib-fastindex:liblua))
158 $(eval $(call library,httpclient,HTTP(S) client library,+luci-lib-web +luci-lib-nixio))
159 $(eval $(call library,ipkg,LuCI IPKG/OPKG call abstraction library))
160 $(eval $(call library,json,LuCI JSON library))
161 $(eval $(call library,lucid,LuCId Full-Stack Webserver,+luci-lib-nixio +luci-lib-web +luci-lib-px5g))
162 $(eval $(call library,lucid-http,LuCId HTTP Backend,+luci-lib-lucid))
163 $(eval $(call library,lucid-rpc,LuCId RPC Backend,+luci-lib-lucid))
164 $(eval $(call library,nixio,NIXIO POSIX library,+PACKAGE_luci-lib-nixio_openssl:libopenssl +PACKAGE_luci-lib-nixio_cyassl:libcyassl))
165 $(eval $(call library,px5g,RSA/X.509 Key Generator (required for LuCId SSL support),+luci-lib-nixio))
166 $(eval $(call library,sys,LuCI Linux/POSIX system library))
167 $(eval $(call library,web,MVC Webframework,+luci-lib-sys +luci-lib-nixio +luci-lib-core +luci-sgi-cgi))
168 $(eval $(call library,luaneightbl,neightbl - Lua lib for IPv6 neighbors,+luci-lib-core))
169
170
171 ### Protocols ###
172 define protocol
173   define Package/luci-proto-$(1)
174     SECTION:=luci
175     CATEGORY:=LuCI
176     TITLE:=LuCI - Lua Configuration Interface
177     URL:=http://luci.subsignal.org/
178     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
179     SUBMENU:=6. Protocols
180     TITLE:=$(if $(2),$(2),LuCI $(1) protocol support)
181     DEPENDS:=$(3)
182   endef
183
184   define Package/luci-proto-$(1)/install
185         $(call Package/luci/install/template,$$(1),protocols/$(1))
186   endef
187
188   ifneq ($(CONFIG_PACKAGE_luci-proto-$(1)),)
189     LUCI_SELECTED_MODULES+=protocols/$(1)
190   endif
191
192   LUCI_BUILD_PACKAGES += luci-proto-$(1)
193 endef
194
195 $(eval $(call protocol,core,Support for static/dhcp/none))
196 $(eval $(call protocol,ppp,Support for PPP/PPPoE/PPPoA/PPtP))
197 $(eval $(call protocol,ipv6,Support for DHCPv6/6in4/6to4/6rd/DS-Lite))
198 $(eval $(call protocol,3g,Support for 3G,+PACKAGE_luci-proto-3g:comgt))
199 $(eval $(call protocol,relay,Support for relayd pseudo bridges,+PACKAGE_luci-proto-relay:relayd))
200
201
202 ### Modules ###
203 define module
204   define Package/luci-mod-$(1)
205     SECTION:=luci
206     CATEGORY:=LuCI
207     TITLE:=LuCI - Lua Configuration Interface
208     URL:=http://luci.subsignal.org/
209     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
210     SUBMENU:=2. Modules
211     TITLE:=$(if $(2),$(2),LuCI $(1) module)
212     $(if $(3),DEPENDS+=$(3))
213   endef
214
215   define Package/luci-mod-$(1)/install
216         $(call Package/luci/install/template,$$(1),modules/$(1))
217         $(call Package/luci-mod-$(1)/extra-install)
218   endef
219
220   ifneq ($(CONFIG_PACKAGE_luci-mod-$(1)),)
221     LUCI_SELECTED_MODULES+=modules/$(1)
222   endif
223
224   LUCI_BUILD_PACKAGES += luci-mod-$(1)
225 endef
226
227
228 define Package/luci-mod-admin-core/extra-install
229         touch $(1)/etc/init.d/luci_fixtime || true
230 endef
231
232 $(eval $(call module,admin-core,Web UI Core module,+luci-lib-web +luci-proto-core +luci-i18n-english))
233 $(eval $(call module,admin-mini,LuCI Essentials - stripped down and user-friendly,+luci-mod-admin-core @BROKEN))
234 $(eval $(call module,admin-full,LuCI Administration - full-featured for full control,+luci-mod-admin-core +luci-lib-ipkg))
235 $(eval $(call module,failsafe,LuCI Fail-Safe - Fail-Safe sysupgrade module,+luci-mod-admin-core))
236 $(eval $(call module,rpc,LuCI RPC - JSON-RPC API,+luci-lib-json))
237 $(eval $(call module,niu,NIU - Next Generation Interface,+luci-mod-admin-core @BROKEN))
238
239
240 ### Applications ###
241 define application
242   define Package/luci-app-$(1)
243     SECTION:=luci
244     CATEGORY:=LuCI
245     TITLE:=LuCI - Lua Configuration Interface
246     URL:=http://luci.subsignal.org/
247     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
248     SUBMENU:=3. Applications
249     TITLE:=$(if $(2),$(2),LuCI $(1) application)
250         DEPENDS:=$(3)
251   endef
252
253   define Package/luci-app-$(1)/install
254         $(call Package/luci/install/template,$$(1),applications/luci-$(1))
255   endef
256
257   ifneq ($(CONFIG_PACKAGE_luci-app-$(1)),)
258     LUCI_SELECTED_MODULES+=applications/luci-$(1)
259   endif
260
261   LUCI_BUILD_PACKAGES += luci-app-$(1)
262 endef
263
264
265 $(eval $(call application,firewall,Firewall and Portforwarding application,\
266         +PACKAGE_luci-app-firewall:firewall))
267
268 $(eval $(call application,qos,Quality of Service configuration module,\
269         +PACKAGE_luci-app-qos:qos-scripts))
270
271 $(eval $(call application,commands,LuCI Shell Command Module))
272
273
274 ### Server Gateway Interfaces ###
275 define sgi
276   define Package/luci-sgi-$(1)
277     SECTION:=luci
278     CATEGORY:=LuCI
279     TITLE:=LuCI - Lua Configuration Interface
280     URL:=http://luci.subsignal.org/
281     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
282     SUBMENU:=7. Server Interfaces
283     TITLE:=$(if $(2),$(2),LuCI $(1) server gateway interface)
284         DEPENDS:=$(3)
285   endef
286
287   define Package/luci-sgi-$(1)/install
288         $(call Package/luci/install/template,$$(1),libs/sgi-$(1))
289   endef
290
291   ifneq ($(CONFIG_PACKAGE_luci-sgi-$(1)),)
292     LUCI_SELECTED_MODULES+=libs/sgi-$(1)
293   endif
294
295   LUCI_BUILD_PACKAGES += luci-sgi-$(1)
296 endef
297
298 $(eval $(call sgi,cgi,CGI Gateway behind existing Webserver))
299 $(eval $(call sgi,uhttpd,Binding for the uHTTPd server,+uhttpd +uhttpd-mod-lua))
300
301
302 ### Themes ###
303 define theme
304   define Package/luci-theme-$(1)
305     SECTION:=luci
306     CATEGORY:=LuCI
307     TITLE:=LuCI - Lua Configuration Interface
308     URL:=http://luci.subsignal.org/
309     SUBMENU:=4. Themes
310     TITLE:=$(if $(2),$(2),LuCI $(1) theme)
311         MAINTAINER:=$(if $(3),$(3),LuCI Development Team <luci@lists.subsignal.org>)
312         DEPENDS:=$(if $(filter-out base,$(1)),+luci-theme-base) $(4)
313         $(if $(5),DEFAULT:=PACKAGE_luci-lib-core)
314   endef
315
316   define Package/luci-theme-$(1)/install
317         $(call Package/luci/install/template,$$(1),themes/$(1))
318   endef
319
320   ifneq ($(CONFIG_PACKAGE_luci-theme-$(1)),)
321     LUCI_SELECTED_MODULES+=themes/$(1)
322   endif
323
324   LUCI_BUILD_PACKAGES += luci-theme-$(1)
325 endef
326
327 $(eval $(call theme,base,Common base for all themes))
328 $(eval $(call theme,openwrt,OpenWrt.org))
329 $(eval $(call theme,bootstrap,Bootstrap Theme (default),,,1))
330
331 $(eval $(call theme,freifunk-bno,Freifunk Berlin Nordost Theme,\
332         Stefan Pirwitz <stefan-at-freifunk-bno-dot-de>))
333
334 $(eval $(call theme,freifunk-generic,Freifunk Generic Theme,\
335         Manuel Munz <freifunk-at-somakoma-dot-de>))
336
337 ### Translations ###
338 define translation
339   define Package/luci-i18n-$(1)
340     SECTION:=luci
341     CATEGORY:=LuCI
342     TITLE:=LuCI - Lua Configuration Interface
343     URL:=http://luci.subsignal.org/
344     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
345     SUBMENU:=5. Translations
346     TITLE:=$(if $(2),$(2),$(1))
347   endef
348
349   define Package/luci-i18n-$(1)/install
350         $(call Package/luci/install/template,$$(1),i18n/$(1))
351   endef
352
353   ifneq ($(CONFIG_PACKAGE_luci-i18n-$(1)),)
354     LUCI_SELECTED_MODULES+=i18n/$(1)
355   endif
356
357   LUCI_BUILD_PACKAGES += luci-i18n-$(1)
358 endef
359
360 $(eval $(call translation,german,German))
361 $(eval $(call translation,english,English))
362 $(eval $(call translation,french,French (by Florian Fainelli)))
363 $(eval $(call translation,italian,Italian (by Matteo Croce)))
364 $(eval $(call translation,russian,Russian (by Skryabin Dmitry)))
365 $(eval $(call translation,portuguese-brazilian,Portuguese (Brazilian) (by Carlos Cesario)))
366 $(eval $(call translation,chinese,Chinese (by Chinese Translators)))
367 $(eval $(call translation,japanese,Japanese (by Tsukasa Hamano)))
368 $(eval $(call translation,greek,Greek (by Vasilis Tsiligiannis)))
369 $(eval $(call translation,catalan,Catalan (by Eduard Duran)))
370 $(eval $(call translation,portuguese,Portuguese (by Jose Monteiro)))
371 $(eval $(call translation,spanish,Spanish (by Guillermo Javier Nardoni)))
372 $(eval $(call translation,vietnamese,Vietnamese (by Hong Phuc Dang)))
373 $(eval $(call translation,malay,Malay (by Teow Wai Chet)))
374 $(eval $(call translation,norwegian,Norwegian (by Lars Hardy)))
375 $(eval $(call translation,hebrew,Hebrew))
376 $(eval $(call translation,romanian,Romanian))
377 $(eval $(call translation,ukrainian,Ukrainian))
378 $(eval $(call translation,hungarian,Hungarian))
379 $(eval $(call translation,polish,Polish))
380
381
382 ### Collections ###
383 define collection
384   define Package/luci$(if $(1),-$(1))
385     SECTION:=luci
386     CATEGORY:=LuCI
387     TITLE:=LuCI - Lua Configuration Interface
388     URL:=http://luci.subsignal.org/
389     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
390     SUBMENU:=1. Collections
391     TITLE:=$(if $(2),$(2),LuCI $(if $(1),$(1),general) collection)
392     $(if $(3),DEPENDS:=$(3))
393   endef
394
395   define Package/luci$(if $(1),-$(1))/install
396         true
397   endef
398
399   LUCI_BUILD_PACKAGES += luci$(if $(1),-$(1))
400 endef
401
402 $(eval $(call collection,,\
403         Standard OpenWrt set including full admin with ppp support and the \
404         default OpenWrt theme,\
405         +uhttpd +uhttpd-mod-ubus +luci-mod-admin-full +luci-theme-bootstrap \
406         +luci-app-firewall +luci-proto-core +luci-proto-ppp +libiwinfo-lua))
407
408 $(eval $(call collection,ssl,\
409         Standard OpenWrt set with HTTPS support,\
410         +luci +libustream-cyassl +px5g))
411
412 $(eval $(call collection,light,\
413         Minimum package set using only admin mini and the standard theme,\
414         +uhttpd +luci-mod-admin-mini +luci-theme-openwrt @BROKEN))
415
416
417 ### Compile ###
418 PKG_CONFIG_DEPENDS=$(patsubst %,CONFIG_PACKAGE_%,$(LUCI_BUILD_PACKAGES))
419
420 include $(INCLUDE_DIR)/package.mk
421
422 define Build/Prepare
423         @if [ ! -x $(LUCI_TOPDIR)/build/mkrevision.sh ]; then \
424                 echo "*** Repository layout changed!" >&2; \
425                 echo "*** Please change the LuCI url in feeds.conf to http://svn.luci.subsignal.org/luci/trunk and reinstall the feed with" >&2; \
426                 echo "*** ./scripts/feeds update luci; ./scripts/feeds install -a -p luci" >&2; \
427                 exit 1; \
428         fi
429         mkdir -p $(PKG_BUILD_DIR)
430         $(TAR) c -C $(LUCI_TOPDIR) . \
431                 --exclude=.pc --exclude=.svn --exclude=.git \
432                 --exclude='boa-0*' --exclude='*.o' --exclude='*.so' \
433                 --exclude=dist | \
434                         tar x -C $(PKG_BUILD_DIR)/
435         $(call Build/Prepare/Default)
436 endef
437
438 define Build/Configure
439 endef
440
441 MAKE_FLAGS += \
442         MODULES="$(LUCI_SELECTED_MODULES)" \
443         LUA_TARGET="$(LUA_TARGET)" \
444         LUA_SHLIBS="-llua -lm -ldl -lcrypt" \
445         CFLAGS="$(TARGET_CFLAGS) $(LUCI_CFLAGS) -I$(STAGING_DIR)/usr/include" \
446         LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \
447         NIXIO_TLS="$(NIXIO_TLS)" OS="Linux"
448
449
450 $(foreach b,$(LUCI_BUILD_PACKAGES),$(eval $(call BuildPackage,$(b))))