You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.8 KiB

  1. INSTALL=install
  2. PREFIX=/usr
  3. SYSCONFDIR=/etc
  4. # Check if pkg-config is installed, we need it for building CFLAGS/LIBS
  5. ifeq ($(shell which pkg-config 2>/dev/null 1>/dev/null || echo 1),1)
  6. $(error "pkg-config was not found")
  7. endif
  8. CFLAGS += -std=c99
  9. CFLAGS += -pipe
  10. CFLAGS += -Wall
  11. CPPFLAGS += -D_GNU_SOURCE
  12. ifndef NOLIBCAIRO
  13. CFLAGS += $(shell pkg-config --cflags cairo xcb-keysyms xcb-dpms xcb-xinerama)
  14. LIBS += $(shell pkg-config --libs cairo xcb-keysyms xcb-dpms xcb-xinerama xcb-image)
  15. else
  16. CPPFLAGS += -DNOLIBCAIRO
  17. CFLAGS += $(shell pkg-config --cflags xcb-keysyms xcb-dpms xcb-xinerama)
  18. LIBS += $(shell pkg-config --libs xcb-keysyms xcb-dpms xcb-image xcb-xinerama)
  19. endif
  20. LIBS += -lpam
  21. LIBS += -lev
  22. FILES:=$(wildcard *.c)
  23. FILES:=$(FILES:.c=.o)
  24. VERSION:=$(shell git describe --tags --abbrev=0)
  25. GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
  26. CPPFLAGS += -DVERSION=\"${GIT_VERSION}\"
  27. .PHONY: install clean uninstall
  28. all: i3lock
  29. i3lock: ${FILES}
  30. $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
  31. clean:
  32. rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
  33. install: all
  34. $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
  35. $(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/pam.d
  36. $(INSTALL) -m 755 i3lock $(DESTDIR)$(PREFIX)/bin/i3lock
  37. $(INSTALL) -m 644 i3lock.pam $(DESTDIR)$(SYSCONFDIR)/pam.d/i3lock
  38. uninstall:
  39. rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
  40. dist: clean
  41. [ ! -d i3lock-${VERSION} ] || rm -rf i3lock-${VERSION}
  42. [ ! -e i3lock-${VERSION}.tar.bz2 ] || rm i3lock-${VERSION}.tar.bz2
  43. mkdir i3lock-${VERSION}
  44. cp *.c *.h i3lock.1 i3lock.pam Makefile LICENSE README i3lock-${VERSION}
  45. sed -e 's/^GIT_VERSION:=\(.*\)/GIT_VERSION:=$(shell /bin/echo '${GIT_VERSION}' | sed 's/\\/\\\\/g')/g;s/^VERSION:=\(.*\)/VERSION:=${VERSION}/g' Makefile > i3lock-${VERSION}/Makefile
  46. tar cfj i3lock-${VERSION}.tar.bz2 i3lock-${VERSION}
  47. rm -rf i3lock-${VERSION}