-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile_6.815
71 lines (50 loc) · 2.83 KB
/
Makefile_6.815
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
# C/C++ compilation involves two stages:
# - compiling: convert each source (*.cpp) file indepdendently into binary object (.o) files
# - linking: assemble all the object files into a single executable
#
# Since any C++ project contains multiple source files, the above
# process involved firing multiple commands. Makefiles help us
# write all the compilation stages in a single file and run them
# as one big script.
#
# See http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
# and many many other tutorials for makefiles
# some variables
BUILD_DIR :=_build
EXECUTABLE := starstack
OUTPUT := Output
# list of headers
HEADERS = $(wildcard *.h)
# the C++ compiler/linker to be used. define here so that we can change
# it easily if needed
#CXX := g++ -w -g3 -ggdb -std=c++11 -I. -O0
CXX := g++ -w -g3 -ggdb -std=c++11 -I. -O3 -march=native -fopenmp
# ------------------------------------------------------------------------------
# 'make' or 'make all' runs the default target 'all' which requires that
# the EXECUTABLE must be available; if the EXECUTABLE is already available
# then nothing happens. see the rules for EXECUTABLE
all: $(EXECUTABLE)
# ------------------------------------------------------------------------------
# 'make run' runs the target 'run' which calls for running the executable
# if the executable is not available, then the rules for creating it are run
# this is a superset of the target 'all' because it creates the executable
# and also runs it
run: $(EXECUTABLE)
./$(EXECUTABLE)
# ------------------------------------------------------------------------------
# 'make clean' runs the target 'clean' which in turn removes the
# intermediate .o files and the executable
clean:
rm -rf $(BUILD_DIR) $(EXECUTABLE) $(OUTPUT)
# ------------------------------------------------------------------------------
# rule for creating the executable: this "links" the .o files using the g++ linker.
# If .o files are not available, then the rules for creating .o files are run.
$(EXECUTABLE): $(BUILD_DIR)/a10_main.o $(BUILD_DIR)/basicImageManipulation.o $(BUILD_DIR)/filtering.o $(BUILD_DIR)/Image.o $(BUILD_DIR)/lodepng.o $(BUILD_DIR)/a10.o $(BUILD_DIR)/homography.o $(BUILD_DIR)/panorama.o $(BUILD_DIR)/cfm.o $(BUILD_DIR)/astro.o
$(CXX) $(BUILD_DIR)/a10_main.o $(BUILD_DIR)/a10.o $(BUILD_DIR)/basicImageManipulation.o $(BUILD_DIR)/filtering.o $(BUILD_DIR)/Image.o $(BUILD_DIR)/lodepng.o $(BUILD_DIR)/cfm.o $(BUILD_DIR)/astro.o $(BUILD_DIR)/homography.o $(BUILD_DIR)/panorama.o -o $(EXECUTABLE)
mkdir -p $(OUTPUT)
# ------------------------------------------------------------------------------
# rules for creating the .o files: compile each of the .cpp files and create a
# corresponding .o file. Each .o depends upon the corresponding .cpp and other .h files
$(BUILD_DIR)/%.o: %.cpp $(HEADERS)
mkdir -p $(BUILD_DIR)
$(CXX) -c $< -o $@