-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
63 lines (52 loc) · 1.26 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
# Use the intel c++ compiler
CXX=icpc
# Include and lib directories
INCPATH=./
LIBPATH=./
# Staging folders for obj.o files and executables
OBJPATH=./obj
BINPATH=./bin
# Compiler flags
# Use the -mmic flag for native phi binaries
CFLAGS= -Wall \
-openmp \
-vec-report=6 \
-ansi-alias \
-O3 \
-restrict \
-fp-model fast \
-opt-assume-safe-padding \
-I$(INCPATH)
# Linker flags
LFLAGS= # Nothing... yet
# Binary name
BIN=nameofyourprogram
# Create a version of all compiled file names
# with a .o extension
SRCS=$(wildcard *.cpp *.cxx *.c)
OBJS=$(patsubst %.cpp,%.o, \
$(patsubst %.cxx,%.o, \
$(patsubst %.c,%.o, $(SRCS))))
# The whole shebang!
all: clear $(BIN)
# Compile C++/C .cpp/.cxx/.c sources into obj.o files
%.o: %.cpp
mkdir -p $(OBJPATH)
$(CXX) $(CFLAGS) -c $< -o $(OBJPATH)/$@
%.o: %.cxx
mkdir -p $(OBJPATH)
$(CXX) $(CFLAGS) -c $< -o $(OBJPATH)/$@
%.o: %.c
mkdir -p $(OBJPATH)
$(CXX) $(CFLAGS) -c $< -o $(OBJPATH)/$@
# Main unit of compilation - generates binary
$(BIN): $(OBJS)
mkdir -p $(BINPATH)
$(CXX) $(CFLAGS) -o $(BINPATH)/$(BIN) \
$(foreach OBJ, $(OBJS), $(OBJPATH)/$(OBJ))
# Make clean - remove obj.o files
clean:
-rm -f $(OBJPATH)/*.o
# Clear the terminal before compiling
clear:
-clear