options: warn if we fail to make sense of buffer_pattern
[fio.git] / Makefile
1 ifneq ($(wildcard config-host.mak),)
2 all:
3 include config-host.mak
4 config-host-mak: configure
5         @echo $@ is out-of-date, running configure
6         @sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
7 else
8 config-host.mak:
9 ifneq ($(MAKECMDGOALS),clean)
10         @echo "Running configure for you..."
11         @./configure
12 endif
13 all:
14 include config-host.mak
15 endif
16
17 DEBUGFLAGS = -D_FORTIFY_SOURCE=2 -DFIO_INC_DEBUG
18 CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
19 OPTFLAGS= -O3 -g -ffast-math
20 CFLAGS  = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS)
21 LIBS    += -lm $(EXTLIBS)
22 PROGS   = fio
23 SCRIPTS = tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio
24
25 ifdef CONFIG_GFIO
26   PROGS += gfio
27 endif
28
29 SOURCE := gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
30                 eta.c verify.c memory.c io_u.c parse.c mutex.c options.c \
31                 lib/rbtree.c smalloc.c filehash.c profile.c debug.c lib/rand.c \
32                 lib/num2str.c lib/ieee754.c $(wildcard crc/*.c) engines/cpu.c \
33                 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
34                 memalign.c server.c client.c iolog.c backend.c libfio.c flow.c \
35                 cconv.c lib/prio_tree.c json.c lib/zipf.c lib/axmap.c \
36                 lib/lfsr.c gettime-thread.c helpers.c lib/flist_sort.c \
37                 lib/hweight.c lib/getrusage.c idletime.c td_error.c \
38                 profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
39                 lib/tp.c
40
41 ifdef CONFIG_LIBHDFS
42   HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
43   HDFSLIB= $(JAVA_HOME)/jre/lib/amd64/server/libjvm.so $(FIO_LIBHDFS_LIB)/liblibhdfs.a
44   CFLAGS += $(HDFSFLAGS)
45   SOURCE += engines/libhdfs.c
46 endif
47
48 ifdef CONFIG_64BIT_LLP64
49   CFLAGS += -DBITS_PER_LONG=32
50 endif
51 ifdef CONFIG_64BIT
52   CFLAGS += -DBITS_PER_LONG=64
53 endif
54 ifdef CONFIG_32BIT
55   CFLAGS += -DBITS_PER_LONG=32
56 endif
57 ifdef CONFIG_LIBAIO
58   SOURCE += engines/libaio.c
59 endif
60 ifdef CONFIG_RDMA
61   SOURCE += engines/rdma.c
62 endif
63 ifdef CONFIG_POSIXAIO
64   SOURCE += engines/posixaio.c
65 endif
66 ifdef CONFIG_LINUX_FALLOCATE
67   SOURCE += engines/falloc.c
68 endif
69 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
70   SOURCE += engines/e4defrag.c
71 endif
72 ifdef CONFIG_LINUX_SPLICE
73   SOURCE += engines/splice.c
74 endif
75 ifdef CONFIG_GUASI
76   SOURCE += engines/guasi.c
77 endif
78 ifdef CONFIG_FUSION_AW
79   SOURCE += engines/fusion-aw.c
80 endif
81 ifdef CONFIG_SOLARISAIO
82   SOURCE += engines/solarisaio.c
83 endif
84 ifdef CONFIG_WINDOWSAIO
85   SOURCE += engines/windowsaio.c
86 endif
87 ifdef CONFIG_RBD
88   SOURCE += engines/rbd.c
89 endif
90 ifndef CONFIG_STRSEP
91   SOURCE += lib/strsep.c
92 endif
93 ifndef CONFIG_STRCASESTR
94   SOURCE += lib/strcasestr.c
95 endif
96 ifndef CONFIG_GETOPT_LONG_ONLY
97   SOURCE += lib/getopt_long.c
98 endif
99 ifndef CONFIG_INET_ATON
100   SOURCE += lib/inet_aton.c
101 endif
102 ifdef CONFIG_GFAPI
103   SOURCE += engines/glusterfs.c
104   SOURCE += engines/glusterfs_sync.c
105   SOURCE += engines/glusterfs_async.c
106   ifdef CONFIG_GF_FADVISE
107     CFLAGS += "-DGFAPI_USE_FADVISE"
108   endif
109 endif
110
111 ifeq ($(CONFIG_TARGET_OS), Linux)
112   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
113                 engines/binject.c
114   LIBS += -lpthread -ldl
115   LDFLAGS += -rdynamic
116 endif
117 ifeq ($(CONFIG_TARGET_OS), Android)
118   SOURCE += diskutil.c fifo.c blktrace.c trim.c profiles/tiobench.c
119   LIBS += -ldl
120   LDFLAGS += -rdynamic
121 endif
122 ifeq ($(CONFIG_TARGET_OS), SunOS)
123   LIBS   += -lpthread -ldl
124   CPPFLAGS += -D__EXTENSIONS__
125 endif
126 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
127   LIBS   += -lpthread -lrt
128   LDFLAGS += -rdynamic
129 endif
130 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
131   LIBS   += -lpthread
132   LDFLAGS += -rdynamic
133 endif
134 ifeq ($(CONFIG_TARGET_OS), NetBSD)
135   LIBS   += -lpthread -lrt
136   LDFLAGS += -rdynamic
137 endif
138 ifeq ($(CONFIG_TARGET_OS), AIX)
139   LIBS   += -lpthread -ldl -lrt
140   CPPFLAGS += -D_LARGE_FILES -D__ppc__
141   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
142 endif
143 ifeq ($(CONFIG_TARGET_OS), HP-UX)
144   LIBS   += -lpthread -ldl -lrt
145   CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
146 endif
147 ifeq ($(CONFIG_TARGET_OS), Darwin)
148   LIBS   += -lpthread -ldl
149 endif
150 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
151   SOURCE := $(filter-out engines/mmap.c,$(SOURCE))
152   SOURCE += os/windows/posix.c
153   LIBS   += -lpthread -lpsapi -lws2_32
154   CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static
155 endif
156
157 OBJS = $(SOURCE:.c=.o)
158
159 FIO_OBJS = $(OBJS) fio.o
160 GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
161                         gclient.o gcompat.o cairo_text_helpers.o printing.o
162
163 -include $(OBJS:.o=.d)
164
165 T_SMALLOC_OBJS = t/stest.o
166 T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
167 T_SMALLOC_PROGS = t/stest
168
169 T_IEEE_OBJS = t/ieee754.o
170 T_IEEE_OBJS += lib/ieee754.o
171 T_IEEE_PROGS = t/ieee754
172
173 T_ZIPF_OBS = t/genzipf.o
174 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/zipf.o t/genzipf.o
175 T_ZIPF_PROGS = t/genzipf
176
177 T_AXMAP_OBJS = t/axmap.o
178 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
179 T_AXMAP_PROGS = t/axmap
180
181 T_LFSR_TEST_OBJS = t/lfsr-test.o
182 T_LFSR_TEST_OBJS += lib/lfsr.o
183 T_LFSR_TEST_PROGS = t/lfsr-test
184
185 T_OBJS = $(T_SMALLOC_OBJS)
186 T_OBJS += $(T_IEEE_OBJS)
187 T_OBJS += $(T_ZIPF_OBJS)
188 T_OBJS += $(T_AXMAP_OBJS)
189 T_OBJS += $(T_LFSR_TEST_OBJS)
190
191 T_PROGS = $(T_SMALLOC_PROGS)
192 T_PROGS += $(T_IEEE_PROGS)
193 T_PROGS += $(T_ZIPF_PROGS)
194 T_PROGS += $(T_AXMAP_PROGS)
195 T_PROGS += $(T_LFSR_TEST_PROGS)
196
197 ifneq ($(findstring $(MAKEFLAGS),s),s)
198 ifndef V
199         QUIET_CC        = @echo '   ' CC $@;
200         QUIET_LINK      = @echo '   ' LINK $@;
201         QUIET_DEP       = @echo '   ' DEP $@;
202 endif
203 endif
204
205 ifeq ($(CONFIG_TARGET_OS), SunOS)
206         INSTALL = ginstall
207 else
208         INSTALL = install
209 endif
210 prefix = /usr/local
211 bindir = $(prefix)/bin
212
213 ifeq ($(CONFIG_TARGET_OS), Darwin)
214 mandir = /usr/share/man
215 sharedir = /usr/share/fio
216 else
217 mandir = $(prefix)/man
218 sharedir = $(prefix)/share/fio
219 endif
220
221 all: $(PROGS) $(SCRIPTS) FORCE
222
223 .PHONY: all install clean
224 .PHONY: FORCE cscope
225
226 FIO-VERSION-FILE: FORCE
227         @$(SHELL) ./FIO-VERSION-GEN
228 -include FIO-VERSION-FILE
229
230 override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
231
232 %.o : %.c
233         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
234         @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $*.c > $*.d
235         @mv -f $*.d $*.d.tmp
236         @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
237         @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
238                 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
239         @rm -f $*.d.tmp
240
241 init.o: FIO-VERSION-FILE init.c
242         $(QUIET_CC)$(CC) -o init.o $(CFLAGS) $(CPPFLAGS) -c init.c
243
244 gcompat.o: gcompat.c gcompat.h
245         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gcompat.c
246
247 goptions.o: goptions.c goptions.h
248         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c goptions.c
249
250 ghelpers.o: ghelpers.c ghelpers.h
251         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c ghelpers.c
252
253 gerror.o: gerror.c gerror.h
254         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gerror.c
255
256 gclient.o: gclient.c gclient.h
257         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gclient.c
258
259 gfio.o: gfio.c ghelpers.c
260         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c gfio.c
261
262 graph.o: graph.c graph.h
263         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c graph.c
264
265 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
266         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c cairo_text_helpers.c
267
268 printing.o: printing.c printing.h
269         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c printing.c
270
271 t/stest: $(T_SMALLOC_OBJS)
272         $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
273
274 t/ieee754: $(T_IEEE_OBJS)
275         $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
276
277 fio: $(FIO_OBJS)
278         $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
279
280 gfio: $(GFIO_OBJS)
281         $(QUIET_LINK)$(CC) $(LDFLAGS) -o gfio $(GFIO_OBJS) $(LIBS) $(GTK_LDFLAGS)
282
283 t/genzipf: $(T_ZIPF_OBJS)
284         $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
285
286 t/axmap: $(T_AXMAP_OBJS)
287         $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
288
289 t/lfsr-test: $(T_LFSR_TEST_OBJS)
290         $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
291
292 clean: FORCE
293         -rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) core.* core gfio FIO-VERSION-FILE *.d lib/*.d crc/*.d engines/*.d profiles/*.d t/*.d config-host.mak config-host.h
294
295 distclean: clean FORCE
296         @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf
297
298 cscope:
299         @cscope -b -R
300
301 tools/plot/fio2gnuplot.1:
302         @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot >  tools/plot/fio2gnuplot.1
303
304 doc: tools/plot/fio2gnuplot.1
305         @man -t ./fio.1 | ps2pdf - fio.pdf
306         @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
307         @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
308
309 install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
310         $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
311         $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
312         $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
313         $(INSTALL) -m 644 fio.1 $(DESTDIR)$(mandir)/man1
314         $(INSTALL) -m 644 tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
315         $(INSTALL) -m 644 tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
316         $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
317         $(INSTALL) -m 644 tools/plot/*gpm $(DESTDIR)$(sharedir)/