]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blob - Makefile
Added Makefile target to create a deb archive
[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         @echo
14         @echo "The following additional targets are available:"
15         @echo
16         @echo "    make deb        creates a Debian package"
17
18 # Rules for autorandr itself
19 DEFAULT_TARGETS=autorandr
20
21 install_autorandr:
22         install -D -m 755 autorandr.py ${DESTDIR}${PREFIX}/bin/autorandr
23
24 uninstall_autorandr:
25         rm -f ${DESTDIR}${PREFIX}/bin/autorandr
26
27 # Rules for bash_completion
28 BASH_COMPLETION_DIR=/etc/bash_completion.d
29 HAVE_BASH_COMPLETION=$(shell [ -d /etc/bash_completion.d/ ] && echo "y")
30 ifeq ($(HAVE_BASH_COMPLETION),y)
31 DEFAULT_TARGETS+=bash_completion
32 endif
33
34 install_bash_completion:
35         install -D -m 644 contrib/bash_completion/autorandr ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
36
37 uninstall_bash_completion:
38         rm -f ${DESTDIR}/${BASH_COMPLETION_DIR}/autorandr
39
40 # Rules for pmutils
41 PM_UTILS_DIR=/etc/pm/sleep.d
42 HAVE_PMUTILS=$(shell [ -x /usr/sbin/pm-suspend ] && echo "y")
43 ifeq ($(HAVE_PMUTILS),y)
44 DEFAULT_TARGETS+=pmutils
45 endif
46
47 install_pmutils:
48         install -D -m 755 contrib/pm-utils/40autorandr ${DESTDIR}/${PM_UTILS_DIR}/40autorandr
49
50 uninstall_pmutils:
51         rm -f ${DESTDIR}/${PM_UTILS_DIR}/40autorandr
52
53 # Rules for systemd
54 SYSTEMD_UNIT_DIR=/etc/systemd/system/
55 HAVE_SYSTEMD=$(shell grep -q systemd /proc/1/comm && echo "y")
56 ifeq ($(HAVE_SYSTEMD),y)
57 DEFAULT_TARGETS+=systemd
58 endif
59
60 install_systemd:
61         install -D -m 644 contrib/systemd/autorandr-resume.service ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr-resume.service
62
63 uninstall_systemd:
64         rm -f ${DESTDIR}/${SYSTEMD_UNIT_DIR}/autorandr-resume.service
65
66 # Rules for udev
67 UDEV_RULES_DIR=/etc/udev/rules.d
68 HAVE_UDEV=$(shell [ -d "${UDEV_RULES_DIR}" ] && echo "y")
69 ifeq ($(HAVE_UDEV),y)
70 DEFAULT_TARGETS+=udev
71 endif
72
73 install_udev:
74         install -D -m 644 contrib/udev/40-monitor-hotplug.rules ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
75 ifeq (${USER},root)
76         udevadm control --reload-rules
77 else
78         @echo "Please run this command as root:"
79         @echo "    udevadm control --reload-rules"
80 endif
81
82 uninstall_udev:
83         rm -f ${DESTDIR}/${UDEV_RULES_DIR}/40-monitor-hotplug.rules
84
85
86 TARGETS=$(DEFAULT_TARGETS)
87 install: $(patsubst %,install_%,$(TARGETS))
88 uninstall: $(patsubst %,uninstall_%,$(TARGETS))
89
90 deb:
91         ./contrib/packaging/debian/make_deb.sh