build: introduce luci-base
[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-base
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-base/install
47 $(call Package/luci/install/template,$(1),modules/base)
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-base/config
56 choice
57 prompt "Build Target"
58 default PACKAGE_luci-base_source
59
60 config PACKAGE_luci-base_compile
61 bool "Precompiled"
62
63 config PACKAGE_luci-base_stripped
64 bool "Stripped"
65
66 config PACKAGE_luci-base_srcdiet
67 bool "Compressed Source"
68
69 config PACKAGE_luci-base_source
70 bool "Full Source"
71
72 endchoice
73 endef
74
75 define Package/luci-base/conffiles
76 /etc/config/luci
77 endef
78
79 ifneq ($(CONFIG_PACKAGE_luci-base_compile),)
80 LUA_TARGET:=compile
81 endif
82
83 ifneq ($(CONFIG_PACKAGE_luci-base_stripped),)
84 LUA_TARGET:=strip
85 endif
86
87 ifneq ($(CONFIG_PACKAGE_luci-base_srcdiet),)
88 LUA_TARGET:=diet
89 endif
90
91 ifneq ($(CONFIG_PACKAGE_luci-base),)
92 LUCI_SELECTED_MODULES+=modules/base
93 endif
94
95 LUCI_BUILD_PACKAGES += luci-base
96
97
98 ### Libraries ###
99 define library
100 define Package/luci-lib-$(1)
101 SECTION:=luci
102 CATEGORY:=LuCI
103 TITLE:=LuCI - Lua Configuration Interface
104 URL:=http://luci.subsignal.org/
105 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
106 SUBMENU:=8. Libraries
107 TITLE:=$(if $(2),$(2),LuCI $(1) library)
108 $(if $(3),DEPENDS:=+luci-base $(3))
109 endef
110
111 define Package/luci-lib-$(1)/install
112 $(call Package/luci/install/template,$$(1),libs/$(1))
113 $(call Package/luci-lib-$(1)/extra-install)
114 endef
115
116 ifneq ($(CONFIG_PACKAGE_luci-lib-$(1)),)
117 LUCI_SELECTED_MODULES+=libs/$(1)
118 endif
119
120 LUCI_BUILD_PACKAGES += luci-lib-$(1)
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,httpclient,HTTP(S) client library,+luci-base +luci-lib-nixio))
162 $(eval $(call library,json,LuCI JSON library))
163 $(eval $(call library,nixio,NIXIO POSIX library,+PACKAGE_luci-lib-nixio_openssl:libopenssl +PACKAGE_luci-lib-nixio_cyassl:libcyassl))
164 $(eval $(call library,px5g,RSA/X.509 Key Generator (required for LuCId SSL support),+luci-lib-nixio))
165 $(eval $(call library,luaneightbl,neightbl - Lua lib for IPv6 neighbors,+luci-base))
166
167
168 ### Protocols ###
169 define protocol
170 define Package/luci-proto-$(1)
171 SECTION:=luci
172 CATEGORY:=LuCI
173 TITLE:=LuCI - Lua Configuration Interface
174 URL:=http://luci.subsignal.org/
175 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
176 SUBMENU:=6. Protocols
177 TITLE:=$(if $(2),$(2),LuCI $(1) protocol support)
178 DEPENDS:=$(3)
179 endef
180
181 define Package/luci-proto-$(1)/install
182 $(call Package/luci/install/template,$$(1),protocols/$(1))
183 endef
184
185 ifneq ($(CONFIG_PACKAGE_luci-proto-$(1)),)
186 LUCI_SELECTED_MODULES+=protocols/$(1)
187 endif
188
189 LUCI_BUILD_PACKAGES += luci-proto-$(1)
190 endef
191
192 $(eval $(call protocol,ppp,Support for PPP/PPPoE/PPPoA/PPtP))
193 $(eval $(call protocol,ipv6,Support for DHCPv6/6in4/6to4/6rd/DS-Lite))
194 $(eval $(call protocol,3g,Support for 3G,+PACKAGE_luci-proto-3g:comgt))
195 $(eval $(call protocol,relay,Support for relayd pseudo bridges,+PACKAGE_luci-proto-relay:relayd))
196
197
198 ### Modules ###
199 define module
200 define Package/luci-mod-$(1)
201 SECTION:=luci
202 CATEGORY:=LuCI
203 TITLE:=LuCI - Lua Configuration Interface
204 URL:=http://luci.subsignal.org/
205 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
206 SUBMENU:=2. Modules
207 TITLE:=$(if $(2),$(2),LuCI $(1) module)
208 $(if $(3),DEPENDS+=$(3))
209 endef
210
211 define Package/luci-mod-$(1)/install
212 $(call Package/luci/install/template,$$(1),modules/$(1))
213 $(call Package/luci-mod-$(1)/extra-install)
214 endef
215
216 ifneq ($(CONFIG_PACKAGE_luci-mod-$(1)),)
217 LUCI_SELECTED_MODULES+=modules/$(1)
218 endif
219
220 LUCI_BUILD_PACKAGES += luci-mod-$(1)
221 endef
222
223
224 $(eval $(call module,admin-mini,LuCI Essentials - stripped down and user-friendly,+luci-base @BROKEN))
225 $(eval $(call module,admin-full,LuCI Administration - full-featured for full control,+luci-base))
226 $(eval $(call module,failsafe,LuCI Fail-Safe - Fail-Safe sysupgrade module,+luci-base))
227 $(eval $(call module,rpc,LuCI RPC - JSON-RPC API,+luci-lib-json))
228
229
230 ### Applications ###
231 define application
232 define Package/luci-app-$(1)
233 SECTION:=luci
234 CATEGORY:=LuCI
235 TITLE:=LuCI - Lua Configuration Interface
236 URL:=http://luci.subsignal.org/
237 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
238 SUBMENU:=3. Applications
239 TITLE:=$(if $(2),$(2),LuCI $(1) application)
240 DEPENDS:=$(3)
241 endef
242
243 define Package/luci-app-$(1)/install
244 $(call Package/luci/install/template,$$(1),applications/luci-$(1))
245 endef
246
247 ifneq ($(CONFIG_PACKAGE_luci-app-$(1)),)
248 LUCI_SELECTED_MODULES+=applications/luci-$(1)
249 endif
250
251 LUCI_BUILD_PACKAGES += luci-app-$(1)
252 endef
253
254
255 $(eval $(call application,firewall,Firewall and Portforwarding application,\
256 +PACKAGE_luci-app-firewall:firewall))
257
258 $(eval $(call application,qos,Quality of Service configuration module,\
259 +PACKAGE_luci-app-qos:qos-scripts))
260
261 $(eval $(call application,commands,LuCI Shell Command Module))
262
263
264 ### Themes ###
265 define theme
266 define Package/luci-theme-$(1)
267 SECTION:=luci
268 CATEGORY:=LuCI
269 TITLE:=LuCI - Lua Configuration Interface
270 URL:=http://luci.subsignal.org/
271 SUBMENU:=4. Themes
272 TITLE:=$(if $(2),$(2),LuCI $(1) theme)
273 MAINTAINER:=$(if $(3),$(3),LuCI Development Team <luci@lists.subsignal.org>)
274 DEPENDS:=+luci-base $(4)
275 $(if $(5),DEFAULT:=PACKAGE_luci-base)
276 endef
277
278 define Package/luci-theme-$(1)/install
279 $(call Package/luci/install/template,$$(1),themes/$(1))
280 endef
281
282 ifneq ($(CONFIG_PACKAGE_luci-theme-$(1)),)
283 LUCI_SELECTED_MODULES+=themes/$(1)
284 endif
285
286 LUCI_BUILD_PACKAGES += luci-theme-$(1)
287 endef
288
289 $(eval $(call theme,openwrt,OpenWrt.org))
290 $(eval $(call theme,bootstrap,Bootstrap Theme (default),,,1))
291
292
293 ### Translations ###
294 define translation
295 define Package/luci-i18n-$(1)
296 SECTION:=luci
297 CATEGORY:=LuCI
298 TITLE:=LuCI - Lua Configuration Interface
299 URL:=http://luci.subsignal.org/
300 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
301 SUBMENU:=5. Translations
302 TITLE:=$(if $(2),$(2),$(1))
303 endef
304
305 define Package/luci-i18n-$(1)/install
306 $(call Package/luci/install/template,$$(1),i18n/$(1))
307 endef
308
309 ifneq ($(CONFIG_PACKAGE_luci-i18n-$(1)),)
310 LUCI_SELECTED_MODULES+=i18n/$(1)
311 endif
312
313 LUCI_BUILD_PACKAGES += luci-i18n-$(1)
314 endef
315
316 $(eval $(call translation,german,German))
317 $(eval $(call translation,english,English))
318 $(eval $(call translation,french,French (by Florian Fainelli)))
319 $(eval $(call translation,italian,Italian (by Matteo Croce)))
320 $(eval $(call translation,russian,Russian (by Skryabin Dmitry)))
321 $(eval $(call translation,portuguese-brazilian,Portuguese (Brazilian) (by Carlos Cesario)))
322 $(eval $(call translation,chinese,Chinese (by Chinese Translators)))
323 $(eval $(call translation,japanese,Japanese (by Tsukasa Hamano)))
324 $(eval $(call translation,greek,Greek (by Vasilis Tsiligiannis)))
325 $(eval $(call translation,catalan,Catalan (by Eduard Duran)))
326 $(eval $(call translation,portuguese,Portuguese (by Jose Monteiro)))
327 $(eval $(call translation,spanish,Spanish (by Guillermo Javier Nardoni)))
328 $(eval $(call translation,vietnamese,Vietnamese (by Hong Phuc Dang)))
329 $(eval $(call translation,malay,Malay (by Teow Wai Chet)))
330 $(eval $(call translation,norwegian,Norwegian (by Lars Hardy)))
331 $(eval $(call translation,hebrew,Hebrew))
332 $(eval $(call translation,romanian,Romanian))
333 $(eval $(call translation,ukrainian,Ukrainian))
334 $(eval $(call translation,hungarian,Hungarian))
335 $(eval $(call translation,polish,Polish))
336
337
338 ### Collections ###
339 define collection
340 define Package/luci$(if $(1),-$(1))
341 SECTION:=luci
342 CATEGORY:=LuCI
343 TITLE:=LuCI - Lua Configuration Interface
344 URL:=http://luci.subsignal.org/
345 MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
346 SUBMENU:=1. Collections
347 TITLE:=$(if $(2),$(2),LuCI $(if $(1),$(1),general) collection)
348 $(if $(3),DEPENDS:=$(3))
349 endef
350
351 define Package/luci$(if $(1),-$(1))/install
352 true
353 endef
354
355 LUCI_BUILD_PACKAGES += luci$(if $(1),-$(1))
356 endef
357
358 $(eval $(call collection,,\
359 Standard OpenWrt set including full admin with ppp support and the \
360 default OpenWrt theme,\
361 +uhttpd +uhttpd-mod-ubus +luci-mod-admin-full +luci-theme-bootstrap \
362 +luci-app-firewall +luci-proto-ppp +libiwinfo-lua))
363
364 $(eval $(call collection,ssl,\
365 Standard OpenWrt set with HTTPS support,\
366 +luci +libustream-polarssl +px5g))
367
368 $(eval $(call collection,light,\
369 Minimum package set using only admin mini and the standard theme,\
370 +uhttpd +luci-mod-admin-mini +luci-theme-openwrt @BROKEN))
371
372
373 ### Compile ###
374 PKG_CONFIG_DEPENDS=$(patsubst %,CONFIG_PACKAGE_%,$(LUCI_BUILD_PACKAGES))
375
376 include $(INCLUDE_DIR)/package.mk
377
378 define Build/Prepare
379 @if [ ! -x $(LUCI_TOPDIR)/build/mkrevision.sh ]; then \
380 echo "*** Repository layout changed!" >&2; \
381 echo "*** Please change the LuCI url in feeds.conf to http://svn.luci.subsignal.org/luci/trunk and reinstall the feed with" >&2; \
382 echo "*** ./scripts/feeds update luci; ./scripts/feeds install -a -p luci" >&2; \
383 exit 1; \
384 fi
385 mkdir -p $(PKG_BUILD_DIR)
386 $(TAR) c -C $(LUCI_TOPDIR) . \
387 --exclude=.pc --exclude=.svn --exclude=.git \
388 --exclude='*.o' --exclude='*.so' \
389 --exclude=dist | \
390 tar x -C $(PKG_BUILD_DIR)/
391 $(call Build/Prepare/Default)
392 endef
393
394 define Build/Configure
395 endef
396
397 MAKE_FLAGS += \
398 MODULES="$(LUCI_SELECTED_MODULES)" \
399 LUA_TARGET="$(LUA_TARGET)" \
400 LUA_SHLIBS="-llua -lm -ldl -lcrypt" \
401 CFLAGS="$(TARGET_CFLAGS) $(LUCI_CFLAGS) -I$(STAGING_DIR)/usr/include" \
402 LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \
403 NIXIO_TLS="$(NIXIO_TLS)" OS="Linux"
404
405
406 $(foreach b,$(LUCI_BUILD_PACKAGES),$(eval $(call BuildPackage,$(b))))