Makefile 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .POSIX:
  2. include config.mk
  3. REQ = util
  4. COM = \
  5. components/battery \
  6. components/cpu \
  7. components/datetime \
  8. components/disk \
  9. components/entropy \
  10. components/hostname \
  11. components/ip \
  12. components/kernel_release \
  13. components/keyboard_indicators \
  14. components/keymap \
  15. components/load_avg \
  16. components/netspeeds \
  17. components/num_files \
  18. components/ram \
  19. components/run_command \
  20. components/separator \
  21. components/swap \
  22. components/temperature \
  23. components/uptime \
  24. components/user \
  25. components/volume \
  26. components/wifi
  27. BUILD_DIR = build
  28. OBJ_DIR = $(BUILD_DIR)/obj
  29. SRC_DIR = src
  30. COM_OBJ = $(COM:%=$(OBJ_DIR)/%.o)
  31. REQ_OBJ = $(REQ:%=$(OBJ_DIR)/%.o)
  32. SLSTATUS_OBJ = $(OBJ_DIR)/archy_slstatus.o
  33. all: $(BUILD_DIR)/archy-slstatus
  34. $(COM_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c $(REQ_OBJ) config.mk $(REQ:%=$(SRC_DIR)/%.h)
  35. @mkdir -p $(@D)
  36. $(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<
  37. $(REQ_OBJ): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.c $(SRC_DIR)/%.h
  38. @mkdir -p $(@D)
  39. $(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<
  40. $(SLSTATUS_OBJ): $(SRC_DIR)/archy_slstatus.c $(SRC_DIR)/archy_slstatus.h $(SRC_DIR)/arg.h config.mk $(REQ_OBJ) $(REQ:%=$(SRC_DIR)/%.h)
  41. @mkdir -p $(@D)
  42. $(CC) -o $@ -c $(CPPFLAGS) $(CFLAGS) $<
  43. $(BUILD_DIR)/archy-slstatus: $(SLSTATUS_OBJ) $(COM_OBJ) $(REQ_OBJ)
  44. $(CC) -o $@ $(LDFLAGS) $(SLSTATUS_OBJ) $(COM_OBJ) $(REQ_OBJ) $(LDLIBS)
  45. clean:
  46. rm -rf $(BUILD_DIR)
  47. dist: build/archy-slstatus
  48. mkdir -p "dist/archy-slstatus_$(VERSION)"
  49. cp -R LICENSE README.md $(BUILD_DIR)/archy-slstatus archy-slstatus.1 "dist/archy-slstatus_$(VERSION)"
  50. tar -cf - "dist/archy-slstatus_$(VERSION)" | gzip -c > "archy-slstatus_$(VERSION).tar.gz"
  51. rm -rf "dist/archy-slstatus_$(VERSION)"
  52. mv "archy-slstatus_$(VERSION).tar.gz" "dist/archy-slstatus_$(VERSION).tar.gz"
  53. echo "The tarball is ready."
  54. printf "Tarball size: %s\n" $$(du -h dist/archy-slstatus_${VERSION}.tar.gz | cut -f1)
  55. printf "Tarball hash: %s\n" $$(sha256sum dist/archy-slstatus_${VERSION}.tar.gz)
  56. install: all
  57. mkdir -p "$(DESTDIR)$(PREFIX)/bin"
  58. cp -f $(BUILD_DIR)/archy-slstatus "$(DESTDIR)$(PREFIX)/bin"
  59. chmod 755 "$(DESTDIR)$(PREFIX)/bin/archy-slstatus"
  60. mkdir -p "$(DESTDIR)$(MANPREFIX)/man1"
  61. cp -f archy-slstatus.1 "$(DESTDIR)$(MANPREFIX)/man1"
  62. chmod 644 "$(DESTDIR)$(MANPREFIX)/man1/archy-slstatus.1"
  63. uninstall:
  64. rm -f "$(DESTDIR)$(PREFIX)/bin/archy-slstatus"
  65. rm -f "$(DESTDIR)$(MANPREFIX)/man1/archy-slstatus.1"
  66. .PHONY: all clean dist install uninstall