diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..eeb1b68 --- /dev/null +++ b/Makefile @@ -0,0 +1,12 @@ + +include lib.mk + +ifeq ($(PLUGINS),) + PLUGINS=$(shell ls -I '*mk' -I Makefile -I README.md) +endif + +all: $(PLUGINS) + +$(eval $(call Plugins/Rules)) + + diff --git a/iwx/functions.sh b/iwx/functions.sh index 5533c81..32d5421 100644 --- a/iwx/functions.sh +++ b/iwx/functions.sh @@ -2,9 +2,9 @@ wifi_ifphylist() { if [ "$1" = "phy" ]; then - iw dev | grep Interface | cut -d ' ' -f 2 - else iw phy | grep Wiphy | cut -d ' ' -f 2 + else + iw dev | grep Interface | cut -d ' ' -f 2 fi } @@ -43,7 +43,7 @@ wifi_if_discovery(){ } wifi_phy_discovery(){ - wifi_phylist | grep '^[a-z].*' | zaf_discovery "{#DEV}" + wifi_phylist | grep '^[a-z].*' | zaf_discovery "{#DEV}" } wifi_channels_discovery(){ diff --git a/iwx/plugin.mk b/iwx/plugin.mk new file mode 100644 index 0000000..914e6ea --- /dev/null +++ b/iwx/plugin.mk @@ -0,0 +1,34 @@ + +NAME=iwx +VERSION=0.5 +URL=https://raw.githubusercontent.com/limosek/zaf-plugins/master/iwx +WEB=https://github.com/limosek/zaf-plugins +DEPENDS_OPKG=busybox jshn +DEPENDS_DPKG=dash +DEPENDS_RPM=dash +SUDO=iw +INSTALL_BIN=functions.sh + +ITEMS=if_discovery phy_discovery + +define iwx/Description + Plugin for wifi mac80211 informations and discovery +endef + +define iwx/Item/if_discovery/Description + Discovery of wireless interfaces +endef + +define iwx/Item/if_discovery/Cmd + wifi_if_discovery +endef + +define iwx/Item/phy_discovery/Description + Discovery of wireless physical interfaces +endef + +define iwx/Item/phy_discovery/Cmd + wifi_phy_discovery +endef + + diff --git a/lib.mk b/lib.mk new file mode 100644 index 0000000..d506833 --- /dev/null +++ b/lib.mk @@ -0,0 +1,43 @@ + +define shvar +V_$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) +endef + +define shexport +export $(call shvar,$(1))="$$(call $(1))" +endef + +define newline + + +endef + +define Plugin/Rule + ifeq ($(wildcard $(1)/plugin.mk),) + $(1): + $(MAKE) PLUGINS=$(1) $(1)/control.zaf + $(1)/control.zaf: + @echo -n + else +include $(1)/plugin.mk + $(1): $(1)/control.zaf + $(MAKE) PLUGINS=$(1) $(1)/control.zaf + $(1)/plugin.mk: + $(1)/control.zaf: $(1)/plugin.mk + printf %b '$(subst $(call newline),\n,$(call Plugin/Control,$(1)))' + + endif +endef + +define Plugins/Rules + $(foreach p,$(PLUGINS),$(eval $(call Plugin/Rule,$(p)))) +endef + +define Plugin/Control +Plugin: $(1) +Version: $$(VERSION) +Description:: + $$(call $(1)/Description) +:: +endef +