summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ce85140e51b8c80e3895c874f86e203bd824082a (plain) (blame)
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
CFLAGS = -I src -g $(shell pkg-config --cflags glib-2.0 dbus-1)
CFLAGS += -I lib/liblist/include -I lib/libgrapheme/
CFLAGS += -Wunused-variable -Wmissing-prototypes
LDLIBS = -lcurses $(shell pkg-config --libs glib-2.0 dbus-1)
DEPFLAGS = -MT $@ -MMD -MP -MF build/$*.d

ifeq "$(PROF)" "YES"
	CFLAGS += -pg
endif

BACKEND ?= mplay

ifeq "$(BACKEND)" "mplay"
	CFLAGS += -I lib/mplay
endif

ifeq "$(BACKEND)" "mpd"
	LDLIBS += -lmpdclient
endif

SRCS = $(filter-out src/player_%.c, $(wildcard src/*.c))
OBJS = $(SRCS:src/%.c=build/%.o) build/player_$(BACKEND).o
DEPS = $(OBJS:%.o=%.d)

LIBLIST_A = lib/liblist/build/liblist.a
LIBGRAPHEME_A = lib/libgrapheme/libgrapheme.a

PREFIX ?= /usr/local
BINDIR ?= /bin

all: tmus

clean:
	rm -rf build

cleanlibs:
	rm -rf lib/liblist/build

build:
	mkdir build

build/%.o: src/%.c build/%.d | build
	$(CC) -c -o $@ $(DEPFLAGS) $(CFLAGS) $<

build/%.d: | build;

include $(DEPS)

$(LIBLIST_A):
	make -C lib/liblist DEBUG=1 build/liblist.a

$(LIBGRAPHEME_A):
	make -C lib/libgrapheme DEBUG=1 libgrapheme.a

tmus: $(OBJS) $(LIBLIST_A) $(LIBGRAPHEME_A)
	$(CC) -o tmus $^ $(CFLAGS) $(LDLIBS)

install: tmus
	install -m755 $< -t "$(DESTDIR)$(PREFIX)$(BINDIR)"

uninstall:
	rm -f "$(DESTDIR)$(PREFIX)$(BINDIR)"

.PHONY: all clean cleanlibs install uninstall