]> git.sur5r.net Git - i3/i3lock/blob - Makefile
Remove last traces of DPMS
[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 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)
19 LIBS += -lpam
20 LIBS += -lev
21 LIBS += -lm
22
23 FILES:=$(wildcard *.c)
24 FILES:=$(FILES:.c=.o)
25
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)'
30 else
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))"
33 endif
34 CPPFLAGS += -DVERSION=\"${I3LOCK_VERSION}\"
35
36 .PHONY: install clean uninstall
37
38 all: i3lock
39
40 i3lock: ${FILES}
41         $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
42
43 clean:
44         rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
45
46 install: all
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
51
52 uninstall:
53         rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
54
55 dist: clean
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}