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.

62 lines
2.1 KiB

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