1SOURCES = parser.c playback.c status.c control.c queue.c \
2 database.c expr.c list.c util.c connection.c
3OBJECTS = $(SOURCES:.c=.o)
4HEADERS = fns.h include/mpdserver.h
5
6CFLAGS ?= -O0 -g -Werror
7CFLAGS += -fPIC -std=c99 -D_POSIX_C_SOURCE=200809L
8CFLAGS += -Wpedantic -Wall -Wextra -Wconversion -Wmissing-prototypes \
9 -Wpointer-arith -Wstrict-prototypes -Wshadow -Wcast-align
10
11CPPFLAGS += -I./include -I./vendor/mpc
12
13libmpdserver.a: mpc.o $(OBJECTS)
14 $(AR) rcs $@ $^
15libmpdserver.so: mpc.o $(OBJECTS)
16 $(LD) -o $@ $^ -shared $(LDFLAGS)
17cmd2yaml: cmd2yaml.o libmpdserver.a
18 $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
19
20check: cmd2yaml
21 cd tests && ./cmd2yaml.sh
22valgrind: cmd2yaml
23 cd tests && ./valgrind.sh
24radamsa: cmd2yaml
25 cd tests && ./radamsa.sh
26
27format:
28 clang-format -style=file -i cmd2yaml.c $(SOURCES) $(HEADERS)
29 sed -i $(SOURCES) \
30 -e 's/[ \t]*static mpc_parser_t/static mpc_parser_t/' \
31 -e 's/static mpc_parser_t \*\(..*\)/static mpc_parser_t \*\n\1/'
32
33mpc.o: mpc.c mpc.h
34 $(CC) -c $< -o $@ $(CFLAGS) -w -ansi
35%.o: %.c $(HEADERS)
36 $(CC) -c -o $@ $< $(CPPFLAGS) $(CFLAGS)
37
38VPATH += vendor/mpc
39.PHONY: check valgrind radamsa format