zbd: change some f->zbd_info conditionals to asserts
[fio.git] / Makefile
1 ifeq ($(SRCDIR),)
2 SRCDIR := .
3 endif
4
5 VPATH := $(SRCDIR)
6
7 all: fio
8
9 config-host.mak: configure
10         @if [ ! -e "$@" ]; then                                 \
11           echo "Running configure ...";                         \
12           ./configure;                                          \
13         else                                                    \
14           echo "$@ is out-of-date, running configure";          \
15           sed -n "/.*Configured with/s/[^:]*: //p" "$@" | sh;   \
16         fi
17
18 ifneq ($(MAKECMDGOALS),clean)
19 include config-host.mak
20 endif
21
22 DEBUGFLAGS = -DFIO_INC_DEBUG
23 CPPFLAGS= -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFIO_INTERNAL $(DEBUGFLAGS)
24 OPTFLAGS= -g -ffast-math
25 FIO_CFLAGS= -std=gnu99 -Wwrite-strings -Wall -Wdeclaration-after-statement $(OPTFLAGS) $(EXTFLAGS) $(BUILD_CFLAGS) -I. -I$(SRCDIR)
26 LIBS    += -lm $(EXTLIBS)
27 PROGS   = fio
28 SCRIPTS = $(addprefix $(SRCDIR)/,tools/fio_generate_plots tools/plot/fio2gnuplot tools/genfio tools/fiologparser.py tools/hist/fiologparser_hist.py tools/hist/fio-histo-log-pctiles.py tools/fio_jsonplus_clat2csv)
29
30 ifndef CONFIG_FIO_NO_OPT
31   FIO_CFLAGS += -O3 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
32 endif
33 ifdef CONFIG_BUILD_NATIVE
34   FIO_CFLAGS += -march=native
35 endif
36
37 ifdef CONFIG_PDB
38   LINK_PDBFILE ?= -Wl,-pdb,$(dir $@)/$(basename $(@F)).pdb
39   FIO_CFLAGS += -gcodeview
40   LDFLAGS += -fuse-ld=lld $(LINK_PDBFILE)
41 endif
42
43 # If clang, do not use builtin stpcpy as it breaks the build
44 ifeq ($(CC),clang)
45   FIO_CFLAGS += -fno-builtin-stpcpy
46 endif
47
48 ifdef CONFIG_GFIO
49   PROGS += gfio
50 endif
51
52 SOURCE :=       $(sort $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/crc/*.c)) \
53                 $(patsubst $(SRCDIR)/%,%,$(wildcard $(SRCDIR)/lib/*.c))) \
54                 gettime.c ioengines.c init.c stat.c log.c time.c filesetup.c \
55                 eta.c verify.c memory.c io_u.c parse.c fio_sem.c rwlock.c \
56                 pshared.c options.c \
57                 smalloc.c filehash.c profile.c debug.c engines/cpu.c \
58                 engines/mmap.c engines/sync.c engines/null.c engines/net.c \
59                 engines/ftruncate.c engines/filecreate.c engines/filestat.c engines/filedelete.c \
60                 server.c client.c iolog.c backend.c libfio.c flow.c cconv.c \
61                 gettime-thread.c helpers.c json.c idletime.c td_error.c \
62                 profiles/tiobench.c profiles/act.c io_u_queue.c filelock.c \
63                 workqueue.c rate-submit.c optgroup.c helper_thread.c \
64                 steadystate.c zone-dist.c zbd.c
65
66 ifdef CONFIG_LIBHDFS
67   HDFSFLAGS= -I $(JAVA_HOME)/include -I $(JAVA_HOME)/include/linux -I $(FIO_LIBHDFS_INCLUDE)
68   HDFSLIB= -Wl,-rpath $(JAVA_HOME)/lib/$(FIO_HDFS_CPU)/server -L$(JAVA_HOME)/lib/$(FIO_HDFS_CPU)/server $(FIO_LIBHDFS_LIB)/libhdfs.a -ljvm
69   FIO_CFLAGS += $(HDFSFLAGS)
70   SOURCE += engines/libhdfs.c
71 endif
72
73 ifdef CONFIG_LIBISCSI
74   libiscsi_SRCS = engines/libiscsi.c
75   libiscsi_LIBS = $(LIBISCSI_LIBS)
76   libiscsi_CFLAGS = $(LIBISCSI_CFLAGS)
77   ENGINES += libiscsi
78 endif
79
80 ifdef CONFIG_LIBNBD
81   nbd_SRCS = engines/nbd.c
82   nbd_LIBS = $(LIBNBD_LIBS)
83   nbd_CFLAGS = $(LIBNBD_CFLAGS)
84   ENGINES += nbd
85 endif
86
87 ifdef CONFIG_LIBNFS
88   CFLAGS += $(LIBNFS_CFLAGS)
89   LIBS += $(LIBNFS_LIBS)
90   SOURCE += engines/nfs.c
91 endif
92
93 ifdef CONFIG_64BIT
94   CPPFLAGS += -DBITS_PER_LONG=64
95 else ifdef CONFIG_32BIT
96   CPPFLAGS += -DBITS_PER_LONG=32
97 endif
98 ifdef CONFIG_LIBAIO
99   libaio_SRCS = engines/libaio.c
100   libaio_LIBS = -laio
101   ENGINES += libaio
102 endif
103 ifdef CONFIG_RDMA
104   rdma_SRCS = engines/rdma.c
105   rdma_LIBS = -libverbs -lrdmacm
106   ENGINES += rdma
107 endif
108 ifdef CONFIG_LIBRPMA_APM
109   librpma_apm_SRCS = engines/librpma_apm.c
110   librpma_fio_SRCS = engines/librpma_fio.c
111   librpma_apm_LIBS = -lrpma -lpmem
112   ENGINES += librpma_apm
113 endif
114 ifdef CONFIG_LIBRPMA_GPSPM
115   librpma_gpspm_SRCS = engines/librpma_gpspm.c engines/librpma_gpspm_flush.pb-c.c
116   librpma_fio_SRCS = engines/librpma_fio.c
117   librpma_gpspm_LIBS = -lrpma -lpmem -lprotobuf-c
118   ENGINES += librpma_gpspm
119 endif
120 ifdef librpma_fio_SRCS
121   SOURCE += $(librpma_fio_SRCS)
122 endif
123 ifdef CONFIG_POSIXAIO
124   SOURCE += engines/posixaio.c
125 endif
126 ifdef CONFIG_LINUX_FALLOCATE
127   SOURCE += engines/falloc.c
128 endif
129 ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
130   SOURCE += engines/e4defrag.c
131 endif
132 ifdef CONFIG_LIBCUFILE
133   SOURCE += engines/libcufile.c
134 endif
135 ifdef CONFIG_LINUX_SPLICE
136   SOURCE += engines/splice.c
137 endif
138 ifdef CONFIG_SOLARISAIO
139   SOURCE += engines/solarisaio.c
140 endif
141 ifdef CONFIG_WINDOWSAIO
142   SOURCE += engines/windowsaio.c
143 endif
144 ifdef CONFIG_RADOS
145   rados_SRCS = engines/rados.c
146   rados_LIBS = -lrados
147   ENGINES += rados
148 endif
149 ifdef CONFIG_RBD
150   rbd_SRCS = engines/rbd.c
151   rbd_LIBS = -lrbd -lrados
152   ENGINES += rbd
153 endif
154 ifdef CONFIG_HTTP
155   http_SRCS = engines/http.c
156   http_LIBS = -lcurl -lssl -lcrypto
157   ENGINES += http
158 endif
159 ifdef CONFIG_DFS
160   dfs_SRCS = engines/dfs.c
161   dfs_LIBS = -luuid -ldaos -ldfs
162   ENGINES += dfs
163 endif
164 SOURCE += oslib/asprintf.c
165 ifndef CONFIG_STRSEP
166   SOURCE += oslib/strsep.c
167 endif
168 ifndef CONFIG_STRCASESTR
169   SOURCE += oslib/strcasestr.c
170 endif
171 ifndef CONFIG_STRLCAT
172   SOURCE += oslib/strlcat.c
173 endif
174 ifndef CONFIG_HAVE_STRNDUP
175   SOURCE += oslib/strndup.c
176 endif
177 ifndef CONFIG_GETOPT_LONG_ONLY
178   SOURCE += oslib/getopt_long.c
179 endif
180 ifndef CONFIG_INET_ATON
181   SOURCE += oslib/inet_aton.c
182 endif
183 ifndef CONFIG_HAVE_STATX
184   SOURCE += oslib/statx.c
185 endif
186 ifdef CONFIG_GFAPI
187   SOURCE += engines/glusterfs.c
188   SOURCE += engines/glusterfs_sync.c
189   SOURCE += engines/glusterfs_async.c
190   LIBS += -lgfapi -lglusterfs
191   ifdef CONFIG_GF_FADVISE
192     FIO_CFLAGS += "-DGFAPI_USE_FADVISE"
193   endif
194 endif
195 ifdef CONFIG_MTD
196   SOURCE += engines/mtd.c
197   SOURCE += oslib/libmtd.c
198   SOURCE += oslib/libmtd_legacy.c
199 endif
200 ifdef CONFIG_PMEMBLK
201   pmemblk_SRCS = engines/pmemblk.c
202   pmemblk_LIBS = -lpmemblk
203   ENGINES += pmemblk
204 endif
205 ifdef CONFIG_LINUX_DEVDAX
206   dev-dax_SRCS = engines/dev-dax.c
207   dev-dax_LIBS = -lpmem
208   ENGINES += dev-dax
209 endif
210 ifdef CONFIG_LIBPMEM
211   libpmem_SRCS = engines/libpmem.c
212   libpmem_LIBS = -lpmem
213   ENGINES += libpmem
214 endif
215 ifdef CONFIG_IME
216   SOURCE += engines/ime.c
217 endif
218 ifdef CONFIG_LIBZBC
219   libzbc_SRCS = engines/libzbc.c
220   libzbc_LIBS = -lzbc
221   ENGINES += libzbc
222 endif
223
224 ifeq ($(CONFIG_TARGET_OS), Linux)
225   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
226                 oslib/linux-dev-lookup.c engines/io_uring.c
227 ifdef CONFIG_HAS_BLKZONED
228   SOURCE += oslib/linux-blkzoned.c
229 endif
230   LIBS += -lpthread -ldl
231   LDFLAGS += -rdynamic
232 endif
233 ifeq ($(CONFIG_TARGET_OS), Android)
234   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c profiles/tiobench.c \
235                 oslib/linux-dev-lookup.c
236 ifdef CONFIG_HAS_BLKZONED
237   SOURCE += oslib/linux-blkzoned.c
238 endif
239   LIBS += -ldl -llog
240   LDFLAGS += -rdynamic
241 endif
242 ifeq ($(CONFIG_TARGET_OS), SunOS)
243   LIBS   += -lpthread -ldl
244   CPPFLAGS += -D__EXTENSIONS__
245 endif
246 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
247   SOURCE += trim.c
248   LIBS   += -lpthread -lrt
249   LDFLAGS += -rdynamic
250 endif
251 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
252   LIBS   += -lpthread
253   LDFLAGS += -rdynamic
254 endif
255 ifeq ($(CONFIG_TARGET_OS), NetBSD)
256   LIBS   += -lpthread -lrt
257   LDFLAGS += -rdynamic
258 endif
259 ifeq ($(CONFIG_TARGET_OS), DragonFly)
260   SOURCE += trim.c
261   LIBS   += -lpthread -lrt
262   LDFLAGS += -rdynamic
263 endif
264 ifeq ($(CONFIG_TARGET_OS), AIX)
265   LIBS   += -lpthread -ldl -lrt
266   CPPFLAGS += -D_LARGE_FILES -D__ppc__
267   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
268 endif
269 ifeq ($(CONFIG_TARGET_OS), HP-UX)
270   LIBS   += -lpthread -ldl -lrt
271   FIO_CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
272 endif
273 ifeq ($(CONFIG_TARGET_OS), Darwin)
274   LIBS   += -lpthread -ldl
275 endif
276 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
277   SOURCE += os/windows/cpu-affinity.c os/windows/posix.c
278   WINDOWS_OBJS = os/windows/cpu-affinity.o os/windows/posix.o lib/hweight.o
279   LIBS   += -lpthread -lpsapi -lws2_32 -lssp
280   FIO_CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
281 endif
282
283 ifdef CONFIG_DYNAMIC_ENGINES
284  DYNAMIC_ENGS := $(ENGINES)
285 define engine_template =
286 $(1)_OBJS := $$($(1)_SRCS:.c=.o)
287 $$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
288 engines/fio-$(1).so: $$($(1)_OBJS)
289         $$(QUIET_LINK)$(CC) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 -o $$@ $$< $$($(1)_LIBS)
290 ENGS_OBJS += engines/fio-$(1).so
291 endef
292 else # !CONFIG_DYNAMIC_ENGINES
293 define engine_template =
294 SOURCE += $$($(1)_SRCS)
295 LIBS += $$($(1)_LIBS)
296 CFLAGS += $$($(1)_CFLAGS)
297 endef
298 endif
299
300 FIO-VERSION-FILE: FORCE
301         @$(SHELL) $(SRCDIR)/FIO-VERSION-GEN
302 -include FIO-VERSION-FILE
303
304 override CFLAGS := -DFIO_VERSION='"$(FIO_VERSION)"' $(FIO_CFLAGS) $(CFLAGS)
305
306 $(foreach eng,$(ENGINES),$(eval $(call engine_template,$(eng))))
307
308 OBJS := $(SOURCE:.c=.o)
309
310 FIO_OBJS = $(OBJS) fio.o
311
312 GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
313                         gclient.o gcompat.o cairo_text_helpers.o printing.o
314
315 ifdef CONFIG_ARITHMETIC
316 FIO_OBJS += lex.yy.o y.tab.o
317 GFIO_OBJS += lex.yy.o y.tab.o
318 endif
319
320 -include $(OBJS:.o=.d)
321
322 T_SMALLOC_OBJS = t/stest.o
323 T_SMALLOC_OBJS += gettime.o fio_sem.o pshared.o smalloc.o t/log.o t/debug.o \
324                   t/arch.o
325 T_SMALLOC_PROGS = t/stest
326
327 T_IEEE_OBJS = t/ieee754.o
328 T_IEEE_OBJS += lib/ieee754.o
329 T_IEEE_PROGS = t/ieee754
330
331 T_ZIPF_OBS = t/genzipf.o
332 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \
333                 lib/strntol.o lib/gauss.o t/genzipf.o oslib/strcasestr.o \
334                 oslib/strndup.o
335 T_ZIPF_PROGS = t/fio-genzipf
336
337 T_AXMAP_OBJS = t/axmap.o
338 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
339 T_AXMAP_PROGS = t/axmap
340
341 T_LFSR_TEST_OBJS = t/lfsr-test.o
342 T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o fio_sem.o pshared.o \
343                     t/log.o t/debug.o t/arch.o
344 T_LFSR_TEST_PROGS = t/lfsr-test
345
346 T_GEN_RAND_OBJS = t/gen-rand.o
347 T_GEN_RAND_OBJS += t/log.o t/debug.o lib/rand.o lib/pattern.o lib/strntol.o \
348                         oslib/strcasestr.o oslib/strndup.o
349 T_GEN_RAND_PROGS = t/gen-rand
350
351 ifeq ($(CONFIG_TARGET_OS), Linux)
352 T_BTRACE_FIO_OBJS = t/btrace2fio.o
353 T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o oslib/linux-dev-lookup.o
354 T_BTRACE_FIO_PROGS = t/fio-btrace2fio
355 endif
356
357 T_DEDUPE_OBJS = t/dedupe.o
358 T_DEDUPE_OBJS += lib/rbtree.o t/log.o fio_sem.o pshared.o smalloc.o gettime.o \
359                 crc/md5.o lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o \
360                 t/arch.o crc/murmur3.o crc/crc32c.o crc/crc32c-intel.o \
361                 crc/crc32c-arm64.o crc/fnv.o
362 T_DEDUPE_PROGS = t/fio-dedupe
363
364 T_VS_OBJS = t/verify-state.o t/log.o crc/crc32c.o crc/crc32c-intel.o crc/crc32c-arm64.o t/debug.o
365 T_VS_PROGS = t/fio-verify-state
366
367 T_PIPE_ASYNC_OBJS = t/read-to-pipe-async.o
368 T_PIPE_ASYNC_PROGS = t/read-to-pipe-async
369
370 T_IOU_RING_OBJS = t/io_uring.o
371 T_IOU_RING_OBJS += t/arch.o
372 T_IOU_RING_PROGS = t/io_uring
373
374 T_MEMLOCK_OBJS = t/memlock.o
375 T_MEMLOCK_PROGS = t/memlock
376
377 T_TT_OBJS = t/time-test.o
378 T_TT_PROGS = t/time-test
379
380 T_FUZZ_OBJS = t/fuzz/fuzz_parseini.o
381 T_FUZZ_OBJS += $(OBJS)
382 ifdef CONFIG_ARITHMETIC
383 T_FUZZ_OBJS += lex.yy.o y.tab.o
384 endif
385 # in case there is no fuzz driver defined by environment variable LIB_FUZZING_ENGINE, use a simple one
386 # For instance, with compiler clang, address sanitizer and libFuzzer as a fuzzing engine, you should define
387 # export CFLAGS="-fsanitize=address,fuzzer-no-link"
388 # export LIB_FUZZING_ENGINE="-fsanitize=address"
389 # export CC=clang
390 # before running configure && make
391 # You can adapt this with different compilers, sanitizers, and fuzzing engines
392 ifndef LIB_FUZZING_ENGINE
393 T_FUZZ_OBJS += t/fuzz/onefile.o
394 endif
395 T_FUZZ_PROGS = t/fuzz/fuzz_parseini
396
397 T_OBJS = $(T_SMALLOC_OBJS)
398 T_OBJS += $(T_IEEE_OBJS)
399 T_OBJS += $(T_ZIPF_OBJS)
400 T_OBJS += $(T_AXMAP_OBJS)
401 T_OBJS += $(T_LFSR_TEST_OBJS)
402 T_OBJS += $(T_GEN_RAND_OBJS)
403 T_OBJS += $(T_BTRACE_FIO_OBJS)
404 T_OBJS += $(T_DEDUPE_OBJS)
405 T_OBJS += $(T_VS_OBJS)
406 T_OBJS += $(T_PIPE_ASYNC_OBJS)
407 T_OBJS += $(T_MEMLOCK_OBJS)
408 T_OBJS += $(T_TT_OBJS)
409 T_OBJS += $(T_IOU_RING_OBJS)
410 T_OBJS += $(T_FUZZ_OBJS)
411
412 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
413     T_DEDUPE_OBJS += $(WINDOWS_OBJS)
414     T_SMALLOC_OBJS += $(WINDOWS_OBJS)
415     T_LFSR_TEST_OBJS += $(WINDOWS_OBJS)
416 endif
417
418 T_TEST_PROGS = $(T_SMALLOC_PROGS)
419 T_TEST_PROGS += $(T_IEEE_PROGS)
420 T_PROGS += $(T_ZIPF_PROGS)
421 T_TEST_PROGS += $(T_AXMAP_PROGS)
422 T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
423 T_TEST_PROGS += $(T_GEN_RAND_PROGS)
424 T_PROGS += $(T_BTRACE_FIO_PROGS)
425 T_PROGS += $(T_DEDUPE_PROGS)
426 T_PROGS += $(T_VS_PROGS)
427 T_TEST_PROGS += $(T_MEMLOCK_PROGS)
428 ifdef CONFIG_PREAD
429 T_TEST_PROGS += $(T_PIPE_ASYNC_PROGS)
430 endif
431 ifneq (,$(findstring Linux,$(CONFIG_TARGET_OS)))
432 T_TEST_PROGS += $(T_IOU_RING_PROGS)
433 endif
434 T_TEST_PROGS += $(T_FUZZ_PROGS)
435
436 PROGS += $(T_PROGS)
437
438 ifdef CONFIG_HAVE_CUNIT
439 UT_OBJS = unittests/unittest.o
440 UT_OBJS += unittests/lib/memalign.o
441 UT_OBJS += unittests/lib/num2str.o
442 UT_OBJS += unittests/lib/strntol.o
443 UT_OBJS += unittests/oslib/strlcat.o
444 UT_OBJS += unittests/oslib/strndup.o
445 UT_OBJS += unittests/oslib/strcasestr.o
446 UT_OBJS += unittests/oslib/strsep.o
447 UT_TARGET_OBJS = lib/memalign.o
448 UT_TARGET_OBJS += lib/num2str.o
449 UT_TARGET_OBJS += lib/strntol.o
450 UT_TARGET_OBJS += oslib/strlcat.o
451 UT_TARGET_OBJS += oslib/strndup.o
452 UT_TARGET_OBJS += oslib/strcasestr.o
453 UT_TARGET_OBJS += oslib/strsep.o
454 UT_PROGS = unittests/unittest
455 else
456 UT_OBJS =
457 UT_TARGET_OBJS =
458 UT_PROGS =
459 endif
460
461 ifneq ($(findstring $(MAKEFLAGS),s),s)
462 ifndef V
463         QUIET_CC        = @echo '   ' CC $@;
464         QUIET_LINK      = @echo ' ' LINK $@;
465         QUIET_DEP       = @echo '  ' DEP $@;
466         QUIET_YACC      = @echo ' ' YACC $@;
467         QUIET_LEX       = @echo '  ' LEX $@;
468 endif
469 endif
470
471 ifeq ($(CONFIG_TARGET_OS), SunOS)
472         INSTALL = ginstall
473 else
474         INSTALL = install
475 endif
476 prefix = $(INSTALL_PREFIX)
477 bindir = $(prefix)/bin
478 libdir = $(prefix)/lib/fio
479
480 ifeq ($(CONFIG_TARGET_OS), Darwin)
481 mandir = /usr/share/man
482 sharedir = /usr/share/fio
483 else
484 mandir = $(prefix)/man
485 sharedir = $(prefix)/share/fio
486 endif
487
488 all: $(PROGS) $(T_TEST_PROGS) $(UT_PROGS) $(SCRIPTS) $(ENGS_OBJS) FORCE
489
490 .PHONY: all install clean test
491 .PHONY: FORCE cscope
492
493 %.o : %.c
494         @mkdir -p $(dir $@)
495         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
496         @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
497         @mv -f $*.d $*.d.tmp
498         @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
499         @if type -p fmt >/dev/null 2>&1; then                           \
500                 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 |  \
501                 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d;                  \
502         else                                                            \
503                 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp |             \
504                 tr -cs "[:graph:]" "\n" |                               \
505                 sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d;     \
506         fi
507         @rm -f $*.d.tmp
508
509 ifdef CONFIG_ARITHMETIC
510 lex.yy.c: exp/expression-parser.l
511 ifdef CONFIG_LEX_USE_O
512         $(QUIET_LEX)$(LEX) -o $@ $<
513 else
514         $(QUIET_LEX)$(LEX) $<
515 endif
516
517 lex.yy.o: lex.yy.c y.tab.h
518         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
519
520 y.tab.o: y.tab.c y.tab.h
521         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
522
523 y.tab.c: exp/expression-parser.y
524         $(QUIET_YACC)$(YACC) -o $@ -l -d -b y $<
525
526 y.tab.h: y.tab.c
527
528 lexer.h: lex.yy.c
529
530 exp/test-expression-parser.o: exp/test-expression-parser.c
531         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
532 exp/test-expression-parser: exp/test-expression-parser.o
533         $(QUIET_LINK)$(CC) $(LDFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
534
535 parse.o: lex.yy.o y.tab.o
536 endif
537
538 init.o: init.c FIO-VERSION-FILE
539
540 gcompat.o: gcompat.c gcompat.h
541         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
542
543 goptions.o: goptions.c goptions.h
544         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
545
546 ghelpers.o: ghelpers.c ghelpers.h
547         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
548
549 gerror.o: gerror.c gerror.h
550         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
551
552 gclient.o: gclient.c gclient.h
553         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
554
555 gfio.o: gfio.c ghelpers.c
556         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
557
558 graph.o: graph.c graph.h
559         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
560
561 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
562         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
563
564 printing.o: printing.c printing.h
565         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
566
567 t/io_uring.o: os/linux/io_uring.h
568 t/io_uring: $(T_IOU_RING_OBJS)
569         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IOU_RING_OBJS) $(LIBS)
570
571 t/read-to-pipe-async: $(T_PIPE_ASYNC_OBJS)
572         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_PIPE_ASYNC_OBJS) $(LIBS)
573
574 t/memlock: $(T_MEMLOCK_OBJS)
575         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_MEMLOCK_OBJS) $(LIBS)
576
577 t/stest: $(T_SMALLOC_OBJS)
578         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
579
580 t/ieee754: $(T_IEEE_OBJS)
581         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
582
583 fio: $(FIO_OBJS)
584         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
585
586 t/fuzz/fuzz_parseini: $(T_FUZZ_OBJS)
587 ifndef LIB_FUZZING_ENGINE
588         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIBS) $(HDFSLIB)
589 else
590         $(QUIET_LINK)$(CXX) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIB_FUZZING_ENGINE) $(LIBS) $(HDFSLIB)
591 endif
592
593 gfio: $(GFIO_OBJS)
594         $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
595
596 t/fio-genzipf: $(T_ZIPF_OBJS)
597         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
598
599 t/axmap: $(T_AXMAP_OBJS)
600         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
601
602 t/lfsr-test: $(T_LFSR_TEST_OBJS)
603         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
604
605 t/gen-rand: $(T_GEN_RAND_OBJS)
606         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_GEN_RAND_OBJS) $(LIBS)
607
608 ifeq ($(CONFIG_TARGET_OS), Linux)
609 t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
610         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
611 endif
612
613 t/fio-dedupe: $(T_DEDUPE_OBJS)
614         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
615
616 t/fio-verify-state: $(T_VS_OBJS)
617         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_VS_OBJS) $(LIBS)
618
619 t/time-test: $(T_TT_OBJS)
620         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_TT_OBJS) $(LIBS)
621
622 ifdef CONFIG_HAVE_CUNIT
623 unittests/unittest: $(UT_OBJS) $(UT_TARGET_OBJS)
624         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(UT_OBJS) $(UT_TARGET_OBJS) -lcunit $(LIBS)
625 endif
626
627 clean: FORCE
628         @rm -f .depend $(FIO_OBJS) $(GFIO_OBJS) $(OBJS) $(T_OBJS) $(UT_OBJS) $(PROGS) $(T_PROGS) $(T_TEST_PROGS) core.* core gfio unittests/unittest FIO-VERSION-FILE *.[do] lib/*.d oslib/*.[do] crc/*.d engines/*.[do] engines/*.so profiles/*.[do] t/*.[do] unittests/*.[do] unittests/*/*.[do] config-host.mak config-host.h y.tab.[ch] lex.yy.c exp/*.[do] lexer.h
629         @rm -f t/fio-btrace2fio t/io_uring t/read-to-pipe-async
630         @rm -rf  doc/output
631
632 distclean: clean FORCE
633         @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf fiologparser_hist.pdf
634
635 cscope:
636         @cscope -b -R
637
638 tools/plot/fio2gnuplot.1:
639         @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot >  tools/plot/fio2gnuplot.1
640
641 doc: tools/plot/fio2gnuplot.1
642         @man -t ./fio.1 | ps2pdf - fio.pdf
643         @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
644         @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
645         @man -t tools/hist/fiologparser_hist.py.1 | ps2pdf - fiologparser_hist.pdf
646
647 test: fio
648         ./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
649
650 fulltest:
651         sudo modprobe null_blk &&                                       \
652         if [ ! -e /usr/include/libzbc/zbc.h ]; then                     \
653           git clone https://github.com/hgst/libzbc &&                   \
654           (cd libzbc &&                                                 \
655            ./autogen.sh &&                                              \
656            ./configure --prefix=/usr &&                                 \
657            make -j &&                                                   \
658            sudo make install)                                           \
659         fi &&                                                           \
660         sudo t/zbd/run-tests-against-nullb -s 1 &&                      \
661         if [ -e /sys/module/null_blk/parameters/zoned ]; then           \
662                 sudo t/zbd/run-tests-against-nullb -s 2;                \
663                 sudo t/zbd/run-tests-against-nullb -s 4;                \
664         fi
665
666 install: $(PROGS) $(SCRIPTS) $(ENGS_OBJS) tools/plot/fio2gnuplot.1 FORCE
667         $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
668         $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
669 ifdef CONFIG_DYNAMIC_ENGINES
670         $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
671         $(INSTALL) -m 755 $(SRCDIR)/engines/*.so $(DESTDIR)$(libdir)
672 endif
673         $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
674         $(INSTALL) -m 644 $(SRCDIR)/fio.1 $(DESTDIR)$(mandir)/man1
675         $(INSTALL) -m 644 $(SRCDIR)/tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
676         $(INSTALL) -m 644 $(SRCDIR)/tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
677         $(INSTALL) -m 644 $(SRCDIR)/tools/hist/fiologparser_hist.py.1 $(DESTDIR)$(mandir)/man1
678         $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
679         $(INSTALL) -m 644 $(SRCDIR)/tools/plot/*gpm $(DESTDIR)$(sharedir)/
680
681 .PHONY: test fulltest