4 .PHONY: all install uninstall autorandr bash_completion autostart_config pmutils systemd udev
7 @echo "Call \"make install\" to install this program."
8 @echo "Call \"make uninstall\" to remove this program."
10 @echo "The following components were autodetected and will be installed:"
11 @echo " "$(DEFAULT_TARGETS)
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)"
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."
22 @echo 'E.g. "make install TARGETS='autorandr pmutils' PM_UTILS_DIR=/etc/pm/sleep.d".'
24 @echo "The following additional targets are available:"
26 @echo " make deb creates a Debian package"
28 # Rules for autorandr itself
29 DEFAULT_TARGETS=autorandr
32 install -D -m 755 autorandr.py ${DESTDIR}${PREFIX}/bin/autorandr
35 rm -f ${DESTDIR}${PREFIX}/bin/autorandr
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
44 install_bash_completion:
45 install -D -m 644 contrib/bash_completion/autorandr ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
47 uninstall_bash_completion:
48 rm -f ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
50 # Rules for autostart config
51 XDG_AUTOSTART_DIR=/etc/xdg/autostart
52 DEFAULT_TARGETS+=autostart_config
54 install_autostart_config:
55 install -D -m 644 contrib/etc/xdg/autostart/autorandr.desktop ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop
57 uninstall_autostart_config:
58 rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop
61 PM_SLEEPHOOKS_DIR:=$(shell pkg-config --variable=pm_sleephooks pm-utils 2>/dev/null)
62 ifneq (,$(PM_SLEEPHOOKS_DIR))
63 DEFAULT_TARGETS+=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
71 $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined))
72 rm -f ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
75 SYSTEMD_UNIT_DIR:=$(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null)
76 ifneq (,$(SYSTEMD_UNIT_DIR))
77 DEFAULT_TARGETS+=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
85 $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
86 rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr-resume.service
89 UDEV_RULES_DIR:=$(shell pkg-config --variable=udevdir udev 2>/dev/null)/rules.d
90 ifneq (,$(UDEV_RULES_DIR),y)
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
98 udevadm control --reload-rules
100 @echo "Please run this command as root:"
101 @echo " udevadm control --reload-rules"
105 $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined))
106 rm -f ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
109 TARGETS=$(DEFAULT_TARGETS)
110 install: $(patsubst %,install_%,$(TARGETS))
111 uninstall: $(patsubst %,uninstall_%,$(TARGETS))
114 ./contrib/packaging/debian/make_deb.sh