-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
37 lines (25 loc) · 781 Bytes
/
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
CFLAGS := -O3 -march=native -std=c++11 -Wall -D_REENTRANT
CC := g++ $(CFLAGS)
LD := g++ -pthread
MODULES := rapidjson sphlib nxt
SRC_DIR := $(addprefix src/,$(MODULES)) src
BUILD_DIR := $(addprefix bin/,$(MODULES)) bin
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.cpp))
OBJ := $(patsubst src/%.cpp,bin/%.o,$(SRC))
INCLUDES := $(addprefix -I,$(SRC_DIR))
EXECUTABLE:= burstminer
vpath %.cpp $(SRC_DIR)
define make-goal
$1/%.o: %.cpp
$(CC) $(INCLUDES) -c $$< -o $$@
endef
.PHONY: all checkdirs clean
all: checkdirs bin/$(EXECUTABLE)
bin/$(EXECUTABLE): $(OBJ)
$(LD) $^ -o $@
checkdirs: $(BUILD_DIR)
$(BUILD_DIR):
@mkdir -p $@
clean:
@rm -rf $(BUILD_DIR)
$(foreach bdir,$(BUILD_DIR),$(eval $(call make-goal,$(bdir))))