]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - Makefile
Makefile: fix install path for udev rules
[deb_pkgs/autorandr.git] / Makefile
1 DESTDIR=/
2 PREFIX=/usr/
3
4 .PHONY: all install uninstall autorandr bash_completion autostart_config 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
13         @echo "The following locations have been detected (from pkg-config):"
14         @echo " - SYSTEMD_UNIT_DIR: $(SYSTEMD_UNIT_DIR)"
15         @echo " - UDEV_RULES_DIR: $(UDEV_RULES_DIR)"
16         @echo " - PM_SLEEPHOOKS_DIR: $(PM_SLEEPHOOKS_DIR)"
17         @echo
18         @echo "You can use the TARGETS variable to override this, but need to set"
19         @echo "the SYSTEMD_UNIT_DIR, PM_SLEEPHOOKS_DIR and UDEV_RULES_DIR variables"
20         @echo "in case they were not detected correctly."
21         @echo
22         @echo 'E.g. "make install TARGETS='autorandr pmutils' PM_UTILS_DIR=/etc/pm/sleep.d".'
23         @echo
24         @echo "The following additional targets are available:"
25         @echo
26         @echo "    make deb        creates a Debian package"
27
28 # Rules for autorandr itself
29 DEFAULT_TARGETS=autorandr
30
31 install_autorandr:
32         install -D -m 755 autorandr.py ${DESTDIR}${PREFIX}/bin/autorandr
33
34 uninstall_autorandr:
35         rm -f ${DESTDIR}${PREFIX}/bin/autorandr
36
37 # Rules for bash_completion
38 BASH_COMPLETION_DIR=/etc/bash_completion.d
39 HAVE_BASH_COMPLETION=$(shell [ -d /etc/bash_completion.d/ ] && echo "y")
40 ifeq ($(HAVE_BASH_COMPLETION),y)
41 DEFAULT_TARGETS+=bash_completion
42 endif
43
44 install_bash_completion:
45         install -D -m 644 contrib/bash_completion/autorandr ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
46
47 uninstall_bash_completion:
48         rm -f ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
49
50 # Rules for autostart config
51 XDG_AUTOSTART_DIR=/etc/xdg/autostart
52 DEFAULT_TARGETS+=autostart_config
53
54 install_autostart_config:
55         install -D -m 644 contrib/etc/xdg/autostart/autorandr.desktop ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop
56
57 uninstall_autostart_config:
58         rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop
59
60 # Rules for pmutils
61 PM_SLEEPHOOKS_DIR:=$(shell pkg-config --variable=pm_sleephooks pm-utils 2>/dev/null)
62 ifneq (,$(PM_SLEEPHOOKS_DIR))
63 DEFAULT_TARGETS+=pmutils
64 endif
65
66 install_pmutils:
67         $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined))
68         install -D -m 755 contrib/pm-utils/40autorandr ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
69
70 uninstall_pmutils:
71         $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined))
72         rm -f ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
73
74 # Rules for systemd
75 SYSTEMD_UNIT_DIR:=$(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null)
76 ifneq (,$(SYSTEMD_UNIT_DIR))
77 DEFAULT_TARGETS+=systemd
78 endif
79
80 install_systemd:
81         $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
82         install -D -m 644 contrib/systemd/autorandr-resume.service ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr-resume.service
83
84 uninstall_systemd:
85         $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
86         rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr-resume.service
87
88 # Rules for udev
89 UDEV_RULES_DIR:=$(shell pkg-config --variable=udevdir udev 2>/dev/null)/rules.d
90 ifneq (,$(UDEV_RULES_DIR),y)
91 DEFAULT_TARGETS+=udev
92 endif
93
94 install_udev:
95         $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined))
96         install -D -m 644 contrib/udev/40-monitor-hotplug.rules ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
97 ifeq (${USER},root)
98         udevadm control --reload-rules
99 else
100         @echo "Please run this command as root:"
101         @echo "    udevadm control --reload-rules"
102 endif
103
104 uninstall_udev:
105         $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined))
106         rm -f ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
107
108
109 TARGETS=$(DEFAULT_TARGETS)
110 install: $(patsubst %,install_%,$(TARGETS))
111 uninstall: $(patsubst %,uninstall_%,$(TARGETS))
112
113 deb:
114         ./contrib/packaging/debian/make_deb.sh