This repository has been archived by the owner on Aug 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (44 loc) · 1.53 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
NAME := ranking
DEBUG_SUFFIX := _debug
RELEASE_SUFFIX := _release
DEBUG_OUTPUT := $(NAME)$(DEBUG_SUFFIX)
RELEASE_OUTPUT := $(NAME)$(RELEASE_SUFFIX)
SRC_EXT := .c
SRC_DIR := src
SRC := $(wildcard $(SRC_DIR)/*$(SRC_EXT))
CC := gcc
CFLAGS := -Wall -Wextra -Werror -MMD -MP
CFLAGS_DEBUG := $(CFLAGS) -g3
CFLAGS_RELEASE := $(CFLAGS) -Ofast -DNDEBUG
BUILD_DIR := .build
OBJ_EXT := .o
OBJ_DEBUG := $(SRC:$(SRC_DIR)/%$(SRC_EXT)=$(BUILD_DIR)/%$(DEBUG_SUFFIX)$(OBJ_EXT))
OBJ_RELEASE := $(SRC:$(SRC_DIR)/%$(SRC_EXT)=$(BUILD_DIR)/%$(RELEASE_SUFFIX)$(OBJ_EXT))
DOXYGEN_DIR := doc/doxygen
GRAPH_FILE := data/wb-cs-stanford.txt
RUN_ARGS := $(GRAPH_FILE) $(basename $(GRAPH_FILE)).data 10 0.85 0.95 0.05 0.5 0.5 1
STUDY_OUTPUT := datastudy *.Rout
all: $(DEBUG_OUTPUT) $(RELEASE_OUTPUT)
$(DEBUG_OUTPUT): $(OBJ_DEBUG)
$(CC) $(CFLAGS_DEBUG) $^ -o $@
$(RELEASE_OUTPUT): $(OBJ_RELEASE)
$(CC) $(CFLAGS_RELEASE) $^ -o $@
clean:
rm -rf $(DEBUG_OUTPUT) $(RELEASE_OUTPUT) $(BUILD_DIR) $(DOXYGEN_DIR) $(STUDY_OUTPUT)
doc:
doxygen
re: clean all
run: $(RELEASE_OUTPUT)
./$< $(RUN_ARGS)
run-gdb: $(DEBUG_OUTPUT)
gdb --args ./$< $(RUN_ARGS)
run-valgrind: $(DEBUG_OUTPUT)
valgrind --leak-check=full ./$< $(RUN_ARGS)
$(BUILD_DIR):
mkdir $@
$(BUILD_DIR)/%$(DEBUG_SUFFIX)$(OBJ_EXT): $(SRC_DIR)/%$(SRC_EXT) | $(BUILD_DIR)
$(CC) $(CFLAGS_DEBUG) -c $< -o $@
$(BUILD_DIR)/%$(RELEASE_SUFFIX)$(OBJ_EXT): $(SRC_DIR)/%$(SRC_EXT) | $(BUILD_DIR)
$(CC) $(CFLAGS_RELEASE) -c $< -o $@
-include $(OBJ:%$(OBJ_EXT)=%.d)
.PHONY: all clean doc re run run-gdb run-valgrind