7 OBJS
= usb_modeswitch.c
8 PREFIX
= $(DESTDIR
)/usr
9 ETCDIR
= $(DESTDIR
)/etc
10 SYSDIR
= $(ETCDIR
)/systemd
/system
11 UPSDIR
= $(ETCDIR
)/init
12 UDEVDIR
= $(DESTDIR
)/lib
/udev
13 SBINDIR
= $(PREFIX
)/sbin
14 MANDIR
= $(PREFIX
)/share
/man
/man1
16 HOST_TCL
:= $(shell cd jim
&& .
/autosetup
/find-tclsh
)
17 ifeq (,$(findstring jimsh0
,$(HOST_TCL
)))
22 JIM_CONFIGURE_OPTS
= --disable-lineedit \
23 --with-out-jim-ext
="stdlib posix load signal syslog" --prefix=/usr
25 .PHONY
: clean install install-common
uninstall \
26 script shared static \
27 dispatcher-script dispatcher-shared dispatcher-static \
28 install-script install-shared install-static
32 script
: $(PROG
) dispatcher-script
34 shared
: $(PROG
) dispatcher-shared
36 static
: $(PROG
) dispatcher-static
38 $(PROG
): $(OBJS
) usb_modeswitch.h
39 $(CC
) -o
$(PROG
) $(OBJS
) $(CFLAGS
) $(LIBS
) $(LDFLAGS
)
42 cd jim
&& CFLAGS
="$(CFLAGS)" CC
="$(CC)" .
/configure
$(JIM_CONFIGURE_OPTS
) --shared
46 cd jim
&& CFLAGS
="$(CFLAGS)" CC
="$(CC)" .
/configure
$(JIM_CONFIGURE_OPTS
)
49 dispatcher-script
: usb_modeswitch.tcl
50 sed
's_!/usr/bin/tclsh_!'"$(TCL)"'_' < usb_modeswitch.tcl
> usb_modeswitch_dispatcher
52 dispatcher-shared
: jim
/libjim.so dispatcher.c usb_modeswitch.string
53 $(CC
) dispatcher.c
$(LDFLAGS
) -Ljim
-ljim
-Ijim
-o usb_modeswitch_dispatcher
$(CFLAGS
)
55 dispatcher-static
: jim
/libjim.a dispatcher.c usb_modeswitch.string
56 $(CC
) dispatcher.c
$(LDFLAGS
) jim
/libjim.a
-Ijim
-o usb_modeswitch_dispatcher
$(CFLAGS
)
58 usb_modeswitch.string
: usb_modeswitch.tcl
59 $(HOST_TCL
) make_string.tcl usb_modeswitch.tcl
> $@
63 $(RM
) usb_modeswitch_dispatcher
64 $(RM
) usb_modeswitch.string
65 $(RM
) jim
/autosetup
/jimsh0
66 $(RM
) jim
/autosetup
/jimsh0.c
69 -$(MAKE
) -C jim
distclean
73 $(RM
) usb_modeswitch_dispatcher
74 $(RM
) usb_modeswitch.string
76 # If the systemd folder is present, install the service for starting the dispatcher
77 # If not, use the dispatcher directly from the udev rule as in previous versions
79 install-common
: $(PROG
) usb_modeswitch_dispatcher
80 install -D
--mode
=755 usb_modeswitch
$(SBINDIR
)/usb_modeswitch
81 install -D
--mode
=755 usb_modeswitch.sh
$(UDEVDIR
)/usb_modeswitch
82 install -D
--mode
=644 usb_modeswitch.conf
$(ETCDIR
)/usb_modeswitch.conf
83 install -D
--mode
=644 usb_modeswitch
.1 $(MANDIR
)/usb_modeswitch
.1
84 install -D
--mode
=644 usb_modeswitch_dispatcher
.1 $(MANDIR
)/usb_modeswitch_dispatcher
.1
85 install -D
--mode
=755 usb_modeswitch_dispatcher
$(SBINDIR
)/usb_modeswitch_dispatcher
86 install -d
$(DESTDIR
)/var
/lib
/usb_modeswitch
87 test -d
$(UPSDIR
) -a
-e
/sbin
/initctl
&& install --mode
=644 usb-modeswitch-upstart.conf
$(UPSDIR
) ||
test 1
88 test -d
$(SYSDIR
) -a
-e
/usr
/bin
/systemctl
&& install --mode
=644 usb_modeswitch@.service
$(SYSDIR
) ||
test 1
90 install: install-script
92 install-script
: dispatcher-script install-common
94 install-shared
: dispatcher-shared install-common
96 install-static
: dispatcher-static install-common
99 $(RM
) $(SBINDIR
)/usb_modeswitch
100 $(RM
) $(SBINDIR
)/usb_modeswitch_dispatcher
101 $(RM
) $(UDEVDIR
)/usb_modeswitch
102 $(RM
) $(ETCDIR
)/usb_modeswitch.conf
103 $(RM
) $(MANDIR
)/usb_modeswitch
.1
104 $(RM
) -R
$(DESTDIR
)/var
/lib
/usb_modeswitch
105 $(RM
) $(SYSDIR
)/usb_modeswitch@.service