-
Notifications
You must be signed in to change notification settings - Fork 35
/
Makefile
65 lines (48 loc) · 1.46 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
CC = gcc
CXX = g++
CFLAGS = -Wall -O3 -std=gnu11 -Wfatal-errors -Wunused-parameter -Wextra -openmp
CXXFLAGS = -Wall -O3 -std=gnu++11 -Wfatal-errors -Wunused-parameter -Wextra -openmp
# Include Eigen library
CXXFLAGS += `pkg-config --cflags eigen3`
# Include RedSVD library
CXXFLAGS += -I./RedSVD/include
# No debugging
# CFLAGS += -DNDEBUG
# CXXFLAGS += -DNDEBUG
# Change this to the name of your main file
PROG = main
# Command used to remove the object files and executable
RM = rm -f
RM_DIR = rm -rf
OBJECT_DIR = unix
ifeq ($(OS),Windows_NT)
# Add .exe suffix on Windows
PROG:=$(addsuffix .exe, $(PROG))
# Use del command for deleting files and rmdir command for removing directories on Windows
RM := del
RM_DIR := rmdir /s /q
# Use directory called win for Windows
OBJECT_DIR := win
endif
# Create a list of all object files
OBJS = $(addsuffix .o,$(addprefix $(OBJECT_DIR)/,$(basename $(notdir $(wildcard *.c)))))
OBJS += $(addsuffix .o,$(addprefix $(OBJECT_DIR)/,$(basename $(notdir $(wildcard *.cpp)))))
.PHONY: all clean run
$(PROG): $(OBJS)
$(CXX) -o $(PROG) $(OBJS) $(LDFLAGS)
# Rebuild everything when makefile changes and create build directory.
$(OBJS): Makefile | $(OBJECT_DIR)
$(OBJECT_DIR):
mkdir $(OBJECT_DIR)
$(OBJECT_DIR)/%.o: %.c
$(CC) $(CFLAGS) -o $@ -c $<
$(OBJECT_DIR)/%.o: %.cpp
$(CXX) $(CXXFLAGS) -o $@ -c $<
all: $(PROG)
# Remove all objects and executable
clean:
$(RM_DIR) $(OBJECT_DIR)
$(RM) $(PROG)
# Run executable
run: all
./$(PROG)