]> git.sur5r.net Git - i3/i3lock/blob - Makefile
Move all PAM code behind UES_PAM and enable that by default.
[i3/i3lock] / Makefile
1 TOPDIR=$(shell pwd)
2
3 INSTALL=install
4 PREFIX=/usr
5 SYSCONFDIR=/etc
6 PKG_CONFIG=pkg-config
7
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")
11 endif
12
13 CFLAGS += -std=c99
14 CFLAGS += -pipe
15 CFLAGS += -Wall
16 CPPFLAGS += -D_GNU_SOURCE
17 CPPFLAGS += -DUSE_PAM
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)
20 LIBS += -lpam
21 LIBS += -lev
22 LIBS += -lm
23
24 FILES:=$(wildcard *.c)
25 FILES:=$(FILES:.c=.o)
26
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)'
31 else
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))"
34 endif
35 CPPFLAGS += -DVERSION=\"${I3LOCK_VERSION}\"
36
37 .PHONY: install clean uninstall
38
39 all: i3lock
40
41 i3lock: ${FILES}
42         $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
43
44 clean:
45         rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
46
47 install: all
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
52
53 uninstall:
54         rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
55
56 dist: clean
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}