8 # Check if pkg-config is installed, we need it for building CFLAGS/LIBS
9 ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null 1>/dev/null || echo 1),1)
10 $(error "$(PKG_CONFIG) was not found")
16 CPPFLAGS += -D_GNU_SOURCE
17 CFLAGS += $(shell $(PKG_CONFIG) --cflags cairo xcb-composite xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
18 LIBS += $(shell $(PKG_CONFIG) --libs cairo xcb-composite xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
23 FILES:=$(wildcard *.c)
26 ifeq ($(wildcard .git),)
27 # not in git repository
28 VERSION := $(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION | cut -d '-' -f 1)
29 I3LOCK_VERSION := '$(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION)'
31 VERSION:=$(shell git describe --tags --abbrev=0)
32 I3LOCK_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
34 CPPFLAGS += -DVERSION=\"${I3LOCK_VERSION}\"
36 .PHONY: install clean uninstall
41 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
44 rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
47 $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
48 $(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/pam.d
49 $(INSTALL) -m 755 i3lock $(DESTDIR)$(PREFIX)/bin/i3lock
50 $(INSTALL) -m 644 i3lock.pam $(DESTDIR)$(SYSCONFDIR)/pam.d/i3lock
53 rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
56 [ ! -d i3lock-${VERSION} ] || rm -rf i3lock-${VERSION}
57 [ ! -e i3lock-${VERSION}.tar.bz2 ] || rm i3lock-${VERSION}.tar.bz2
58 mkdir i3lock-${VERSION}
59 cp *.c *.h i3lock.1 i3lock.pam Makefile LICENSE README.md CHANGELOG i3lock-${VERSION}
60 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
61 tar cfj i3lock-${VERSION}.tar.bz2 i3lock-${VERSION}
62 rm -rf i3lock-${VERSION}