]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - Makefile
The 40autorandr script needs to be executable for udev
[deb_pkgs/autorandr.git] / Makefile
1 DESTDIR=/
2 PREFIX=/usr/
3
4 .PHONY: all install uninstall autorandr bash_completion pmutils systemd udev
5
6 all:
7         @echo "Call \"make install\" to install this program."
8         @echo "Call \"make uninstall\" to remove this program."
9         @echo
10         @echo "The following components were autodetected and will be installed:"
11         @echo " "$(DEFAULT_TARGETS)
12         @echo "You can use the TARGETS variable to override, e.g. \"make install TAGETS='autorandr pmutils'\"."
13
14 # Rules for autorandr itself
15 DEFAULT_TARGETS=autorandr
16
17 install_autorandr:
18         install -D -m 755 autorandr.py ${DESTDIR}${PREFIX}/bin/autorandr
19
20 uninstall_autorandr:
21         rm -f ${DESTDIR}${PREFIX}/bin/autorandr
22
23 # Rules for bash_completion
24 HAVE_BASH_COMPLETION=$(shell [ -d /etc/bash_completion.d/ ] && echo "y")
25 ifeq ($(HAVE_BASH_COMPLETION),y)
26 DEFAULT_TARGETS+=bash_completion
27 endif
28
29 install_bash_completion:
30         install -D -m 644 contrib/bash_completion/autorandr ${DESTDIR}/etc/bash_completion.d/autorandr
31
32 uninstall_bash_completion:
33         rm -f ${DESTDIR}/etc/bash_completion.d/autorandr
34
35 # Rules for pmutils
36 HAVE_PMUTILS=$(shell [ -x /usr/sbin/pm-suspend ] && echo "y")
37 ifeq ($(HAVE_PMUTILS),y)
38 DEFAULT_TARGETS+=pmutils
39 endif
40
41 install_pmutils:
42         install -D -m 755 contrib/pm-utils/40autorandr ${DESTDIR}/etc/pm/sleep.d/40autorandr
43
44 uninstall_pmutils:
45         rm -f ${DESTDIR}/etc/pm/sleep.d/40autorandr
46
47 # Rules for systemd
48 HAVE_SYSTEMD=$(shell grep -q systemd $$(readlink -f $$(awk '{print $$1}' /proc/1/cmdline)) && echo "y")
49 ifeq ($(HAVE_SYSTEMD),y)
50 DEFAULT_TARGETS+=systemd
51 endif
52
53 install_systemd: install_pmutils
54         install -D -m 644 contrib/systemd/autorandr-resume.service ${DESTDIR}/etc/systemd/system/autorandr-resume.service
55
56 uninstall_systemd: uninstall_pmutils
57         rm -f ${DESTDIR}/etc/systemd/system/autorandr-resume.service
58
59 # Rules for udev
60 HAVE_UDEV=$(shell [ -d /etc/udev/rules.d/ ] && echo "y")
61 ifeq ($(HAVE_UDEV),y)
62 DEFAULT_TARGETS+=udev
63 endif
64
65 install_udev:
66         install -D -m 644 contrib/udev/40-monitor-hotplug.rules ${DESTDIR}/etc/udev/rules.d/40-monitor-hotplug.rules
67 ifeq (${USER},root)
68         udevadm control --reload-rules
69 else
70         @echo "Please run this command as root:"
71         @echo "    udevadm control --reload-rules"
72 endif
73
74 uninstall_udev:
75         rm -f ${DESTDIR}/etc/udev/rules.d/40-monitor-hotplug.rules
76
77
78 TARGETS=$(DEFAULT_TARGETS)
79 install: $(patsubst %,install_%,$(TARGETS))
80 uninstall: $(patsubst %,uninstall_%,$(TARGETS))