]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/blobdiff - Makefile
Prefer X11 launcher (like srandr) over udev/systemd setup
[deb_pkgs/autorandr.git] / Makefile
index d8b27c6e5eac1ce9627e2cb224c3c2aa6473180e..a4a70e4a1958315e1240995822edb46e8b2e9b28 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
 DESTDIR=/
 PREFIX=/usr/
 RPM_SPEC=contrib/packaging/rpm/autorandr.spec
+CFLAGS=-O2
 
 .PHONY: all install uninstall autorandr bash_completion autostart_config pmutils systemd udev
 
@@ -23,10 +24,9 @@ all:
        @echo
        @echo 'E.g. "make install TARGETS='autorandr pmutils' PM_UTILS_DIR=/etc/pm/sleep.d".'
        @echo
-       @echo "An additional TARGETS variable \"launcher\" is available. This"
-       @echo "installs a launcher called \"autorandr_launcher\". The launcher"
-       @echo "is able to be run by the user and calls autorandr automatically"
-       @echo "without using udev rules."
+       @echo "By default, if xcb libraries are available, autorandr prefers to"
+       @echo "install a launcher that listens for X11 randr events and runs"
+       @echo "autorandr whenever something changes, over udev/systemd rules."
        @echo
        @echo "The following additional targets are available:"
        @echo
@@ -139,12 +139,24 @@ uninstall_manpage:
        rm -f ${DESTDIR}/${MANDIR}/autorandr.1
 
 # Rules for launcher
+LAUNCHER_FLAGS=$(shell pkg-config --libs --cflags pkg-config xcb xcb-randr 2>/dev/null)
+ifneq (,$(LAUNCHER_FLAGS))
+DEFAULT_TARGETS+=launcher
+DEFAULT_TARGETS:=$(filter-out systemd udev,$(DEFAULT_TARGETS))
+endif
+
 install_launcher:
-       gcc -Wall contrib/autorandr_launcher/autorandr_launcher.c -o contrib/autorandr_launcher/autorandr_launcher -lxcb -lxcb-randr
-       install -D -m 755 contrib/autorandr_launcher/autorandr_launcher ${DESTDIR}${PREFIX}/bin/autorandr_launcher
+       gcc -Wall $(CFLAGS) contrib/autorandr_launcher/autorandr_launcher.c -o contrib/autorandr_launcher/autorandr-launcher $(LAUNCHER_FLAGS)
+       install -D -m 755 contrib/autorandr_launcher/autorandr_launcher ${DESTDIR}${PREFIX}/bin/autorandr-launcher
+
+       install -D -m 644 contrib/etc/xdg/autostart/autorandr-launcher.desktop ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-launcher.desktop
+ifneq ($(PREFIX),/usr/)
+       sed -i -re 's#/usr/bin/autorandr-launcher#$(subst #,\#,${PREFIX})/bin/autorandr-launcher#g' ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-launcher.desktop
+endif
 
 uninstall_launcher:
-       rm -f ${DESTDIR}${PREFIX}/bin/autorandr_launcher
+       rm -f ${DESTDIR}${PREFIX}/bin/autorandr-launcher
+       rm -f ${DESTDIR}/${XDG_AUTOSTART_DIR}/autorandr-launcher.desktop
 
 TARGETS=$(DEFAULT_TARGETS)
 install: $(patsubst %,install_%,$(TARGETS))