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.

68 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-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
  16. LIBS += $(shell $(PKG_CONFIG) --libs cairo xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
  17. LIBS += -lpam
  18. LIBS += -lev
  19. LIBS += -lm
  20. # OpenBSD lacks PAM, use bsd_auth(3) instead.
  21. ifneq ($(UNAME),OpenBSD)
  22. LIBS += -lpam
  23. endif
  24. FILES:=$(wildcard *.c)
  25. FILES:=$(FILES:.c=.o)
  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. .PHONY: install clean uninstall
  36. all: i3lock
  37. i3lock: ${FILES}
  38. $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
  39. clean:
  40. rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
  41. install: all
  42. $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
  43. $(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/pam.d
  44. $(INSTALL) -m 755 i3lock $(DESTDIR)$(PREFIX)/bin/i3lock
  45. $(INSTALL) -m 644 i3lock.pam $(DESTDIR)$(SYSCONFDIR)/pam.d/i3lock
  46. uninstall:
  47. rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
  48. dist: clean
  49. [ ! -d i3lock-${VERSION} ] || rm -rf i3lock-${VERSION}
  50. [ ! -e i3lock-${VERSION}.tar.bz2 ] || rm i3lock-${VERSION}.tar.bz2
  51. mkdir i3lock-${VERSION}
  52. cp *.c *.h i3lock.1 i3lock.pam Makefile LICENSE README.md CHANGELOG i3lock-${VERSION}
  53. 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
  54. tar cfj i3lock-${VERSION}.tar.bz2 i3lock-${VERSION}
  55. rm -rf i3lock-${VERSION}