  	}
  }
  
-@@ -498,9 +506,9 @@ return 1
- 
- proc {ParseGlobalConfig} {} {
+@@ -522,12 +530,12 @@ return 1
+ 
+ proc {ParseGlobalConfig} {path} {
  
 -global flags
 +global flags setup
  set configFile ""
--set places [list /etc/usb_modeswitch.conf /etc/sysconfig/usb_modeswitch /etc/default/usb_modeswitch]
-+set places [list $setup(etcdir)/usb_modeswitch.conf $setup(etcdir)/sysconfig/usb_modeswitch $setup(etcdir)/default/usb_modeswitch]
+ if [string length $path] {
+ 	set places [list $path]
+ } else {
+-	set places [list /etc/usb_modeswitch.conf /etc/sysconfig/usb_modeswitch /etc/default/usb_modeswitch]
++	set places [list $setup(etcdir)/usb_modeswitch.conf $setup(etcdir)/sysconfig/usb_modeswitch $setup(etcdir)/default/usb_modeswitch]
+ }
  foreach cfg $places {
  	if [file exists $cfg] {
- 		set configFile $cfg
-@@ -897,10 +905,12 @@ proc {SysLog} {msg} {
+@@ -923,10 +931,12 @@ proc {SysLog} {msg} {
  
  global flags
  if {![info exists flags(logger)]} {

 			Log "Error when trying to find MBIM configuration, switch to legacy modem mode"
 		} else {
 			set cfgno [string trim $cfgno]
@@ -297,7 +305,7 @@ if {$report == ""} {
 	# Now we are actually switching
 	if $flags(logging) {
 		Log "Command line:\nusb_modeswitch -W -D $configParam $busParam $devParam -v $usb(idVendor) -p $usb(idProduct) -f \$flags(config)"

+configure: configure-dispatcher configure-script \
+	configure-systemd configure-upstart
+
+dispatcher-script: configure-dispatcher usb_modeswitch_dispatcher.tcl
 	DISPATCH=dispatcher-script
 	cp -f usb_modeswitch_dispatcher.tcl usb_modeswitch_dispatcher
 
@@ -53,16 +78,28 @@ distclean: clean
 # If the systemd folder is present, install the service for starting the dispatcher
 # If not, use the dispatcher directly from the udev rule as in previous versions
 
-install-common: $(PROG) $(DISPATCH)
-	install -D --mode=755 usb_modeswitch $(SBINDIR)/usb_modeswitch
-	install -D --mode=755 usb_modeswitch.sh $(UDEVDIR)/usb_modeswitch
-	install -D --mode=644 usb_modeswitch.conf $(ETCDIR)/usb_modeswitch.conf
-	install -D --mode=644 usb_modeswitch.1 $(MANDIR)/usb_modeswitch.1
-	install -D --mode=644 usb_modeswitch_dispatcher.1 $(MANDIR)/usb_modeswitch_dispatcher.1
-	install -D --mode=755 usb_modeswitch_dispatcher $(SBINDIR)/usb_modeswitch_dispatcher
+install-common: $(PROG) configure $(DISPATCH)
+	install -D --mode=755 usb_modeswitch $(DESTDIR)$(SBINDIR)/usb_modeswitch
+	install -D --mode=755 usb_modeswitch.sh $(DESTDIR)$(UDEVDIR)/usb_modeswitch
+	install -D --mode=644 usb_modeswitch.conf $(DESTDIR)$(ETCDIR)/usb_modeswitch.conf
