-
Notifications
You must be signed in to change notification settings - Fork 45
/
Makefile
78 lines (63 loc) · 1.52 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
PREFIX=/usr/local
DESTDIR=
LIBDIR=${PREFIX}/lib
INCDIR=${PREFIX}/include
CFLAGS += --std=c99 -D_XOPEN_SOURCE=600 -g -O2 -DDEBUG -fPIC
CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wno-unused-parameter
LIBS=-lev -lcurl
AR=ar
AR_FLAGS=rc
RANLIB=ranlib
ifeq (1, $(WITH_JANSSON))
LIBS+=-ljansson
CFLAGS+=-DWITH_JANSSON
else
LIBS+=-ljson-c
endif
LIBNSQ_HEADERS = \
nsq.h \
http.h
LIBNSQ_SOURCES = \
command.c \
message.c \
reader.c \
http.c \
json.c \
nsqlookupd.c \
nsqd_connection.c \
buffer.c \
buffered_socket.c
all: libnsq
libnsq: libnsq.a
%.o: %.c
$(CC) -o $@ -c $< -I. $(CFLAGS)
libnsq.a: $(patsubst %.c, %.o, ${LIBNSQ_SOURCES})
$(AR) $(AR_FLAGS) $@ $^
$(RANLIB) $@
fmt: ${LIBNSQ_SOURCES} ${LIBNSQ_HEADERS}
astyle --style=1tbs \
--lineend=linux \
--convert-tabs \
--preserve-date \
--pad-header \
--indent-switches \
--align-pointer=name \
--align-reference=name \
--pad-oper \
-n $^
test: test-nsqd test-lookupd test-evbuffsock
test-nsqd: test.c libnsq.a
$(CC) -o $@ $^ -I. $(CFLAGS) $(LIBS) -DNSQD_STANDALONE
test-lookupd: test.c libnsq.a
$(CC) -o $@ $^ -I. $(CFLAGS) $(LIBS)
test-evbuffsock: test_evbuffsock.c buffer.c
$(CC) -o $@ $^ $(CFLAGS) -lev
clean:
rm -rvf libnsq.a test-nsqd test-lookupd test-evbuffsock *.dSYM *.o
.PHONY: install clean all test
install:
install -m 755 -d ${DESTDIR}${INCDIR}
install -m 755 -d ${DESTDIR}${LIBDIR}
install -m 755 libnsq.a ${DESTDIR}${LIBDIR}/libnsq.a
install -m 755 nsq.h ${DESTDIR}${INCDIR}/nsq.h
install -m 755 evbuffsock.h ${DESTDIR}${INCDIR}/evbuffsock.h