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