-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (46 loc) · 1.05 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
CC ?= gcc
CFLAGS ?= -pedantic -W -Wall
LDFLAGS ?= -shared -fPIC
INCLUDES = -Imsgpack
CFLAGS_DEBUG = -g -DDEBUG
# target build configuration
TARGET_SRCS = \
msgpack/message.c \
msgpack/unpack.c \
ltx.c \
main.c
TARGET = ltx
# library build configuration
LIB_SRCS = \
msgpack/message.c \
msgpack/unpack.c \
ltx.c
LIBRARY = libltx.so
# tests build configuration
TESTS_DEPS = \
msgpack/message.c \
msgpack/unpack.c
TESTS_SRCS = \
tests/test_message.c \
tests/test_unpack.c \
tests/test_utils.c
TESTS = $(TESTS_SRCS:%.c=%)
# make rules
.PHONY: $(TARGET) $(TESTS) clean debug shared shared-debug
all: $(TARGET_SRCS)
$(CC) $(CFLAGS) $(INCLUDES) \
$(TARGET_SRCS) -o $(TARGET)
debug: CFLAGS += $(CFLAGS_DEBUG)
debug: all
shared: $(LIB_SRCS)
$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) \
$(LIB_SRCS) -o $(LIBRARY)
shared-debug: CFLAGS += $(CFLAGS_DEBUG)
shared-debug: shared
test: $(TESTS)
$(TESTS): $(TESTS_DEPS)
$(CC) $(CFLAGS) $(INCLUDES) \
$(TESTS_DEPS) [email protected] -o $@ \
`pkg-config --cflags --libs check`
clean:
$(RM) $(TARGET) $(LIBRARY) $(TESTS)