-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
56 lines (41 loc) · 1.28 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
# Use Clang to compile the common files.
CC = clang
# Directories.
BUILD_DIR := build
SRC_DIR := src
MODULES_DIR := modules
COMMON_DIR := $(MODULES_DIR)/common
# Common source and build directories.
COMMON_BUILD_DIR := $(COMMON_DIR)/build
COMMON_SRC_DIR := $(COMMON_DIR)/src
# Common objects.
COMMON_OBJS := $(COMMON_BUILD_DIR)/utils.o $(COMMON_BUILD_DIR)/cmd_line.o $(COMMON_BUILD_DIR)/config.o
# Source and out files.
SEQ_SRC := sequence.c
SEQ_OUT := sequence.o
MAIN_SRC := main.c
MAIN_OUT := pcktbatch
# Global and main flags.
GLOBAL_FLAGS := -O2
MAIN_FLAGS := -pthread -lyaml
# Chains.
all: mk_build sequence main
# Creates the build directory if it doesn't already exist.
mk_build:
mkdir -p $(BUILD_DIR)
# The sequence file.
sequence: mk_build
$(CC) -I $(COMMON_SRC_DIR) $(GLOBAL_FLAGS) -c -o $(BUILD_DIR)/$(SEQ_OUT) $(SRC_DIR)/$(SEQ_SRC)
# The main program.
main: mk_build sequence $(COMMON_OBJS)
$(CC) -I $(COMMON_SRC_DIR) $(GLOBAL_FLAGS) $(MAIN_FLAGS) -o $(BUILD_DIR)/$(MAIN_OUT) $(COMMON_OBJS) $(BUILD_DIR)/$(SEQ_OUT) $(SRC_DIR)/$(MAIN_SRC)
# Cleanup (remove build files).
clean:
$(MAKE) -C $(COMMON_DIR)/ clean
rm -f $(BUILD_DIR)/*.o
rm -f $(BUILD_DIR)/$(MAIN_OUT)
# Install executable to $PATH.
install:
cp $(BUILD_DIR)/$(MAIN_OUT) /usr/bin/$(MAIN_OUT)
.PHONY:
.DEFAULT: all