]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - Makefile
Prefer systemd sleep.target over pmutils
[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 systemd
61 SYSTEMD_UNIT_DIR:=$(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null)
62 ifneq (,$(SYSTEMD_UNIT_DIR))
63 DEFAULT_TARGETS+=systemd
64 endif
65
66 install_systemd:
67         $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
68         install -D -m 644 contrib/systemd/autorandr.service ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service
69
70 uninstall_systemd:
71         $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
72         rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service
73
74 # Rules for pmutils
75 PM_SLEEPHOOKS_DIR:=$(shell pkg-config --variable=pm_sleephooks pm-utils 2>/dev/null)
76 ifneq (,$(PM_SLEEPHOOKS_DIR))
77 ifeq (,$(SYSTEMD_UNIT_DIR))
78 DEFAULT_TARGETS+=pmutils
79 endif
80 endif
81
82 install_pmutils:
83         $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined))
84         install -D -m 755 contrib/pm-utils/40autorandr ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
85
86 uninstall_pmutils:
87         $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined))
88         rm -f ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
89
90
91 # Rules for udev
92 UDEV_RULES_DIR:=$(shell pkg-config --variable=udevdir udev 2>/dev/null)/rules.d
93 ifneq (,$(UDEV_RULES_DIR),y)
94 DEFAULT_TARGETS+=udev
95 endif
96
97 install_udev:
98         $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined))
99         install -D -m 644 contrib/udev/40-monitor-hotplug.rules ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
100 ifeq (${USER},root)
101         udevadm control --reload-rules
102 else
103         @echo "Please run this command as root:"
104         @echo "    udevadm control --reload-rules"
105 endif
106
107 uninstall_udev:
108         $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined))
109         rm -f ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
110
111
112 TARGETS=$(DEFAULT_TARGETS)
113 install: $(patsubst %,install_%,$(TARGETS))
114 uninstall: $(patsubst %,uninstall_%,$(TARGETS))
115
116 deb:
117         ./contrib/packaging/debian/make_deb.sh