9 # Check if pkg-config is installed, we need it for building CFLAGS/LIBS
10 ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null 1>/dev/null || echo 1),1)
11 $(error "$(PKG_CONFIG) was not found")
17 CPPFLAGS += -D_GNU_SOURCE
18 CFLAGS += $(shell $(PKG_CONFIG) --cflags cairo xcb-composite xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
19 LIBS += $(shell $(PKG_CONFIG) --libs cairo xcb-composite xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
23 # OpenBSD lacks PAM, use bsd_auth(3) instead.
24 ifneq ($(UNAME),OpenBSD)
28 FILES:=$(wildcard *.c)
31 ifeq ($(wildcard .git),)
32 # not in git repository
33 VERSION := $(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION | cut -d '-' -f 1)
34 I3LOCK_VERSION := '$(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION)'
36 VERSION:=$(shell git describe --tags --abbrev=0)
37 I3LOCK_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
39 CPPFLAGS += -DVERSION=\"${I3LOCK_VERSION}\"
41 .PHONY: install clean uninstall
46 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
49 rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
52 $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
53 $(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/pam.d
54 $(INSTALL) -m 755 i3lock $(DESTDIR)$(PREFIX)/bin/i3lock
55 $(INSTALL) -m 644 i3lock.pam $(DESTDIR)$(SYSCONFDIR)/pam.d/i3lock
58 rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
61 [ ! -d i3lock-${VERSION} ] || rm -rf i3lock-${VERSION}
62 [ ! -e i3lock-${VERSION}.tar.bz2 ] || rm i3lock-${VERSION}.tar.bz2
63 mkdir i3lock-${VERSION}
64 cp *.c *.h i3lock.1 i3lock.pam Makefile LICENSE README.md CHANGELOG i3lock-${VERSION}
65 sed -e 's/^I3LOCK_VERSION:=\(.*\)/I3LOCK_VERSION:=$(shell /bin/echo '${I3LOCK_VERSION}' | sed 's/\\/\\\\/g')/g;s/^VERSION:=\(.*\)/VERSION:=${VERSION}/g' Makefile > i3lock-${VERSION}/Makefile
66 tar cfj i3lock-${VERSION}.tar.bz2 i3lock-${VERSION}
67 rm -rf i3lock-${VERSION}