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
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)
24 FILES:=$(wildcard *.c)
27 ifeq ($(wildcard .git),)
28 # not in git repository
29 VERSION := $(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION | cut -d '-' -f 1)
30 I3LOCK_VERSION := '$(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION)'
32 VERSION:=$(shell git describe --tags --abbrev=0)
33 I3LOCK_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
35 CPPFLAGS += -DVERSION=\"${I3LOCK_VERSION}\"
37 .PHONY: install clean uninstall
42 $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
45 rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
48 $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
49 $(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/pam.d
50 $(INSTALL) -m 755 i3lock $(DESTDIR)$(PREFIX)/bin/i3lock
51 $(INSTALL) -m 644 i3lock.pam $(DESTDIR)$(SYSCONFDIR)/pam.d/i3lock
54 rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
57 [ ! -d i3lock-${VERSION} ] || rm -rf i3lock-${VERSION}
58 [ ! -e i3lock-${VERSION}.tar.bz2 ] || rm i3lock-${VERSION}.tar.bz2
59 mkdir i3lock-${VERSION}
60 cp *.c *.h i3lock.1 i3lock.pam Makefile LICENSE README.md CHANGELOG i3lock-${VERSION}
61 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
62 tar cfj i3lock-${VERSION}.tar.bz2 i3lock-${VERSION}
63 rm -rf i3lock-${VERSION}