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.

67 lines
2.1 KiB

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