source: trunk/plugins/example/plugin.mk.example @ 517

Last change on this file since 517 was 517, checked in by amain, 6 years ago

Merge contrib branch 340:516. Main features added:

  • updated plugin architecture
  • improved patch system
  • bitten continous integration support
  • sever build fixed over time to remain in sync with OpenWrt
File size: 4.1 KB
Line 
1# DebWrt - Debian on Embedded devices
2#
3# Copyright (C) 2012 Elliott Mitchell <ehem+debwrt@m5p.com>
4#       2012-10-21  Initial version of this sample plugin.mk file.
5#
6# This program is free software: you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation, either version 3 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
19#
20# This is an example plugin.mk file.  I'm giving examples of some conventional
21# Make constructs, rename this file to "plugin.mk" to see them in action.
22#
23
24
25#
26# This handles enabling/disabling the example plugin
27#
28ifeq ($(CONFIG_$(PLUGIN_VAR)_ENABLE),y)
29
30#
31# Here we check the UUID and configuration version from the .config.  They
32# should match us, if they don't something has happened.
33#
34ifneq ("50b4589d-6e13-4514-b57e-a7ec36e056b3",$(CONFIG_$(PLUGIN_VAR)_UUID))
35$(error Configuration for $(PLUGIN_NAME) out of date/mismatched, reconfigure to fix.)
36endif
37ifneq ("1.0",$(CONFIG_$(PLUGIN_VAR)_CONFVER))
38$(warn $(PLUGIN_NAME) is version 1.0, configuration is version $(call qstrip,$(CONFIG_$(PLUGIN_VAR)_CONFVER)), results may not be good.)
39endif
40
41#
42# This would cause our patches to be applied to the OpenWRT download, check
43# openwrt/patches/README for the naming rules (they are important!).  This will
44# apply patches in openwrt/all to function on all branches and then include
45# patches from branch-specific subdirectory.  This is eval'd since we need
46# $(PLUGIN_PATH), which references $(PLUGIN_ID) to be expanded now, while
47# $(PLUGIN_ID) is valid.
48#
49#$(eval OPENWRT_PATCH_DIRS += "$(PLUGIN_PATH)/openwrt/all" \
50#       $(PLUGIN_PATH)/openwrt/$(OPENWRT_BRANCH))
51#
52# A line like this follows the traditional behavior for plugin patches to the
53# OpenWRT build portion.  All patches in the directory will be used, but you
54# can use the filename to restrict patches to a specific OpenWRT branch (see
55# openwrt/patches/README).  This is eval'd since we need $(PLUGIN_PATH), which
56# references $(PLUGIN_ID) to be expanded now, while $(PLUGIN_ID) is valid.
57#
58#$(eval OPENWRT_PATCH_DIRS += "$(PLUGIN_PATH)/openwrt")
59
60#
61# This makes us a prerequisite of the "clean" rule, so `make clean` will cause
62# us to be invoked.
63#
64clean: $(PLUGIN_RULE)/test
65
66#
67# The end of the enable/disable construct.  Everything follows from the above,
68# pieces, disabling these two portions completely removes us from action.  Our
69# variable will still be known to Make, but unless another plugin touches it...
70#
71endif
72
73
74#
75# Create a Make variable with a random value
76#
77$(PLUGIN_VAR)_TESTVAR = some value
78
79#
80# This creates a pattern-specific Make variable, this is needed in order to
81# access our variables when the rule is used.  By the time the rule is used,
82# $(PLUGIN_ID) will no longer exist.
83#
84$(PLUGIN_RULE)/test $(PLUGIN_RULE)/unplug: PLUGIN_ID := $(PLUGIN_ID)
85
86#
87# This is our rule, it simply prints a couple strings.  This can be invoked
88# by running `make plugins/example/test` (or whatever directory we're installed
89# in).
90#
91$(PLUGIN_RULE)/test:
92        @echo I\'m located in the directory \"$(PLUGIN_NAME)\", the variable is \"$($(PLUGIN_VAR)_TESTVAR)\"\; my id is $(PLUGIN_ID)\; you are number 6
93
94#
95# This adds us as a prerequisite of the "plugins/unplug" rule.  This is for
96# removal of our plugin.  This is unconditional since if we need to remove all
97# traces of ourself, whether or not we're actually enabled in the current
98# configuration.
99#
100plugins/unplug: $(PLUGIN_RULE)/unplug
101
102#
103# If any files in the DebWRT tree were modified, we need to remove those
104# modifications now.  Since this example plugin doesn't do that, we simply
105# produce a pithy message.
106#
107$(PLUGIN_RULE)/unplug:
108        @echo Help\! Help\! I\'m being repressed\! I\'m number $(PLUGIN_ID), and I\'m being removed\!
109
Note: See TracBrowser for help on using the repository browser.