2015-09-01 18:27:17 +08:00
|
|
|
DIRS-y:=juci
|
2015-09-18 17:45:01 +08:00
|
|
|
PLUGINS-y:=
|
|
|
|
BIN:=bin
|
2015-09-24 01:54:22 +08:00
|
|
|
BACKEND_BIN_DIR:=$(BIN)/usr/lib/ubus/juci/
|
2015-09-18 17:45:01 +08:00
|
|
|
CODE_DIR:=$(BIN)/www/js
|
|
|
|
CSS_DIR:=$(BIN)/www/css
|
|
|
|
TARGETS:=
|
|
|
|
PHONY:=debug release clean prepare node_modules
|
2015-09-18 19:43:14 +08:00
|
|
|
CP:=cp -Rp
|
2015-09-18 20:24:00 +08:00
|
|
|
Q:=@
|
2015-09-18 19:43:14 +08:00
|
|
|
INSTALL_DIR:=mkdir -p
|
2015-09-18 17:45:01 +08:00
|
|
|
|
|
|
|
all: release
|
|
|
|
|
|
|
|
-include Makefile.local
|
|
|
|
|
|
|
|
define Plugin/Default
|
2015-09-18 19:43:14 +08:00
|
|
|
CODE_LOAD:=10
|
2015-09-18 17:45:01 +08:00
|
|
|
JAVASCRIPT-y:=
|
|
|
|
TEMPLATES-y:=
|
|
|
|
STYLES-y:=
|
|
|
|
endef
|
|
|
|
|
2015-10-08 19:51:26 +08:00
|
|
|
define BuildDir-y
|
2015-09-18 17:45:01 +08:00
|
|
|
$(eval $(call Plugin/Default))
|
2015-09-18 19:43:14 +08:00
|
|
|
$(eval CODE_LOAD:=50) # same as LOAD, LOAD is deprecated
|
2015-09-18 17:45:01 +08:00
|
|
|
$(eval TPL_LOAD:=90)
|
2015-09-18 19:43:14 +08:00
|
|
|
$(eval STYLE_LOAD:=50)
|
2015-09-18 17:45:01 +08:00
|
|
|
$(eval JAVASCRIPT-y:=src/*.js src/pages/*.js src/widgets/*.js)
|
|
|
|
$(eval TEMPLATES-y:=src/widgets/*.html src/pages/*.html)
|
|
|
|
$(eval STYLES-y:=src/css/*.css)
|
2015-09-18 19:51:31 +08:00
|
|
|
$(eval PLUGIN_DIR:=$(CURDIR)/$(2)/$(1))
|
2015-09-18 17:45:01 +08:00
|
|
|
$(eval -include $(2)/$(1)/Makefile)
|
|
|
|
$(eval $(Plugin/$(1)))
|
2015-09-18 19:43:14 +08:00
|
|
|
$(eval TARGETS+=$(1)-install $(CODE_DIR)/$(CODE_LOAD)-$(1).js $(CODE_DIR)/$(TPL_LOAD)-$(1).tpl.js $(CSS_DIR)/$(STYLE_LOAD)-$(1).css)
|
2015-09-18 17:45:01 +08:00
|
|
|
$(eval JAVASCRIPT_$(1):=$(wildcard $(addprefix $(2)/$(1)/,$(JAVASCRIPT-y))))
|
|
|
|
$(eval TEMPLATES_$(1):=$(wildcard $(addprefix $(2)/$(1)/,$(TEMPLATES-y))))
|
|
|
|
$(eval STYLES_$(1):=$(wildcard $(addprefix $(2)/$(1)/,$(STYLES-y))))
|
|
|
|
PHONY += $(1)-install
|
2015-09-18 19:43:14 +08:00
|
|
|
$(CODE_DIR)/$(CODE_LOAD)-$(1).js: $(JAVASCRIPT_$(1))
|
2015-09-18 17:45:01 +08:00
|
|
|
@echo -e "\e[0;33m[JS]\t$(1) -> $$@\e[m"
|
2015-09-18 19:43:14 +08:00
|
|
|
@#echo " * $$^"
|
2015-09-18 17:45:01 +08:00
|
|
|
@echo "" > $$@
|
2015-09-18 19:43:14 +08:00
|
|
|
$(Q)if [ "" != "$$^" ]; then for file in $$^; do cat $$$$file >> $$@; echo "" >> $$@; done; fi
|
|
|
|
$(CSS_DIR)/$(STYLE_LOAD)-$(1).css: $(STYLES_$(1))
|
2015-09-18 17:45:01 +08:00
|
|
|
@echo -e "\e[0;33m[CSS]\t$(1) -> $$@\e[m"
|
|
|
|
@#echo " * $$(STYLES_$(1))"
|
|
|
|
@echo "" > $$@
|
2015-09-18 19:43:14 +08:00
|
|
|
$(Q)if [ "" != "$$^" ]; then for file in $$^; do cat $$$$file >> $$@; echo "" >> $$@; done; fi
|
2015-09-18 17:45:01 +08:00
|
|
|
$(CODE_DIR)/$(TPL_LOAD)-$(1).tpl.js: $(TEMPLATES_$(1))
|
|
|
|
@echo -e "\e[0;33m[HTML]\t$(1) -> $$@\e[m"
|
2015-09-18 19:43:14 +08:00
|
|
|
@#echo " * $$^"
|
2015-09-18 17:45:01 +08:00
|
|
|
@echo "" > $$@
|
2015-09-18 19:43:14 +08:00
|
|
|
$(Q)if [ "" != "$$^" ]; then ./juci-build-tpl-cache $$^ $$@; fi
|
2015-09-18 17:45:01 +08:00
|
|
|
$(1)-install:
|
2015-09-18 19:43:14 +08:00
|
|
|
$(call Plugin/$(1)/install,$(BIN))
|
2015-09-22 21:31:45 +08:00
|
|
|
$(Q)if [ -d $(CURDIR)/$(2)/$(1)/ubus ]; then $(CP) $(CURDIR)/$(2)/$(1)/ubus/* $(BACKEND_BIN_DIR); fi
|
2015-10-05 23:29:30 +08:00
|
|
|
$(Q)if [ -d $(CURDIR)/$(2)/$(1)/service ]; then $(CP) $(CURDIR)/$(2)/$(1)/service/* $(BIN)/usr/lib/ubus-services/; fi
|
2015-09-18 20:47:50 +08:00
|
|
|
@-chmod +x $(BACKEND_BIN_DIR)/*
|
2015-09-18 19:57:51 +08:00
|
|
|
$(Q)if [ -f $(CURDIR)/$(2)/$(1)/menu.json ]; then $(CP) $(CURDIR)/$(2)/$(1)/menu.json $(BIN)/usr/share/rpcd/menu.d/$(1).json; fi
|
|
|
|
$(Q)if [ -f $(CURDIR)/$(2)/$(1)/access.json ]; then $(CP) $(CURDIR)/$(2)/$(1)/access.json $(BIN)/usr/share/rpcd/acl.d/$(1).json; fi
|
2015-09-18 17:45:01 +08:00
|
|
|
endef
|
2015-09-01 18:27:17 +08:00
|
|
|
|
2015-10-08 19:51:26 +08:00
|
|
|
$(eval $(call BuildDir-y,juci,./))
|
|
|
|
$(foreach th,$(wildcard plugins/*),$(eval $(call BuildDir-$(CONFIG_PACKAGE_$(notdir $(th))),$(notdir $(th)),./plugins)))
|
|
|
|
$(foreach th,$(wildcard themes/*),$(eval $(call BuildDir-$(CONFIG_PACKAGE_$(notdir $(th))),$(notdir $(th)),./themes)))
|
2015-06-03 17:13:45 +08:00
|
|
|
|
2015-09-18 17:45:01 +08:00
|
|
|
UBUS_MODS:= backend/igmpinfo
|
|
|
|
|
2015-07-06 20:54:13 +08:00
|
|
|
export CC:=$(CC)
|
2015-07-01 06:19:27 +08:00
|
|
|
export CFLAGS:=$(CFLAGS)
|
2015-06-03 17:13:45 +08:00
|
|
|
|
2015-09-04 18:25:38 +08:00
|
|
|
ifeq ($(DESTDIR),)
|
|
|
|
DESTDIR:=/
|
|
|
|
endif
|
|
|
|
|
2015-09-03 15:53:00 +08:00
|
|
|
ifneq ($(SELECT_ALL),)
|
|
|
|
DIRS-y += $(wildcard plugins/*)
|
|
|
|
endif
|
2015-09-01 21:30:37 +08:00
|
|
|
|
2015-10-02 06:33:45 +08:00
|
|
|
ifeq ($(CONFIG_PACKAGE_juci-ubus-core),y)
|
2015-07-21 19:25:37 +08:00
|
|
|
UBUS_MODS += backend/juci-core
|
2015-07-21 18:41:52 +08:00
|
|
|
endif
|
|
|
|
|
2015-06-24 05:16:03 +08:00
|
|
|
prepare:
|
2015-09-18 17:45:01 +08:00
|
|
|
@echo "======= JUCI CONFIG ========="
|
|
|
|
@echo "TARGETS: $(TARGETS)"
|
|
|
|
@echo "BACKEND: $(UBUS_MODS)"
|
2015-10-08 22:22:17 +08:00
|
|
|
@./bootstrap.sh
|
2015-09-18 17:45:01 +08:00
|
|
|
@mkdir -p $(BIN)/www/js/
|
|
|
|
@mkdir -p $(BIN)/www/css/
|
2015-09-18 19:43:14 +08:00
|
|
|
@mkdir -p $(BIN)/usr/share/lua/
|
2015-09-18 17:45:01 +08:00
|
|
|
@mkdir -p $(BIN)/usr/share/rpcd/menu.d/
|
|
|
|
@mkdir -p $(BIN)/usr/share/rpcd/acl.d/
|
2015-09-18 20:47:50 +08:00
|
|
|
@mkdir -p $(BACKEND_BIN_DIR)
|
2015-10-05 23:29:30 +08:00
|
|
|
@mkdir -p $(BIN)/usr/lib/ubus-services/
|
2015-09-18 17:45:01 +08:00
|
|
|
@mkdir -p $(BIN)/etc/hotplug.d/
|
2015-06-24 05:16:03 +08:00
|
|
|
|
2015-06-24 04:24:21 +08:00
|
|
|
node_modules: package.json
|
|
|
|
npm install --production
|
2015-09-18 17:45:01 +08:00
|
|
|
|
2015-09-18 21:12:21 +08:00
|
|
|
release: prepare $(TARGETS) node_modules $(UBUS_MODS)
|
2015-09-18 17:45:01 +08:00
|
|
|
@echo "======= JUCI BUILD =========="
|
|
|
|
@./juci-compile
|
|
|
|
@./juci-update $(BIN)/www RELEASE
|
|
|
|
|
2015-06-24 04:24:21 +08:00
|
|
|
|
2015-09-18 21:12:21 +08:00
|
|
|
debug: prepare $(TARGETS) $(UBUS_MODS)
|
2015-09-18 17:45:01 +08:00
|
|
|
@echo -e "\e[0;33m [GRUNT] $@ \e[m"
|
|
|
|
@grunt
|
|
|
|
@echo -e "\e[0;33m [UPDATE] $@ \e[m"
|
|
|
|
@./juci-update $(BIN)/www DEBUG
|
2015-06-03 17:13:45 +08:00
|
|
|
|
2015-09-04 18:23:57 +08:00
|
|
|
install:
|
2015-09-28 21:17:02 +08:00
|
|
|
@cp -Rp $(BIN)/* $(DESTDIR)
|
2015-09-04 18:23:57 +08:00
|
|
|
|
2015-09-18 17:45:01 +08:00
|
|
|
.PHONY: $(PHONY) $(UBUS_MODS)
|
2015-06-06 23:50:52 +08:00
|
|
|
|
2015-06-24 02:38:39 +08:00
|
|
|
$(UBUS_MODS):
|
2015-06-24 04:24:21 +08:00
|
|
|
@echo "Building UBUS module $@"
|
2015-07-01 06:19:27 +08:00
|
|
|
@echo "CFLAGS: $(CFLAGS)"
|
2015-09-28 21:17:02 +08:00
|
|
|
@make -i -C $@ clean
|
|
|
|
@make -C $@
|
|
|
|
@cp -Rp $@/build/* $(BIN)/
|
2015-06-24 02:38:39 +08:00
|
|
|
|
2015-06-03 17:13:45 +08:00
|
|
|
clean:
|
2015-06-24 05:16:03 +08:00
|
|
|
rm -rf ./bin
|
2015-09-01 18:27:17 +08:00
|
|
|
|