source: branches/contrib/plugins/plugins.mk @ 449

Last change on this file since 449 was 449, checked in by ehem, 7 years ago

While I like the elegance of all plugins getting equal width Id numbers, this
becomes a problem when you start having to deal with uncertain numbers of
plugins.

File size: 3.3 KB
Line 
1# DebWrt - Debian on Embedded devices
2#
3# Copyright (C) 2011 Johan van Zoomeren <amain@debwrt.net>
4#
5# Copyright (C) 2012 Elliott Mitchell <ehem+debwrt@m5p.com>
6#       2012-10-06  merged OpenWRT patching with DebWRT's patching of OpenWRT
7#       2012-10-06  added ability to include Makefile from plugins
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22ifeq ($(PLUGIN),)
23        PLUGIN_LIST:=$(shell find $(PLUGINS_DIR) -maxdepth 1 -mindepth 1 -type d -name '*' ! -name '.*' -printf '%f\n')
24else
25        PLUGIN_LIST:=$(PLUGIN)
26endif
27
28# include plugin.mk from each plugin (allows influence on build process
29# without needing to patch Makefiles)
30$(foreach PLUGIN_IDX,$(shell seq $(words $(PLUGIN_LIST))),\
31$(eval PLUGIN_NAME:=$(word $(PLUGIN_IDX),$(PLUGIN_LIST)))\
32$(eval -include $(addprefix plugins/,$(addsuffix /plugin.mk,$(PLUGIN_NAME)))))
33PLUGIN_NAME:=\<invalid\>
34
35PLUGIN_CONFIG_LINE = \
36config PLUGINS_$${plugin_up}_ENABLED\n\
37\tbool \"$${plugin}\"\n\
38\tdefault y\n\
39\thelp\n\
40\t  Enable/disable plugin $${plugin}\n
41
42
43# add the plugin patches to the list of patches to OpenWRT
44OPENWRT_PATCH_DIRS += $(wildcard $(addprefix $(PLUGINS_DIR)/,$(addsuffix /openwrt,$(PLUGIN_LIST))))
45
46plugins/config_plugins.in:
47        @for plugin in $(PLUGIN_LIST) hello; \
48        do \
49          plugin_up=$$(echo $${plugin} | tr [a-z] [A-Z]); \
50          /bin/echo -e "$(PLUGIN_CONFIG_LINE)" >>$@; \
51        done
52
53plugins/menuconfig: $(MCONF) plugins/config_plugins.in
54        cd $(PLUGINS_DIR); $(MCONF) Config.in
55
56plugins/list:
57        @for plugin in $(PLUGIN_LIST); \
58        do \
59           echo $${plugin}; \
60        done
61
62plugins/apply:
63        @for plugin in $(PLUGIN_LIST); do \
64                echo "Applying plugin '$$plugin' on DebWrt:"; \
65                for patch in `find $(PLUGINS_DIR)/$$plugin/debwrt -maxdepth 2 -mindepth 1 -type f -printf '%f\n' | sort`; do \
66                        if [ "$${patch%.rpatch}" != "$${patch}" ]; then \
67                                echo "Reverse patch: $$patch"; \
68                                patch -R -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
69                        else \
70                                echo "Normal patch: $$patch"; \
71                                patch -N -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
72                        fi \
73                done; \
74        done; \
75        touch $@
76
77plugins/remove:
78        @for plugin in $(PLUGIN_LIST); do \
79                echo "De-applying plugin '$$plugin' on DebWrt:"; \
80                for patch in `find $(PLUGINS_DIR)/$$plugin/debwrt/ -maxdepth 1 -mindepth 1 -type f -printf '%f\n' | sort -r`; do \
81                        if [ "$${patch%.rpatch}" != "$${patch}" ]; then \
82                                echo "Reverse patch: $$patch"; \
83                                patch -N -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
84                        else \
85                                echo "Normal patch: $$patch"; \
86                                patch -R -p1 -d $(TOPDIR) <$(PLUGINS_DIR)/$$plugin/debwrt/$$patch; \
87                        fi \
88                done; \
89        done; \
90        touch $@
91
92
93plugins/clean:
94        [ -f plugins/apply ] && make -C $(TOPDIR) plugins/remove ; \
95        rm -f plugins/apply plugins/remove
96
97.PHONY: plugins/list \
98        plugins/clean
Note: See TracBrowser for help on using the repository browser.