5ee13d4d4bfea3e672088d82460a342c25d5bf22
[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) iwinfo
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   endef
275
276   define Package/luci-theme-$(1)/install
277         $(call Package/luci/install/template,$$(1),themes/$(1))
278   endef
279
280   ifneq ($(CONFIG_PACKAGE_luci-theme-$(1)),)
281     LUCI_SELECTED_MODULES+=themes/$(1)
282   endif
283
284   LUCI_BUILD_PACKAGES += luci-theme-$(1)
285 endef
286
287 $(eval $(call theme,openwrt,OpenWrt.org))
288 $(eval $(call theme,bootstrap,Bootstrap Theme (default)))
289
290
291 ### Translations ###
292 define translation
293   define Package/luci-i18n-$(1)
294     SECTION:=luci
295     CATEGORY:=LuCI
296     TITLE:=LuCI - Lua Configuration Interface
297     URL:=http://luci.subsignal.org/
298     MAINTAINER:=LuCI Development Team <luci@lists.subsignal.org>
299     SUBMENU:=5. Translations
300     TITLE:=$(if $(2),$(2),$(1))
301   endef
302
303   define Package/luci-i18n-$(1)/install
304         $(call Package/luci/install/template,$$(1),i18n/$(1))
305   endef
306
307   ifneq ($(CONFIG_PACKAGE_luci-i18n-$(1)),)
308     LUCI_SELECTED_MODULES+=i18n/$(1)
309   endif
310
311   LUCI_BUILD_PACKAGES += luci-i18n-$(1)
312 endef
313
314 $(eval $(call translation,german,German))
315 $(eval $(call translation,english,English))
316 $(eval $(call translation,french,French (by Florian Fainelli)))
317 $(eval $(call translation,italian,Italian (by Matteo Croce)))
318 $(eval $(call translation,russian,Russian (by Skryabin Dmitry)))
319 $(eval $(call translation,portuguese-brazilian,Portuguese (Brazilian) (by Carlos Cesario)))
320 $(eval $(call translation,chinese,Chinese (by Chinese Translators)))
321 $(eval $(call translation,japanese,Japanese (by Tsukasa Hamano)))
322 $(eval $(call translation,greek,Greek (by Vasilis Tsiligiannis)))
323 $(eval $(call translation,catalan,Catalan (by Eduard Duran)))
324 $(eval $(call translation,portuguese,Portuguese (by Jose Monteiro)))
325 $(eval $(call translation,spanish,Spanish (by Guillermo Javier Nardoni)))
326 $(eval $(call translation,vietnamese,Vietnamese (by Hong Phuc Dang)))
327 $(eval $(call translation,malay,Malay (by Teow Wai Chet)))
328 $(eval $(call translation,norwegian,Norwegian (by Lars Hardy)))
329 $(eval $(call translation,hebrew,Hebrew))
330 $(eval $(call translation,romanian,Romanian))
331 $(eval $(call translation,ukrainian,Ukrainian))
332 $(eval $(call translation,hungarian,Hungarian))
333 $(eval $(call translation,polish,Polish))
334
335
336 ### Collections ###
337 define collection
338   define Package/luci$(if $(1),-$(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:=1. Collections
345     TITLE:=$(if $(2),$(2),LuCI $(if $(1),$(1),general) collection)
346     $(if $(3),DEPENDS:=$(3))
347   endef
348
349   define Package/luci$(if $(1),-$(1))/install
350         true
351   endef
352
353   LUCI_BUILD_PACKAGES += luci$(if $(1),-$(1))
354 endef
355
356 $(eval $(call collection,,\
357         Standard OpenWrt set including full admin with ppp support and the \
358         default OpenWrt theme,\
359         +uhttpd +uhttpd-mod-ubus +luci-mod-admin-full +luci-theme-bootstrap \
360         +luci-app-firewall +luci-proto-ppp +libiwinfo-lua +luci-lib-nixio))
361
362 $(eval $(call collection,ssl,\
363         Standard OpenWrt set with HTTPS support,\
364         +luci +libustream-polarssl +px5g))
365
366 $(eval $(call collection,light,\
367         Minimum package set using only admin mini and the standard theme,\
368         +uhttpd +luci-mod-admin-mini +luci-theme-openwrt @BROKEN))
369
370
371 ### Compile ###
372 PKG_CONFIG_DEPENDS=$(patsubst %,CONFIG_PACKAGE_%,$(LUCI_BUILD_PACKAGES))
373
374 include $(INCLUDE_DIR)/package.mk
375
376 define Build/Prepare
377         @if [ ! -x $(LUCI_TOPDIR)/build/mkrevision.sh ]; then \
378                 echo "*** Repository layout changed!" >&2; \
379                 echo "*** Please change the LuCI url in feeds.conf to http://svn.luci.subsignal.org/luci/trunk and reinstall the feed with" >&2; \
380                 echo "*** ./scripts/feeds update luci; ./scripts/feeds install -a -p luci" >&2; \
381                 exit 1; \
382         fi
383         mkdir -p $(PKG_BUILD_DIR)
384         $(TAR) c -C $(LUCI_TOPDIR) . \
385                 --exclude=.pc --exclude=.svn --exclude=.git \
386                 --exclude='*.o' --exclude='*.so' \
387                 --exclude=dist | \
388                         tar x -C $(PKG_BUILD_DIR)/
389         $(call Build/Prepare/Default)
390 endef
391
392 define Build/Configure
393 endef
394
395 MAKE_FLAGS += \
396         MODULES="$(LUCI_SELECTED_MODULES)" \
397         LUA_TARGET="$(LUA_TARGET)" \
398         LUA_SHLIBS="-llua -lm -ldl -lcrypt" \
399         CFLAGS="$(TARGET_CFLAGS) $(LUCI_CFLAGS) -I$(STAGING_DIR)/usr/include" \
400         LDFLAGS="$(TARGET_LDFLAGS) -L$(STAGING_DIR)/usr/lib" \
401         NIXIO_TLS="$(NIXIO_TLS)" OS="Linux"
402
403
404 $(foreach b,$(LUCI_BUILD_PACKAGES),$(eval $(call BuildPackage,$(b))))