Install also udev helper and systemd service file

Signed-off-by: Ladislav Michl <la...@linux-mips.org>
---
Changelog:
 - select TCL also depends on RUNTIME
 - simplify 'or' in makefile's ifdef
 - targetinstall file from pkgdir, not srcdir
 (all above pointed by Michael Olbrich, thanks!)

 rules/usb-modeswitch.in   | 20 +++++++++++++++++---
 rules/usb-modeswitch.make | 24 ++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/rules/usb-modeswitch.in b/rules/usb-modeswitch.in
index aaefd86..3ccf31f 100644
--- a/rules/usb-modeswitch.in
+++ b/rules/usb-modeswitch.in
@@ -1,11 +1,25 @@
 ## SECTION=shell_and_console
 
-config USB_MODESWITCH
-       tristate
-       prompt "usb-modeswitch"
+menuconfig USB_MODESWITCH
+       tristate "usb-modeswitch                "
        select LIBUSB
+       select TCL if (USB_MODESWITCH_UDEV_HELPER || 
USB_MODESWITCH_SYSTEMD_UNIT) && RUNTIME
        help
          USB_ModeSwitch is (surprise!) a mode switching tool
          for controlling 'multi-mode' USB devices.
 
+if USB_MODESWITCH
+
+config USB_MODESWITCH_UDEV_HELPER
+       bool "install udev helper"
+       default y
+       depends on UDEV
+
+config USB_MODESWITCH_SYSTEMD_UNIT
+       bool "install systemd unit file"
+       default y
+       depends on SYSTEMD
+
+endif
+
 # vim: set sw=8 ts=8 noet ft=kconfig:
diff --git a/rules/usb-modeswitch.make b/rules/usb-modeswitch.make
index 4ebf0e8..95149a3 100644
--- a/rules/usb-modeswitch.make
+++ b/rules/usb-modeswitch.make
@@ -37,6 +37,18 @@ USB_MODESWITCH_MAKE_ENV              := $(CROSS_ENV)
 USB_MODESWITCH_MAKE_OPT                := $(CROSS_ENV_PROGS)
 
 # ----------------------------------------------------------------------------
+# Install
+# ----------------------------------------------------------------------------
+
+$(STATEDIR)/usb-modeswitch.install:
+       @$(call targetinfo)
+       @$(call world/install, USB_MODESWITCH)
+       @mkdir -p $(USB_MODESWITCH_PKGDIR)/lib/systemd/system
+       @install -m 0644 $(USB_MODESWITCH_DIR)/usb_modeswitch@.service \
+               
$(USB_MODESWITCH_PKGDIR)/lib/systemd/system/usb_modeswitch@.service
+       @$(call touch)
+
+# ----------------------------------------------------------------------------
 # Target-Install
 # ----------------------------------------------------------------------------
 
@@ -51,6 +63,18 @@ $(STATEDIR)/usb-modeswitch.targetinstall:
 
        @$(call install_copy, usb-modeswitch, 0, 0, 0755, -, \
                /usr/sbin/usb_modeswitch)
+ifneq 
($(PTXCONF_USB_MODESWITCH_UDEV_HELPER)$(PTXCONF_USB_MODESWITCH_SYSTEMD_UNIT),)
+       @$(call install_copy, usb-modeswitch, 0, 0, 0755, -, \
+               /usr/sbin/usb_modeswitch_dispatcher)
+endif
+ifdef PTXCONF_USB_MODESWITCH_UDEV_HELPER
+       @$(call install_copy, usb-modeswitch, 0, 0, 0755, -, \
+               /lib/udev/usb_modeswitch)
+endif
+ifdef PTXCONF_USB_MODESWITCH_SYSTEMD_UNIT
+       @$(call install_copy, usb-modeswitch, 0, 0, 0644, -, \
+               /lib/systemd/system/usb_modeswitch@.service)
+endif
 
        @$(call install_finish, usb-modeswitch)
 
-- 
2.1.4


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

Reply via email to