forked from Creepsky/creepMiner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (31 loc) · 1.23 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
LOGGING := service
MODULES := sphlib nxt
SRC_DIR := $(addprefix src/,$(MODULES)) src
BUILD_DIR := $(addprefix bin/obj/,$(MODULES)) bin/obj
POCO_MODULES := Net Foundation NetSSL_OpenSSL openssl Crypto Util JSON
POCO_DIR := $(addprefix Poco/,$(POCO_MODULES))
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
OBJ := $(patsubst src/%.cpp,bin/obj/%.o,$(SRC))
INCLUDES := $(addprefix -I,$(SRC_DIR)) $(addprefix -I,$(POCO_DIR))
EXECUTABLE := creepMiner
EXECUTABLE_PATH := bin/$(EXECUTABLE)
cflags_logging.service := -DLOG_SERVICE
cflags_logging.terminal := -DLOG_TERMINAL
CFLAGS := -O3 -march=native -std=c++14 -Wall -D_REENTRANT -DNDEBUG ${cflags_logging.${LOGGING}}
CC := $(CXX)
LDFLAGS := -L/usr/local/lib -pthread -lPocoFoundation -lPocoNetSSL -lPocoCrypto -lPocoUtil -lPocoNet -lPocoJSON
vpath %.cpp $(SRC_DIR)
define make-goal
$1/%.o: %.cpp
$(CC) $(CFLAGS) $(INCLUDES) -c $$< -o $$@
endef
.PHONY: all checkdirs clean
all: checkdirs bin/$(EXECUTABLE)
$(EXECUTABLE_PATH): $(OBJ)
$(CC) $(CFLAGS) -o $(EXECUTABLE_PATH) $(OBJ) $(LDFLAGS)
checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
@mkdir -p $@
clean:
@rm -rf $(BUILD_DIR)/*.o
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))