-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
91 lines (79 loc) · 2.17 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
CC ?= gcc
SRC_DIR ?= src
EXT_DIR ?= ext
BUILD_DIR ?= build
SRCS = \
$(SRC_DIR)/censorscope.c \
$(SRC_DIR)/dns.c \
$(SRC_DIR)/experiment.c \
$(SRC_DIR)/http.c \
$(SRC_DIR)/logging.c \
$(SRC_DIR)/options.c \
$(SRC_DIR)/register.c \
$(SRC_DIR)/sandbox.c \
$(SRC_DIR)/scheduling.c \
$(SRC_DIR)/subprocesses.c \
$(SRC_DIR)/tcp.c \
$(SRC_DIR)/termination.c \
$(SRC_DIR)/transport.c \
$(SRC_DIR)/util.c \
$(EXT_DIR)/ini.c
OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(SRCS))
TEST_DIR ?= tests
TEST_SRCS = \
$(SRC_DIR)/util.c \
$(EXT_DIR)/tinytest.c \
$(TEST_DIR)/tests.c
TEST_OBJS = $(patsubst %.c,$(BUILD_DIR)/%.o,$(TEST_SRCS))
EXE ?= censorscope
TEST_EXE ?= censorscope-tests
LUA_CFLAGS ?= `pkg-config lua5.1 --cflags`
CFLAGS += $(LUA_CFLAGS) -g -Wall -Werror -std=gnu99
ifdef DEFAULT_SANDBOX_DIR
CFLAGS += -DDEFAULT_SANDBOX_DIR="\"$(DEFAULT_SANDBOX_DIR)\""
endif
ifdef DEFAULT_LUASRC_DIR
CFLAGS += -DDEFAULT_LUASRC_DIR="\"$(DEFAULT_LUASRC_DIR)\""
endif
ifdef DEFAULT_RESULTS_DIR
CFLAGS += -DDEFAULT_RESULTS_DIR="\"$(DEFAULT_RESULTS_DIR)\""
endif
ifdef DEFAULT_MAX_MEMORY
CFLAGS += -DDEFAULT_MAX_MEMORY="$(DEFAULT_MAX_MEMORY)"
endif
ifdef DEFAULT_MAX_INSTRUCTIONS
CFLAGS += -DDEFAULT_MAX_INSTRUCTIONS="$(DEFAULT_MAX_INSTRUCTIONS)"
endif
ifdef DEFAULT_DOWNLOAD_TRANSPORT
CFLAGS += -DDEFAULT_DOWNLOAD_TRANSPORT="\"$(DEFAULT_DOWNLOAD_TRANSPORT)\""
endif
ifdef DEFAULT_UPLOAD_TRANSPORT
CFLAGS += -DDEFAULT_UPLOAD_TRANSPORT="\"$(DEFAULT_UPLOAD_TRANSPORT)\""
endif
ifdef CONFIGURATION_PATH
CFLAGS += -DCONFIGURATION_PATH="\"$(CONFIGURATION_PATH)\""
endif
LUA_LIBS ?= `pkg-config lua5.1 --libs`
LDFLAGS := $(LUA_LIBS) -lldns -levent -lcurl -lssl -lcrypto -lz $(LDFLAGS)
all: $(EXE)
echo $(BUILD_DIR)
$(BUILD_DIR)/src/%.o: $(SRC_DIR)/%.c
mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $< -o $@
$(BUILD_DIR)/tests/%.o: $(TEST_DIR)/%.c
mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $< -o $@
$(BUILD_DIR)/$(EXT_DIR)/%.o: $(EXT_DIR)/%.c
mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $< -o $@
$(EXE): $(OBJS)
$(CC) $(LDFLAGS) $(OBJS) -o $@
$(TEST_EXE): $(TEST_OBJS)
$(CC) $(LDFLAGS) $(TEST_OBJS) -o $@
test: $(TEST_EXE)
./$(TEST_EXE)
clean:
rm -f $(OBJS) $(TEST_OBJS)
rm -rf $(BUILD_DIR)
clobber: clean
rm -f $(EXE) $(TEST_EXE)