summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 5f03e65a143df97418a5f001e610654985bb7cc0 (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
CFLAGS = -I src -g $(shell pkg-config --cflags glib-2.0 dbus-1)
CFLAGS += -I lib/liblist/include -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)" "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

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 build/liblist.a

tmus: $(OBJS) $(LIBLIST_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