-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·56 lines (39 loc) · 1.27 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
CC = gcc
CFLAGS = -Wall -g -D_POSIX_SOURCE -D_DEFAULT_SOURCE -Werror -pedantic
LDFLAGS := $(LDFLAGS)-L/usr/local/lib/
LDLIBS = -lnng -lbinn -lsodium
SRC_DIRS ?= .
INC_DIRS := $(shell find . ! -path . -type d)
ifeq ($(shell uname), Darwin)
CC = gcc-9
INC_DIRS := $(INC_DIRS) /usr/local/include/nng/ \
/usr/local/include/ /usr/local/include/sodium/
endif
INC_FLAGS := $(addprefix -I, $(INC_DIRS:./%=%))
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
# SRCS := $(shell find $(SRC_DIRS) -name "*.c")
GET_OBJS = $(addsuffix .o, $(basename $(shell find $(1) -name "*.c")))
DEPS := $($(call GET_OBJS,$(SRC_DIRS)):.o=.d)
NODE_SRC_DIRS := lib
NODE_OBJS := $(call GET_OBJS, $(NODE_SRC_DIRS))
TEST_SRC_DIRS := test
TEST_OBJS := $(call GET_OBJS, $(TEST_SRC_DIRS))
.SUFFIXES: .c .o
.PHONY: all clean
all: node address_node testrunner
$(RM) $(shell find $(SRC_DIRS) -name "*.d")
test: testrunner
$(RM) $(shell find $(SRC_DIRS) -name "*.d")
./testrunner
node: $(NODE_OBJS)
address_node: $(NODE_OBJS)
testrunner: $(NODE_OBJS) $(TEST_OBJS)
clean:
$(RM) $(shell find $(SRC_DIRS) -name "*.o")
$(RM) $(shell find $(SRC_DIRS) -name "*.d")
$(RM) $(shell find $(SRC_DIRS) -name "*.bin")
rm -rf $(shell find $(SRC_DIRS) -name "*.dSYM")
$(RM) node
$(RM) testrunner
$(RM) address_node
-include $(DEPS)