Makefile 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #- aslstatus - async suckless status monitor -#
  2. include config.mk
  3. ifeq (${COMPONENTS},)
  4. COMPONENTS := $(wildcard components/*.c)
  5. COMPONENTS += $(wildcard lib/*.c)
  6. A_ALSA_C := components/volume/alsa.c
  7. A_PULSE_C := components/volume/pulse.c
  8. A_DEF_C := components/volume/default.c
  9. endif # COMPONENTS
  10. OBJ = ${COMPONENTS:.c=.o}
  11. X ?= 1
  12. XKB ?= 1
  13. AUDIO ?= ALSA
  14. # components that needs running X server
  15. NEED_X_SERVER_COM := keymap
  16. NEED_X_SERVER_DEF := -DNEED_X_SERVER=1
  17. NEED_X_SERVER = $(if \
  18. $(strip \
  19. $(foreach _,\
  20. ${NEED_X_SERVER_COM},\
  21. $(filter %/${_}.c,${COMPONENTS})\
  22. )),\
  23. ${NEED_X_SERVER_DEF},)
  24. SMART_CONFIG ?= 1
  25. ifeq (${X},1)
  26. LDLIBS += ${LDXCB}
  27. CPPFLAGS += -DUSE_X=1
  28. ifeq (${XKB},1)
  29. LDLIBS += ${LDXCB_XKB}
  30. CPPFLAGS += -DUSE_XKB=1
  31. else
  32. CPPFLAGS += -DUSE_XKB=0
  33. endif # XKB
  34. else
  35. CPPFLAGS += -DUSE_X=0
  36. CPPFLAGS += -DUSE_XKB=0
  37. endif # X
  38. .PHONY: all
  39. ifeq (${SMART_CONFIG},1)
  40. all: smart-conf
  41. include smart-config.mk
  42. else
  43. all: aslstatus
  44. endif
  45. ifeq (${AUDIO},ALSA)
  46. LDLIBS += ${LDALSA}
  47. CPPFLAGS += -DUSE_ALSA
  48. COMPONENTS += ${A_ALSA_C}
  49. endif # ALSA
  50. ifeq (${AUDIO},PULSE)
  51. LDLIBS += ${LDPULSE}
  52. CPPFLAGS += -DUSE_PULSE
  53. COMPONENTS += ${A_PULSE_C}
  54. endif # PULSE
  55. ifneq (${AUDIO},ALSA)
  56. ifneq (${AUDIO},PULSE)
  57. COMPONENTS += ${A_DEF_C}
  58. endif
  59. endif
  60. ifneq (,$(filter %tcc,${CC})) # if compiler is tcc
  61. # libraries and flags first, then files to link
  62. LINK_FLAGS = ${LDFLAGS} ${LDLIBS} ${CFLAGS} ${1}
  63. else
  64. # vice versa
  65. LINK_FLAGS = ${1} ${LDFLAGS} ${LDLIBS} ${CFLAGS}
  66. endif
  67. include deps.mk
  68. include build.mk
  69. aslstatus.o: CPPFLAGS += $(NEED_X_SERVER)
  70. config.o: config.h
  71. arch="$$(uname -m)" && $(LD) -m "elf_$${arch}" -r -b binary -o $@ $<
  72. %.o: %.c
  73. $(CC) -o $@ -c $< ${CFLAGS} ${WARNINGS} ${CPPFLAGS}
  74. aslstatus: aslstatus.o config.o ${OBJ}
  75. $(CC) -o $@ $(call LINK_FLAGS,$^)
  76. man/aslstatus.1: man/aslstatus.1.md
  77. pandoc --standalone --from=markdown $< --to=man -o $@
  78. .PHONY: man
  79. man: man/aslstatus.1
  80. .PHONY: install
  81. install: all
  82. mkdir -p "${DESTDIR}${PREFIX}/bin"
  83. cp -f aslstatus "${DESTDIR}${PREFIX}/bin"
  84. chmod 755 "${DESTDIR}${PREFIX}/bin/aslstatus"
  85. mkdir -p "${DESTDIR}${MANPREFIX}/man1"
  86. cp -f man/aslstatus.1 "${DESTDIR}${MANPREFIX}/man1"
  87. chmod 644 "${DESTDIR}${MANPREFIX}/man1/aslstatus.1"
  88. .PHONY: clean
  89. ifeq (${SMART_CONFIG},1)
  90. clean: smart-config-clean
  91. endif
  92. clean:
  93. rm -f aslstatus aslstatus.o config.o \
  94. $(wildcard lib/*.o components/*.o components/*/*.o)
  95. .PHONY: uninstall
  96. uninstall:
  97. rm -f "${DESTDIR}${PREFIX}/bin/aslstatus"
  98. rm -f "${DESTDIR}${MANPREFIX}/man1/aslstatus.1"