9 config-host.mak: configure
10 @if [ ! -e "$@" ]; then \
11 echo "Running configure ..."; \
14 echo "$@ is out-of-date, running configure"; \
15 sed -n "/.*Configured with/s/[^:]*: //p" "$@" | sh; \
18 ifneq ($(MAKECMDGOALS),clean)
19 include config-host.mak
22 DEBUGFLAGS = -DFIO_INC_DEBUG
23 CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
24 OPTFLAGS= -g -ffast-math
25 CFLAGS = -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) -I. -I$(SRCDIR)
26 LIBS += -lm $(EXTLIBS)
28 SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio tools/fiologparser.py tools/hist/fiologparser_hist.py tools/fio_jsonplus_clat2csv)
30 ifndef CONFIG_FIO_NO_OPT
31 CFLAGS += -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
33 ifdef CONFIG_BUILD_NATIVE
34 CFLAGS += -march=native
41 SOURCE := $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \
42 $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/lib/*.c))) \
43 gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
44 eta.c verify.c memory.c io_u.c parse.c fio_sem.c rwlock.c \
46 smalloc.c filehash.c profile.c debug.c engines/cpu.c \
47 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
48 engines/ftruncate.c engines/filecreate.c \
49 server.c client.c iolog.c backend.c libfio.c flow.c cconv.c \
50 gettime-thread.c helpers.c json.c idletime.c td_error.c \
51 profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
52 workqueue.c rate-submit.c optgroup.c helper_thread.c \
53 steadystate.c zone-dist.c
56 HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
57 HDFSLIB= -Wl,-rpath $(JAVA_HOME)/jre/lib/$(FIO_HDFS_CPU)/server -L$(JAVA_HOME)/jre/lib/$(FIO_HDFS_CPU)/server $(FIO_LIBHDFS_LIB)/libhdfs.a -ljvm
58 CFLAGS += $(HDFSFLAGS)
59 SOURCE += engines/libhdfs.c
63 CFLAGS += -DBITS_PER_LONG=64
66 CFLAGS += -DBITS_PER_LONG=32
69 SOURCE += engines/libaio.c
72 SOURCE += engines/rdma.c
75 SOURCE += engines/posixaio.c
77 ifdef CONFIG_LINUX_FALLOCATE
78 SOURCE += engines/falloc.c
80 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
81 SOURCE += engines/e4defrag.c
83 ifdef CONFIG_LINUX_SPLICE
84 SOURCE += engines/splice.c
87 SOURCE += engines/guasi.c
89 ifdef CONFIG_FUSION_AW
90 SOURCE += engines/fusion-aw.c
92 ifdef CONFIG_SOLARISAIO
93 SOURCE += engines/solarisaio.c
95 ifdef CONFIG_WINDOWSAIO
96 SOURCE += engines/windowsaio.c
99 SOURCE += engines/rados.c
102 SOURCE += engines/rbd.c
105 SOURCE += engines/http.c
107 SOURCE += oslib/asprintf.c
109 SOURCE += oslib/strsep.c
111 ifndef CONFIG_STRCASESTR
112 SOURCE += oslib/strcasestr.c
114 ifndef CONFIG_STRLCAT
115 SOURCE += oslib/strlcat.c
117 ifndef CONFIG_HAVE_STRNDUP
118 SOURCE += oslib/strndup.c
120 ifndef CONFIG_GETOPT_LONG_ONLY
121 SOURCE += oslib/getopt_long.c
123 ifndef CONFIG_INET_ATON
124 SOURCE += oslib/inet_aton.c
127 SOURCE += engines/glusterfs.c
128 SOURCE += engines/glusterfs_sync.c
129 SOURCE += engines/glusterfs_async.c
130 ifdef CONFIG_GF_FADVISE
131 CFLAGS += "-DGFAPI_USE_FADVISE"
135 SOURCE += engines/mtd.c
136 SOURCE += oslib/libmtd.c
137 SOURCE += oslib/libmtd_legacy.c
140 SOURCE += engines/pmemblk.c
142 ifdef CONFIG_LINUX_DEVDAX
143 SOURCE += engines/dev-dax.c
146 SOURCE += engines/libpmem.c
149 ifeq ($(CONFIG_TARGET_OS), Linux)
150 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
151 oslib/linux-dev-lookup.c
152 LIBS += -lpthread -ldl
155 ifeq ($(CONFIG_TARGET_OS), Android)
156 SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c profiles/tiobench.c \
157 oslib/linux-dev-lookup.c
161 ifeq ($(CONFIG_TARGET_OS), SunOS)
162 LIBS += -lpthread -ldl
163 CPPFLAGS += -D__EXTENSIONS__
165 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
167 LIBS += -lpthread -lrt
170 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
174 ifeq ($(CONFIG_TARGET_OS), NetBSD)
175 LIBS += -lpthread -lrt
178 ifeq ($(CONFIG_TARGET_OS), DragonFly)
180 LIBS += -lpthread -lrt
183 ifeq ($(CONFIG_TARGET_OS), AIX)
184 LIBS += -lpthread -ldl -lrt
185 CPPFLAGS += -D_LARGE_FILES -D__ppc__
186 LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
188 ifeq ($(CONFIG_TARGET_OS), HP-UX)
189 LIBS += -lpthread -ldl -lrt
190 CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
192 ifeq ($(CONFIG_TARGET_OS), Darwin)
193 LIBS += -lpthread -ldl
195 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
196 SOURCE += os/windows/posix.c
197 LIBS += -lpthread -lpsapi -lws2_32
198 CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format -static
201 OBJS := $(SOURCE:.c=.o)
203 FIO_OBJS = $(OBJS) fio.o
205 GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
206 gclient.o gcompat.o cairo_text_helpers.o printing.o
208 ifdef CONFIG_ARITHMETIC
209 FIO_OBJS += lex.yy.o y.tab.o
210 GFIO_OBJS += lex.yy.o y.tab.o
213 -include $(OBJS:.o=.d)
215 T_SMALLOC_OBJS = t/stest.o
216 T_SMALLOC_OBJS += gettime.o fio_sem.o pshared.o smalloc.o t/log.o t/debug.o \
218 T_SMALLOC_PROGS = t/stest
220 T_IEEE_OBJS = t/ieee754.o
221 T_IEEE_OBJS += lib/ieee754.o
222 T_IEEE_PROGS = t/ieee754
224 T_ZIPF_OBS = t/genzipf.o
225 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \
226 lib/strntol.o lib/gauss.o t/genzipf.o oslib/strcasestr.o \
228 T_ZIPF_PROGS = t/fio-genzipf
230 T_AXMAP_OBJS = t/axmap.o
231 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
232 T_AXMAP_PROGS = t/axmap
234 T_LFSR_TEST_OBJS = t/lfsr-test.o
235 T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o fio_sem.o pshared.o \
236 t/log.o t/debug.o t/arch.o
237 T_LFSR_TEST_PROGS = t/lfsr-test
239 T_GEN_RAND_OBJS = t/gen-rand.o
240 T_GEN_RAND_OBJS += t/log.o t/debug.o lib/rand.o lib/pattern.o lib/strntol.o \
241 oslib/strcasestr.o oslib/strndup.o
242 T_GEN_RAND_PROGS = t/gen-rand
244 ifeq ($(CONFIG_TARGET_OS), Linux)
245 T_BTRACE_FIO_OBJS = t/btrace2fio.o
246 T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o oslib/linux-dev-lookup.o
247 T_BTRACE_FIO_PROGS = t/fio-btrace2fio
250 T_DEDUPE_OBJS = t/dedupe.o
251 T_DEDUPE_OBJS += lib/rbtree.o t/log.o fio_sem.o pshared.o smalloc.o gettime.o \
252 crc/md5.o lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o \
253 t/arch.o crc/murmur3.o crc/crc32c.o crc/crc32c-intel.o \
254 crc/crc32c-arm64.o crc/fnv.o
255 T_DEDUPE_PROGS = t/fio-dedupe
257 T_VS_OBJS = t/verify-state.o t/log.o crc/crc32c.o crc/crc32c-intel.o crc/crc32c-arm64.o t/debug.o
258 T_VS_PROGS = t/fio-verify-state
260 T_PIPE_ASYNC_OBJS = t/read-to-pipe-async.o
261 T_PIPE_ASYNC_PROGS = t/read-to-pipe-async
263 T_MEMLOCK_OBJS = t/memlock.o
264 T_MEMLOCK_PROGS = t/memlock
266 T_TT_OBJS = t/time-test.o
267 T_TT_PROGS = t/time-test
269 T_OBJS = $(T_SMALLOC_OBJS)
270 T_OBJS += $(T_IEEE_OBJS)
271 T_OBJS += $(T_ZIPF_OBJS)
272 T_OBJS += $(T_AXMAP_OBJS)
273 T_OBJS += $(T_LFSR_TEST_OBJS)
274 T_OBJS += $(T_GEN_RAND_OBJS)
275 T_OBJS += $(T_BTRACE_FIO_OBJS)
276 T_OBJS += $(T_DEDUPE_OBJS)
277 T_OBJS += $(T_VS_OBJS)
278 T_OBJS += $(T_PIPE_ASYNC_OBJS)
279 T_OBJS += $(T_MEMLOCK_OBJS)
280 T_OBJS += $(T_TT_OBJS)
282 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
283 T_DEDUPE_OBJS += os/windows/posix.o lib/hweight.o
284 T_SMALLOC_OBJS += os/windows/posix.o lib/hweight.o
285 T_LFSR_TEST_OBJS += os/windows/posix.o lib/hweight.o
288 T_TEST_PROGS = $(T_SMALLOC_PROGS)
289 T_TEST_PROGS += $(T_IEEE_PROGS)
290 T_PROGS += $(T_ZIPF_PROGS)
291 T_TEST_PROGS += $(T_AXMAP_PROGS)
292 T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
293 T_TEST_PROGS += $(T_GEN_RAND_PROGS)
294 T_PROGS += $(T_BTRACE_FIO_PROGS)
295 T_PROGS += $(T_DEDUPE_PROGS)
296 T_PROGS += $(T_VS_PROGS)
300 ifneq ($(findstring $(MAKEFLAGS),s),s)
302 QUIET_CC = @echo ' ' CC $@;
303 QUIET_LINK = @echo ' ' LINK $@;
304 QUIET_DEP = @echo ' ' DEP $@;
305 QUIET_YACC = @echo ' ' YACC $@;
306 QUIET_LEX = @echo ' ' LEX $@;
310 ifeq ($(CONFIG_TARGET_OS), SunOS)
315 prefix = $(INSTALL_PREFIX)
316 bindir = $(prefix)/bin
318 ifeq ($(CONFIG_TARGET_OS), Darwin)
319 mandir = /usr/share/man
320 sharedir = /usr/share/fio
322 mandir = $(prefix)/man
323 sharedir = $(prefix)/share/fio
326 all: $(PROGS) $(T_TEST_PROGS) $(SCRIPTS) FORCE
328 .PHONY: all install clean test
331 FIO-VERSION-FILE: FORCE
332 @$(SHELL) $(SRCDIR)/FIO-VERSION-GEN
333 -include FIO-VERSION-FILE
335 override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
339 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
340 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
342 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
343 ifeq ($(CONFIG_TARGET_OS), NetBSD)
344 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | tr -cs "[:graph:]" "\n" | \
345 sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d
347 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 | \
348 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
352 ifdef CONFIG_ARITHMETIC
353 lex.yy.c: exp/expression-parser.l
354 ifdef CONFIG_LEX_USE_O
355 $(QUIET_LEX)$(LEX) -o $@ $<
357 $(QUIET_LEX)$(LEX) $<
360 lex.yy.o: lex.yy.c y.tab.h
361 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
363 y.tab.o: y.tab.c y.tab.h
364 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
366 y.tab.c: exp/expression-parser.y
367 $(QUIET_YACC)$(YACC) -o $@ -l -d -b y $<
373 exp/test-expression-parser.o: exp/test-expression-parser.c
374 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
375 exp/test-expression-parser: exp/test-expression-parser.o
376 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
378 parse.o: lex.yy.o y.tab.o
381 init.o: init.c FIO-VERSION-FILE
383 $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
384 @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
386 @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
387 ifeq ($(CONFIG_TARGET_OS), NetBSD)
388 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | tr -cs "[:graph:]" "\n" | \
389 sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d
391 @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 | \
392 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
396 gcompat.o: gcompat.c gcompat.h
397 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
399 goptions.o: goptions.c goptions.h
400 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
402 ghelpers.o: ghelpers.c ghelpers.h
403 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
405 gerror.o: gerror.c gerror.h
406 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
408 gclient.o: gclient.c gclient.h
409 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
411 gfio.o: gfio.c ghelpers.c
412 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
414 graph.o: graph.c graph.h
415 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
417 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
418 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
420 printing.o: printing.c printing.h
421 $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
423 t/read-to-pipe-async: $(T_PIPE_ASYNC_OBJS)
424 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_PIPE_ASYNC_OBJS) $(LIBS)
426 t/memlock: $(T_MEMLOCK_OBJS)
427 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_MEMLOCK_OBJS) $(LIBS)
429 t/stest: $(T_SMALLOC_OBJS)
430 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
432 t/ieee754: $(T_IEEE_OBJS)
433 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
436 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
439 $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
441 t/fio-genzipf: $(T_ZIPF_OBJS)
442 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
444 t/axmap: $(T_AXMAP_OBJS)
445 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
447 t/lfsr-test: $(T_LFSR_TEST_OBJS)
448 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
450 t/gen-rand: $(T_GEN_RAND_OBJS)
451 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_GEN_RAND_OBJS) $(LIBS)
453 ifeq ($(CONFIG_TARGET_OS), Linux)
454 t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
455 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
458 t/fio-dedupe: $(T_DEDUPE_OBJS)
459 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
461 t/fio-verify-state: $(T_VS_OBJS)
462 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_VS_OBJS) $(LIBS)
464 t/time-test: $(T_TT_OBJS)
465 $(QUIET_LINK)$(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(T_TT_OBJS) $(LIBS)
468 @rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio FIO-VERSION-FILE *.[do] lib/*.d oslib/*.[do] crc/*.d engines/*.[do] profiles/*.[do] t/*.[do] config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h
471 distclean: clean FORCE
472 @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf fiologparser_hist.pdf
477 tools/plot/fio2gnuplot.1:
478 @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot > tools/plot/fio2gnuplot.1
480 doc: tools/plot/fio2gnuplot.1
481 @man -t ./fio.1 | ps2pdf - fio.pdf
482 @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
483 @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
484 @man -t tools/hist/fiologparser_hist.py.1 | ps2pdf - fiologparser_hist.pdf
487 ./fio --minimal --thread --exitall_on_error --runtime=1s --name=nulltest --ioengine=null --rw=randrw --iodepth=2 --norandommap --random_generator=tausworthe64 --size=16T --name=verifyfstest --filename=fiotestfile.tmp --unlink=1 --rw=write --verify=crc32c --verify_state_save=0 --size=16K
489 install: $(PROGS) $(SCRIPTS) tools/plot/fio2gnuplot.1 FORCE
490 $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
491 $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
492 $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
493 $(INSTALL) -m 644 $(SRCDIR)/fio.1 $(DESTDIR)$(mandir)/man1
494 $(INSTALL) -m 644 $(SRCDIR)/tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
495 $(INSTALL) -m 644 $(SRCDIR)/tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
496 $(INSTALL) -m 644 $(SRCDIR)/tools/hist/fiologparser_hist.py.1 $(DESTDIR)$(mandir)/man1
497 $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
498 $(INSTALL) -m 644 $(SRCDIR)/tools/plot/*gpm $(DESTDIR)$(sharedir)/