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.

63 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. CPPFLAGS += -DUSE_PAM
  15. CFLAGS += $(shell $(PKG_CONFIG) --cflags cairo xcb-composite xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
  16. LIBS += $(shell $(PKG_CONFIG) --libs cairo xcb-composite xcb-xinerama xcb-atom xcb-image xcb-xkb xkbcommon xkbcommon-x11)
  17. LIBS += -lpam
  18. LIBS += -lev
  19. LIBS += -lm
  20. FILES:=$(wildcard *.c)
  21. FILES:=$(FILES:.c=.o)
  22. ifeq ($(wildcard .git),)
  23. # not in git repository
  24. VERSION := $(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION | cut -d '-' -f 1)
  25. I3LOCK_VERSION := '$(shell [ -f $(TOPDIR)/I3LOCK_VERSION ] && cat $(TOPDIR)/I3LOCK_VERSION)'
  26. else
  27. VERSION:=$(shell git describe --tags --abbrev=0)
  28. I3LOCK_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
  29. endif
  30. CPPFLAGS += -DVERSION=\"${I3LOCK_VERSION}\"
  31. .PHONY: install clean uninstall
  32. all: i3lock
  33. i3lock: ${FILES}
  34. $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
  35. clean:
  36. rm -f i3lock ${FILES} i3lock-${VERSION}.tar.gz
  37. install: all
  38. $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
  39. $(INSTALL) -d $(DESTDIR)$(SYSCONFDIR)/pam.d
  40. $(INSTALL) -m 755 i3lock $(DESTDIR)$(PREFIX)/bin/i3lock
  41. $(INSTALL) -m 644 i3lock.pam $(DESTDIR)$(SYSCONFDIR)/pam.d/i3lock
  42. uninstall:
  43. rm -f $(DESTDIR)$(PREFIX)/bin/i3lock
  44. dist: clean
  45. [ ! -d i3lock-${VERSION} ] || rm -rf i3lock-${VERSION}
  46. [ ! -e i3lock-${VERSION}.tar.bz2 ] || rm i3lock-${VERSION}.tar.bz2
  47. mkdir i3lock-${VERSION}
  48. cp *.c *.h i3lock.1 i3lock.pam Makefile LICENSE README.md CHANGELOG i3lock-${VERSION}
  49. 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
  50. tar cfj i3lock-${VERSION}.tar.bz2 i3lock-${VERSION}
  51. rm -rf i3lock-${VERSION}