]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/lib9p/GNUmakefile
bhyvectl(8): Normalize the man page date
[FreeBSD/FreeBSD.git] / contrib / lib9p / GNUmakefile
1 CC_VERSION := $(shell $(CC) --version | \
2     sed -n -e '/clang-/s/.*clang-\([0-9][0-9]*\).*/\1/p')
3 ifeq ($(CC_VERSION),)
4 # probably not clang
5 CC_VERSION := 0
6 endif
7
8 WFLAGS :=
9
10 # Warnings are version-dependent, unfortunately,
11 # so test for version before adding a -W flag.
12 # Note: gnu make requires $(shell test ...) for "a > b" type tests.
13 ifeq ($(shell test $(CC_VERSION) -gt 0; echo $$?),0)
14 WFLAGS += -Weverything
15 WFLAGS += -Wno-padded
16 WFLAGS += -Wno-gnu-zero-variadic-macro-arguments
17 WFLAGS += -Wno-format-nonliteral
18 WFLAGS += -Wno-unused-macros
19 WFLAGS += -Wno-disabled-macro-expansion
20 WFLAGS += -Werror
21 endif
22
23 ifeq ($(shell test $(CC_VERSION) -gt 600; echo $$?),0)
24 WFLAGS += -Wno-reserved-id-macro
25 endif
26
27 CFLAGS := $(WFLAGS) \
28         -g \
29         -O0 \
30         -DL9P_DEBUG=L9P_DEBUG
31 # Note: to turn on debug, use -DL9P_DEBUG=L9P_DEBUG,
32 # and set env variable LIB9P_LOGGING to stderr or to
33 # the (preferably full path name of) the debug log file.
34
35 LIB_SRCS := \
36         pack.c \
37         connection.c \
38         request.c \
39         genacl.c \
40         log.c \
41         hashtable.c \
42         utils.c \
43         rfuncs.c \
44         threadpool.c \
45         sbuf/sbuf.c \
46         transport/socket.c \
47         backend/fs.c
48
49 SERVER_SRCS := \
50         example/server.c
51
52 BUILD_DIR := build
53 LIB_OBJS := $(addprefix build/,$(LIB_SRCS:.c=.o))
54 SERVER_OBJS := $(SERVER_SRCS:.c=.o)
55 LIB := lib9p.dylib
56 SERVER := server
57
58 all: build $(LIB) $(SERVER)
59
60 $(LIB): $(LIB_OBJS)
61         cc -dynamiclib $^ -o build/$@
62
63 $(SERVER): $(SERVER_OBJS) $(LIB)
64         cc $< -o build/$(SERVER) -Lbuild/ -l9p
65
66 clean:
67         rm -rf build
68         rm -f $(SERVER_OBJS)
69 build:
70         mkdir build
71         mkdir build/sbuf
72         mkdir build/transport
73         mkdir build/backend
74
75 build/%.o: %.c
76         $(CC) $(CFLAGS) -c $< -o $@