-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (80 loc) · 2.06 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# C source code
CSRC = io_png/io_png.c
# C++ source code
CXXSRC = numerics1.cpp frot.cpp splines.cpp fproj.cpp \
library.cpp flimage.cpp filter.cpp \
demo_lib_sift.cpp compute_asift_keypoints.cpp \
compute_asift_matches.cpp \
libMatch/match.cpp libNumerics/numerics.cpp \
orsa.cpp demo_ASIFT.cpp
# all source code
SRC = $(CSRC) $(CXXSRC)
# C objects
COBJ = $(CSRC:.c=.o)
# C++ objects
CXXOBJ = $(CXXSRC:.cpp=.o)
# all objects
OBJ = $(COBJ) $(CXXOBJ)
# binary target
BIN = demo_ASIFT
default : $(BIN)
# C optimization flags
#COPT = -O3 -ftree-vectorize -funroll-loops
#COPT = -m32 -mfpmath=sse -Ofast -flto -march=native -funroll-loops
COPT = -m64 -Ofast -flto -march=native -funroll-loops
# C++ optimization flags
CXXOPT = $(COPT)
# C compilation flags
CFLAGS = $(COPT) -Wall -Wextra \
-Wno-write-strings -ansi
# C++ compilation flags
CXXFLAGS = $(CXXOPT) -Wall -Wextra \
-Wno-write-strings -Wno-deprecated -ansi
# link flags
LDFLAGS = -lpng -lm
# use local embedded libraries with `make LOCAL_LIBS=1`
ifdef LOCAL_LIBS
# library location
LIBDIR = io_png/libs/build/lib
INCDIR = io_png/libs/build/include
# libpng is required
LIBDEPS += libpng
# compile options to use the local libpng header
CFLAGS += -I$(INCDIR) -D_LOCAL_LIBS
# link options to use the local libraries
LDFLAGS = $(LIBDIR)/libpng.a $(LIBDIR)/libz.a -lm
# io_png.o needs png.h
io_png/io_png.o : $(LIBDEPS)
endif
# use openMP with `make OMP=1`
ifdef OMP
CFLAGS += -fopenmp
CXXFLAGS += -fopenmp
LDFLAGS += -lgomp
else
CFLAGS += -Wno-unknown-pragmas
CXXFLAGS += -Wno-unknown-pragmas
endif
# build the local png library
.PHONY : libpng
libpng :
$(MAKE) -C io_png/libs libpng
CFLAGS += -I./io_png/
CXXFLAGS += -I./
# partial compilation of C source code
%.o: %.c %.h
$(CC) -c -o $@ $< $(CFLAGS)
# partial compilation of C++ source code
%.o: %.cpp %.h
$(CXX) -c -o $@ $< $(CXXFLAGS)
# link all the opject code
$(BIN): $(OBJ) $(LIBDEPS)
$(CXX) -o $@ $(OBJ) $(LDFLAGS)
# housekeeping
.PHONY : clean distclean
clean :
$(RM) $(OBJ)
$(MAKE) -C ./io_png/libs $@
distclean : clean
$(RM) $(BIN)
$(MAKE) -C ./io_png/libs $@