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:=$(shell pkg-config --variable=completionsdir bash-completion 2>/dev/null)
39 ifneq (,$(BASH_COMPLETION_DIR))
40 DEFAULT_TARGETS+=bash_completion
43 install_bash_completion:
44 install -D -m 644 contrib/bash_completion/autorandr ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
46 uninstall_bash_completion:
47 rm -f ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
49 # Rules for autostart config
50 XDG_AUTOSTART_DIR=/etc/xdg/autostart
51 DEFAULT_TARGETS+=autostart_config
53 install_autostart_config:
54 install -D -m 644 contrib/etc/xdg/autostart/autorandr.desktop ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop
55 ifneq ($(PREFIX),/usr/)
56 sed -i -re 's#/usr/bin/autorandr#$(subst #,\#,${PREFIX})/bin/autorandr#g' ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop
59 uninstall_autostart_config:
60 rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr.desktop
63 SYSTEMD_UNIT_DIR:=$(shell pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null)
64 ifneq (,$(SYSTEMD_UNIT_DIR))
65 DEFAULT_TARGETS+=systemd
69 $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
70 install -D -m 644 contrib/systemd/autorandr.service ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service
71 ifneq ($(PREFIX),/usr/)
72 sed -i -re 's#/usr/bin/autorandr#$(subst #,\#,${PREFIX})/bin/autorandr#g' ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service
75 @echo "To activate the systemd unit, run this command as root:"
76 @echo " systemctl daemon-reload"
77 @echo " systemctl enable autorandr.service"
81 $(if $(SYSTEMD_UNIT_DIR),,$(error SYSTEMD_UNIT_DIR is not defined))
82 rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr.service
85 PM_SLEEPHOOKS_DIR:=$(shell pkg-config --variable=pm_sleephooks pm-utils 2>/dev/null)
86 ifneq (,$(PM_SLEEPHOOKS_DIR))
87 ifeq (,$(SYSTEMD_UNIT_DIR))
88 DEFAULT_TARGETS+=pmutils
93 $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined))
94 install -D -m 755 contrib/pm-utils/40autorandr ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
95 ifneq ($(PREFIX),/usr/)
96 sed -i -re 's#/usr/bin/autorandr#$(subst #,\#,${PREFIX})/bin/autorandr#g' ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
100 $(if $(PM_SLEEPHOOKS_DIR),,$(error PM_SLEEPHOOKS_DIR is not defined))
101 rm -f ${DESTDIR}/${PM_SLEEPHOOKS_DIR}/40autorandr
105 UDEV_RULES_DIR:=$(shell pkg-config --variable=udevdir udev 2>/dev/null)/rules.d
106 ifneq (,$(UDEV_RULES_DIR),y)
107 DEFAULT_TARGETS+=udev
111 $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined))
112 mkdir -p ${DESTDIR}/${UDEV_RULES_DIR}/
113 echo 'ACTION=="change", SUBSYSTEM=="drm", RUN+="$(if $(findstring systemd, $(TARGETS)),/bin/systemctl start --no-block autorandr.service,${PREFIX}/bin/autorandr --batch --change --default default)"' > ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
115 @echo "To activate the udev rules, run this command as root:"
116 @echo " udevadm control --reload-rules"
120 $(if $(UDEV_RULES_DIR),,$(error UDEV_RULES_DIR is not defined))
121 rm -f ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
124 TARGETS=$(DEFAULT_TARGETS)
125 install: $(patsubst %,install_%,$(TARGETS))
126 uninstall: $(patsubst %,uninstall_%,$(TARGETS))
129 ./contrib/packaging/debian/make_deb.sh