-
Notifications
You must be signed in to change notification settings - Fork 60
/
Makefile
151 lines (109 loc) · 4.85 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
CC?=gcc
CXX?=g++
AR?=ar
# Set the default optional flags if none are specified
# Release mode (If just dropping the lib into your project, check out -flto too.)
#
# Note1: OpenMP is (currently) not required by the lib, just for precise benchmarking.
# Note2: the -Wa,-ahl=... part only generates .s assembly so one can see generated code.
# Note3: If you want to add `-flto`, you should add the same -O to LDFLAGS as to FLAGS.
DEFAULT_FLAGS=-O3 -g -DNDEBUG -fopenmp -Wall -Wextra -Wa,-ahl=$(@:.o=.s)
DEFAULT_LDFLAGS=-fopenmp
# Debug mode
# DEFAULT_FLAGS=-fPIC -Wall -Wextra -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -I. -O0 -g -fopenmp -Wa,-ahl=$(@:.o=.s)
# DEFAULT_LDFLAGS=-fopenmp -g
# First set the flags to their defaults if not supplied externally.
CFLAGS?=$(DEFAULT_FLAGS)
CXXFLAGS?=$(DEFAULT_FLAGS)
LDFLAGS?=$(DEFAULT_LDFLAGS)
# Then add those flags we can't live without, unconditionally.
CFLAGS+=-fPIC -I. -pedantic
CXXFLAGS+=-fPIC -I. -std=c++0x
LDFLAGS+=-lm
.PHONY: all benchmarks samples clean
all: libheatmap.a libheatmap.so benchmarks examples tests
tests: tests/test
benchmarks: benchs/add_point_with_stamp benchs/weighted_unweighted benchs/rendering
examples: examples/heatmap_gen examples/heatmap_gen_weighted examples/simplest_cpp examples/simplest_c examples/huge examples/customstamps examples/customstamp_heatmaps examples/show_colorschemes
clean:
rm -f libheatmap.a
rm -f libheatmap.so
rm -f benchs/add_point_with_stamp
rm -f benchs/rendering
rm -f examples/heatmap_gen
rm -f examples/heatmap_gen_weighted
rm -f examples/simplest_c
rm -f examples/simplest_cpp
rm -f examples/simplest_libpng_cpp
rm -f examples/huge
rm -f examples/customstamps
rm -f examples/customstamp_heatmaps
rm -f examples/show_colorschemes
rm -f tests/test
find . -name '*.[os]' -print0 | xargs -0 rm -f
test: tests
tests/test
heatmap.o: heatmap.c heatmap.h
$(CC) -c $< $(CFLAGS) -o $@
colorschemes/%.o: colorschemes/%.c colorschemes/%.h
$(CC) -c $< $(CFLAGS) -o $@
libheatmap.a: heatmap.o $(patsubst %.c,%.o,$(wildcard colorschemes/*.c))
$(AR) rs $@ $^
libheatmap.so: heatmap.o $(patsubst %.c,%.o,$(wildcard colorschemes/*.c))
$(CC) $(LDFLAGS) -shared -o $@ $^
tests/test.o: tests/test.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
tests/test: tests/test.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
examples/lodepng_cpp.o: examples/lodepng.cpp examples/lodepng.h
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/lodepng_c.o: examples/lodepng.cpp examples/lodepng.h
$(CC) -x c -c $< $(CFLAGS) -o $@
examples/heatmap_gen.o: examples/heatmap_gen.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/heatmap_gen: examples/heatmap_gen.o examples/lodepng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
examples/heatmap_gen_weighted.o: examples/heatmap_gen.cpp
$(CXX) -c $< $(CXXFLAGS) -DWEIGHTED -o $@
examples/heatmap_gen_weighted: examples/heatmap_gen_weighted.o examples/lodepng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
examples/simplest_cpp.o: examples/simplest.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/simplest_cpp: examples/simplest_cpp.o examples/lodepng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
examples/simplest_c.o: examples/simplest.c
$(CC) -c $< $(CFLAGS) -o $@
examples/simplest_c: examples/simplest_c.o examples/lodepng_c.o libheatmap.a
$(CC) $^ $(LDFLAGS) -o $@
examples/simplest_libpng_cpp.o: examples/simplest_libpng.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/simplest_libpng_cpp: examples/simplest_libpng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -lpng -o $@
examples/huge.o: examples/huge.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/huge: examples/huge.o examples/lodepng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
examples/customstamps.o: examples/customstamps.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/customstamps: examples/customstamps.o examples/lodepng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
examples/customstamp_heatmaps.o: examples/customstamp_heatmaps.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/customstamp_heatmaps: examples/customstamp_heatmaps.o examples/lodepng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
examples/show_colorschemes.o: examples/show_colorschemes.cpp
$(CXX) -c $< $(CXXFLAGS) -o $@
examples/show_colorschemes: examples/show_colorschemes.o examples/lodepng_cpp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
benchs/add_point_with_stamp.o: benchs/add_point_with_stamp.cpp benchs/common.hpp benchs/timing.hpp
$(CXX) -c $< $(CXXFLAGS) -o $@
benchs/add_point_with_stamp: benchs/add_point_with_stamp.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
benchs/weighted_unweighted.o: benchs/weighted_unweighted.cpp benchs/common.hpp benchs/timing.hpp
$(CXX) -c $< $(CXXFLAGS) -o $@
benchs/weighted_unweighted: benchs/weighted_unweighted.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@
benchs/rendering.o: benchs/rendering.cpp benchs/common.hpp benchs/timing.hpp
$(CXX) -c $< $(CXXFLAGS) -o $@
benchs/rendering: benchs/rendering.o libheatmap.a
$(CXX) $^ $(LDFLAGS) -o $@