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