* Fixed OpenWRT Makefile
[project/luci.git] / contrib / package / luci / Makefile
index 3c5e1d8..d1995f3 100644 (file)
@@ -18,6 +18,7 @@ PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
 
 # LUA_TARGET:=compile LUAC=$(BUILD_DIR_HOST)/lua/luac
 LUA_TARGET:=source
+PKG_SELECTED_MODULES:=
 
 
 include $(INCLUDE_DIR)/package.mk
@@ -25,40 +26,70 @@ include $(INCLUDE_DIR)/package.mk
 define Build/Configure
 endef
 
-define Build/Compile
-       $(MAKE) -C$(PKG_BUILD_DIR) build LUA_TARGET=$(LUA_TARGET)
+
+define Build/Compile 
+       for i in '$(PKG_SELECTED_MODULES)'; do $(MAKE) -C$(PKG_BUILD_DIR)/$$i build LUA_TARGET=$(LUA_TARGET); done
 endef
 
+### Templates ###
 
-define Package/luci/template
+define Package/luci/libtemplate
   SECTION:=admin
   CATEGORY:=Administration
   TITLE:=LuCI - Lua Configuration Interface
   URL:=http://luci.freifunk-halle.net/
   MAINTAINER:=Steven Barth <steven-at-midlink-dot-org>
+  SUBMENU:=LuCI - Libraries
+  DEPENDS:=+luci-core
+endef
+
+define Package/luci/fftemplate
+  $(call Package/luci/libtemplate)
+  SUBMENU:=LuCI - Freifunk Support
+  DEPENDS:=+luci-mod-freifunk
 endef
 
