juci/Makefile

129 lines
3.8 KiB
Makefile
Raw Normal View History

DIRS-y:=juci
PLUGINS-y:=
BIN:=bin
BACKEND_BIN_DIR:=$(BIN)/usr/lib/ubus/juci/
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
Q:=@
2015-09-18 19:43:14 +08:00
INSTALL_DIR:=mkdir -p
all: release
-include Makefile.local
define Plugin/Default
2015-09-18 19:43:14 +08:00
CODE_LOAD:=10
JAVASCRIPT-y:=
TEMPLATES-y:=
STYLES-y:=
endef
define BuildDir-y
$(eval $(call Plugin/Default))
2015-09-18 19:43:14 +08:00
$(eval CODE_LOAD:=50) # same as LOAD, LOAD is deprecated
$(eval TPL_LOAD:=90)
2015-09-18 19:43:14 +08:00
$(eval STYLE_LOAD:=50)
$(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)
$(eval PLUGIN_DIR:=$(CURDIR)/$(2)/$(1))
$(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)
$(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))
@echo -e "\e[0;33m[JS]\t$(1) -> $$@\e[m"
2015-09-18 19:43:14 +08:00
@#echo " * $$^"
@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))
@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
$(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 " * $$^"
@echo "" > $$@
2015-09-18 19:43:14 +08:00
$(Q)if [ "" != "$$^" ]; then ./juci-build-tpl-cache $$^ $$@; fi
$(1)-install:
2015-09-18 19:43:14 +08:00
$(call Plugin/$(1)/install,$(BIN))
$(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
@-chmod +x $(BACKEND_BIN_DIR)/*
$(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
endef
$(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
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
ifneq ($(SELECT_ALL),)
DIRS-y += $(wildcard plugins/*)
endif
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:
@echo "======= JUCI CONFIG ========="
@echo "TARGETS: $(TARGETS)"
@echo "BACKEND: $(UBUS_MODS)"
@./bootstrap.sh
@mkdir -p $(BIN)/www/js/
@mkdir -p $(BIN)/www/css/
2015-09-18 19:43:14 +08:00
@mkdir -p $(BIN)/usr/share/lua/
@mkdir -p $(BIN)/usr/share/rpcd/menu.d/
@mkdir -p $(BIN)/usr/share/rpcd/acl.d/
@mkdir -p $(BACKEND_BIN_DIR)
2015-10-05 23:29:30 +08:00
@mkdir -p $(BIN)/usr/lib/ubus-services/
@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 21:12:21 +08:00
release: prepare $(TARGETS) node_modules $(UBUS_MODS)
@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)
@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
.PHONY: $(PHONY) $(UBUS_MODS)
$(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-03 17:13:45 +08:00
clean:
2015-06-24 05:16:03 +08:00
rm -rf ./bin