1234567891011121314151617181920212223242526272829303132333435363738
  1. ifeq ($(PREFIX),)
  2. PREFIX := /usr
  3. endif
  4. BINDIR=$(DESTDIR)$(PREFIX)/bin
  5. MANDIR=$(DESTDIR)$(PREFIX)/share/man/man1
  6. CC=gcc
  7. CFLAGS=-std=c89 -O2 -pedantic -Wall -I"./include" -D_XOPEN_SOURCE=500
  8. MANFLAGS=-h -h -v -V -N
  9. HELP2MAN_VERSION := $(shell help2man --version 2>/dev/null)
  10. light: src/helpers.c src/light.c src/main.c
  11. $(CC) $(CFLAGS) -g -o $@ $^
  12. man: light
  13. ifndef HELP2MAN_VERSION
  14. $(error "help2man is not installed")
  15. endif
  16. help2man $(MANFLAGS) ./light | gzip - > light.1.gz
  17. install: light man
  18. mkdir -p $(BINDIR)
  19. cp -f ./light $(BINDIR)/light
  20. chown root $(BINDIR)/light
  21. chmod 4755 $(BINDIR)/light
  22. mkdir -p $(MANDIR)
  23. mv light.1.gz $(MANDIR)
  24. uninstall:
  25. rm $(BINDIR)/light
  26. rm -rf /etc/light
  27. rm $(MANDIR)/light.1.gz
  28. clean:
  29. rm -vfr *~ light light.1.gz
  30. .PHONY: man install uninstall clean