-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (58 loc) · 2.41 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
CPP = g++
# Specifies the C++ compiler
INC_DIR = include
SRC_DIR = source
OBJ_DIR = objects
# Directory where header files (.h) are stored
# Directory where source files (.cpp) are stored
# Destination directory to store object files (.o)
# CFLAGS are compiler flags.
# -c Compile one souce code at a time and link them only after all objext files are generated
# -Wall Enable "warning all"
# -O3 Obtimize compilation to the 3rd degree (highest level)
# -g Include debugging information
# -std=c++1z or c++17 C++ language standard should be C++17 or above in clang or gcc respectively
# -fopenmp Use openmp library for parallelization
# -I$(INC_DIR) Include files from INC_DIR when compiling
# Determine the C++17 standard flag based on the compiler
COMPILER := $(shell $(CPP) -dM -E - < /dev/null | grep __clang__)
ifneq ($(COMPILER),)
CXXFLAGS = -c -Wall -O3 -g -std=c++1z -fopenmp -I$(INC_DIR)
else
CXXFLAGS = -c -Wall -O3 -g -std=c++17 -fopenmp -I$(INC_DIR)
endif
LDFLAGS = -fopenmp -lz
# LDFLAGS are linker flags
# -fopenmp link openmp library for parallelization
# -lrt link against the real-time extensions library (sometimes needed when working with POSIX functions)
SRC = $(wildcard $(SRC_DIR)/*.cpp)
# Take all source files from SRC_DIR
OBJS = $(patsubst $(SRC_DIR)/%.cpp,$(OBJ_DIR)/%.o,$(SRC))
# For every source file, generate an object file in OBJ_DIR
EXECUTABLE = RadiSeq
# Specifies the name of the executable generated
EXECUTABLE2 = RadiSeqProfiler
# Seperate executable for the profiler program
# Source file for the new program
SRC2 = radiSeqProfiler/radiSeqProfiler.cpp
OBJ2 = $(OBJ_DIR)/radiSeqProfiler.o
# Create the 'objects' directory if it doesn't exist
$(shell mkdir -p $(OBJ_DIR))
all: $(EXECUTABLE) $(EXECUTABLE2)
$(EXECUTABLE): $(OBJS)
$(CPP) $(OBJS) -o $@ $(LDFLAGS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
$(CPP) $(CXXFLAGS) $< -o $@
# $(SRC) $(EXECUTABLE) -- Dependencies for building the executable
# $(EXECUTABLE): $(OBJS) -- Rule for linking the object files
# rest are the commands: to link the object files and create the executable
# and to compile source files to object files respectively
# Rule for building the new executable
$(EXECUTABLE2): $(OBJ2)
$(CPP) $(OBJ2) -o $@ $(LDFLAGS)
# Rule for compiling the new radiSeqProfiler.cpp file
$(OBJ_DIR)/radiSeqProfiler.o: $(SRC2)
$(CPP) $(CXXFLAGS) $< -o $@
# Remove all the object files and the executable
clean:
rm -rf $(OBJ_DIR)/*.o $(EXECUTABLE) $(EXECUTABLE2)