+define Package/luci/webtemplate
+  $(call Package/luci/libtemplate)
+  SUBMENU:=LuCI - Webinterface Components
+endef
+
+
 define Package/luci/install/template
        $(CP) $(PKG_BUILD_DIR)/$(2)/dist/* $(1)/ -R
 endef
 
 
-define Package/luci
-  $(call Package/luci/template)
-  MENU:=1
+
+### Core package ###
+
+define Package/luci-core
+  $(call Package/luci/libtemplate)
   DEPENDS:=+lua +luaposix
+  TITLE:=LuCI core libraries
+endef
+
+define Package/luci-core/install               
+       $(call Package/luci/install/template,$(1),libs/core)
 endef
 
-define Package/luci/install            
-       $(call Package/luci/install/template,$(1),core)
+
+### Libraries ###
+define Package/luci-cbi
+  $(call Package/luci/libtemplate)
+  DEPENDS+=+luci-web
+  TITLE:=Configuration Binding Interface
+endef
+
+define Package/luci-cbi/install
+       $(call Package/luci/install/template,$(1),libs/cbi)
 endef
 
 
-### Web Packages ###
 define Package/luci-web
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-addons
-  TITLE:=LuCI - Webframework
+  $(call Package/luci/libtemplate)
+  DEPENDS+=+luci-addons
+  TITLE:=MVC Webframework
 endef
 
 define Package/luci-web/conffiles
@@ -66,7 +97,7 @@ define Package/luci-web/conffiles
 endef
 
 define Package/luci-web/install
-       $(call Package/luci/install/template,$(1),web)
+       $(call Package/luci/install/template,$(1),libs/web)
        $(call Package/luci/install/template,$(1),themes/fledermaus)
 endef
 
@@ -75,9 +106,9 @@ endef
 ### Community Packages ###
 
 define Package/luci-ff-halle
-  $(call Package/luci/template)
-  DEPENDS:=luci \
-   +luci-sgi-haserl +luci-mod-freifunk +luci-app-splash \
+  $(call Package/luci/fftemplate)
+  DEPENDS+= \
+   +luci-sgi-haserl +luci-app-splash \
    +luci-app-ffwizard-leipzig \
    +olsrd +olsrd-mod-dyn-gw +olsrd-mod-txtinfo +olsrd-mod-nameservice \
    +kmod-tun +ip
@@ -85,13 +116,15 @@ define Package/luci-ff-halle
 endef
 
 define Package/luci-ff-halle/install
+       $(call Package/luci/install/template,$(1),applications/community-halle)
+       $(CP) -a ./ipkg/luci-ff-halle.postinst $(1)/CONTROL/postinst
 endef
 
 
 define Package/luci-ff-leipzig
-  $(call Package/luci/template)
-  DEPENDS:=luci \
-   +luci-sgi-haserl +luci-mod-freifunk +luci-app-splash \
+  $(call Package/luci/fftemplate)
+  DEPENDS+= \
+   +luci-sgi-haserl +luci-app-splash \
    +luci-app-ffwizard-leipzig \
    +olsrd +olsrd-mod-dyn-gw +olsrd-mod-txtinfo +olsrd-mod-nameservice \
    +kmod-tun +ip
@@ -105,9 +138,9 @@ endef
 
 
 define Package/luci-ff-hannover
-  $(call Package/luci/template)
-  DEPENDS:=luci \
-   +luci-sgi-haserl +luci-mod-freifunk +luci-app-splash \
+  $(call Package/luci/fftemplate)
+  DEPENDS+= \
+   +luci-sgi-haserl +luci-app-splash \
    +olsrd +olsrd-mod-dyn-gw +olsrd-mod-txtinfo +olsrd-mod-nameservice
   TITLE:=Freifunk Hannover Community Meta-Package
   URL:=http://www.freifunk-hannover.de/
@@ -123,9 +156,9 @@ endef
 ### Modules ###
 
 define Package/luci-mod-admin-core
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-web +luci-app-cbi
-  TITLE:=Core administrative pages
+  $(call Package/luci/webtemplate)
+  DEPENDS+=+luci-web +luci-cbi
+  TITLE:=Administration module
 endef
 
 define Package/luci-mod-admin-core/install
@@ -134,9 +167,9 @@ endef
 
 
 define Package/luci-mod-freifunk
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-mod-admin-core +luci-app-firewall
-  TITLE:=Freifunk public and administrative pages
+  $(call Package/luci/fftemplate)
+  DEPENDS:=+luci-mod-admin-core
+  TITLE:=LuCI Freifunk module
 endef
 
 define Package/luci-mod-freifunk/conffiles
@@ -151,20 +184,9 @@ endef
 
 ### Applications ###
 
-define Package/luci-app-cbi
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-web
-  TITLE:=Configuration Binding Interface
-endef
-
-define Package/luci-app-cbi/install
-       $(call Package/luci/install/template,$(1),applications/cbi)
-endef
-
-
 define Package/luci-app-ffwizard-leipzig
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-mod-freifunk
+  $(call Package/luci/fftemplate)
+  DEPENDS+=+luci-app-firewall
   TITLE:=Freifunk Leipzig configuration wizard
 endef
 
@@ -174,8 +196,8 @@ endef
 
 
 define Package/luci-app-firewall
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-mod-admin-core
+  $(call Package/luci/webtemplate)
+  DEPENDS+=+luci-mod-admin-core
   TITLE:=Firewall and Portforwarding application
 endef
 
@@ -190,8 +212,8 @@ endef
 
 
 define Package/luci-app-splash
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-mod-freifunk +luci-sgi-haserl +iptables-mod-nat +iptables-mod-ipopt
+  $(call Package/luci/fftemplate)
+  DEPENDS+=+luci-sgi-haserl +iptables-mod-nat +iptables-mod-ipopt
   TITLE:=Freifunk DHCP-Splash application
 endef
 
@@ -210,8 +232,8 @@ endef
 
 
 define Package/luci-app-statistics
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-mod-admin-core +collectd +collectd-mod-rrdtool1 +rrdtool1
+  $(call Package/luci/webtemplate)
+  DEPENDS+=+luci-mod-admin-core +collectd +collectd-mod-rrdtool1 +rrdtool1
   TITLE:=LuCI Statistics Application (incomplete)
 endef
 
@@ -229,31 +251,75 @@ endef
 ### Server Gateway Interfaces ###
 
 define Package/luci-sgi-haserl
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-web +haserl-lua
+  $(call Package/luci/libtemplate)
+  DEPENDS+=+luci-web +haserl-lua
   TITLE:=SGI for Haserl
 endef
 
 define Package/luci-sgi-haserl/install
-       $(call Package/luci/install/template,$(1),applications/sgi-haserl)
+       $(call Package/luci/install/template,$(1),libs/sgi-haserl)
        $(CP) -a ./ipkg/luci-sgi-haserl.postinst $(1)/CONTROL/postinst
 endef
 
 
 define Package/luci-sgi-webuci
-  $(call Package/luci/template)
-  DEPENDS:=luci +luci-web
+  $(call Package/luci/libtemplate)
+  DEPENDS+=+luci-web
   TITLE:=SGI for Webuci
 endef
 
 define Package/luci-sgi-webuci/install
-       $(call Package/luci/install/template,$(1),applications/sgi-webuci)
-endef
-
-
-
-
-$(eval $(call BuildPackage,luci))
+       $(call Package/luci/install/template,$(1),libs/sgi-webuci)
+endef
+
+### Compile Templates ###
+ifneq ($(CONFIG_PACKAGE_luci-core),)
+       PKG_SELECTED_MODULES+=libs/core
+endif
+ifneq ($(CONFIG_PACKAGE_luci-cbi),)
+       PKG_SELECTED_MODULES+=libs/cbi
+endif
+ifneq ($(CONFIG_PACKAGE_luci-web),)
+       PKG_SELECTED_MODULES+=libs/web
+endif
+
+ifneq ($(CONFIG_PACKAGE_luci-ff-halle),)
+       PKG_SELECTED_MODULES+=applications/community-halle
+endif
+ifneq ($(CONFIG_PACKAGE_luci-ff-leipzig),)
+       PKG_SELECTED_MODULES+=applications/community-leipzig
+endif
+ifneq ($(CONFIG_PACKAGE_luci-ff-hannover),)
+       PKG_SELECTED_MODULES+=applications/community-hannover
+endif
+
+ifneq ($(CONFIG_PACKAGE_luci-mod-admin-core),)
+       PKG_SELECTED_MODULES+=modules/admin-core
+endif
+ifneq ($(CONFIG_PACKAGE_luci-mod-freifunk),)
+       PKG_SELECTED_MODULES+=modules/freifunk
+endif
+
+ifneq ($(CONFIG_PACKAGE_luci-app-ffwizard-leipzig),)
+       PKG_SELECTED_MODULES+=applications/luci-ffwizard-leipzig
+endif
+ifneq ($(CONFIG_PACKAGE_luci-app-splash),)
+       PKG_SELECTED_MODULES+=applications/luci-splash
+endif
+ifneq ($(CONFIG_PACKAGE_luci-app-statistics),)
+       PKG_SELECTED_MODULES+=applications/luci-statistics
+endif
+
+ifneq ($(CONFIG_PACKAGE_luci-sgi-haserl),)
+       PKG_SELECTED_MODULES+=libs/sgi-haserl
+endif
+ifneq ($(CONFIG_PACKAGE_luci-sgi-webuci),)
+       PKG_SELECTED_MODULES+=libs/sgi-webuci
+endif
+
+
+$(eval $(call BuildPackage,luci-core))
+$(eval $(call BuildPackage,luci-cbi))
 $(eval $(call BuildPackage,luci-web))
 
 $(eval $(call BuildPackage,luci-ff-halle))
@@ -263,7 +329,6 @@ $(eval $(call BuildPackage,luci-ff-hannover))
 $(eval $(call BuildPackage,luci-mod-admin-core))
 $(eval $(call BuildPackage,luci-mod-freifunk))
 
-$(eval $(call BuildPackage,luci-app-cbi))
 $(eval $(call BuildPackage,luci-app-ffwizard-leipzig))
 $(eval $(call BuildPackage,luci-app-firewall))
 $(eval $(call BuildPackage,luci-app-splash))