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