Add randtrimwrite data direction
[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 ifeq ($(CONFIG_TARGET_OS), Linux)
241   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c engines/sg.c \
242                 oslib/linux-dev-lookup.c engines/io_uring.c engines/nvme.c
243   cmdprio_SRCS = engines/cmdprio.c
244 ifdef CONFIG_HAS_BLKZONED
245   SOURCE += oslib/linux-blkzoned.c
246 endif
247   LIBS += -lpthread -ldl
248   LDFLAGS += -rdynamic
249 endif
250 ifeq ($(CONFIG_TARGET_OS), Android)
251   SOURCE += diskutil.c fifo.c blktrace.c cgroup.c trim.c profiles/tiobench.c \
252                 oslib/linux-dev-lookup.c engines/io_uring.c engines/nvme.c
253   cmdprio_SRCS = engines/cmdprio.c
254 ifdef CONFIG_HAS_BLKZONED
255   SOURCE += oslib/linux-blkzoned.c
256 endif
257   LIBS += -ldl -llog
258   LDFLAGS += -rdynamic
259 endif
260 ifeq ($(CONFIG_TARGET_OS), SunOS)
261   LIBS   += -lpthread -ldl
262   CPPFLAGS += -D__EXTENSIONS__
263 endif
264 ifeq ($(CONFIG_TARGET_OS), FreeBSD)
265   SOURCE += trim.c
266   LIBS   += -lpthread -lrt
267   LDFLAGS += -rdynamic
268 endif
269 ifeq ($(CONFIG_TARGET_OS), OpenBSD)
270   LIBS   += -lpthread
271   LDFLAGS += -rdynamic
272 endif
273 ifeq ($(CONFIG_TARGET_OS), NetBSD)
274   LIBS   += -lpthread -lrt
275   LDFLAGS += -rdynamic
276 endif
277 ifeq ($(CONFIG_TARGET_OS), DragonFly)
278   SOURCE += trim.c
279   LIBS   += -lpthread -lrt
280   LDFLAGS += -rdynamic
281 endif
282 ifeq ($(CONFIG_TARGET_OS), AIX)
283   LIBS   += -lpthread -ldl -lrt
284   CPPFLAGS += -D_LARGE_FILES -D__ppc__
285   LDFLAGS += -L/opt/freeware/lib -Wl,-blibpath:/opt/freeware/lib:/usr/lib:/lib -Wl,-bmaxdata:0x80000000
286 endif
287 ifeq ($(CONFIG_TARGET_OS), HP-UX)
288   LIBS   += -lpthread -ldl -lrt
289   FIO_CFLAGS += -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE_EXTENDED
290 endif
291 ifeq ($(CONFIG_TARGET_OS), Darwin)
292   LIBS   += -lpthread -ldl
293 endif
294 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
295   SOURCE += os/windows/cpu-affinity.c os/windows/posix.c os/windows/dlls.c
296   WINDOWS_OBJS = os/windows/cpu-affinity.o os/windows/posix.o os/windows/dlls.o lib/hweight.o
297   LIBS   += -lpthread -lpsapi -lws2_32 -lssp
298   FIO_CFLAGS += -DPSAPI_VERSION=1 -Ios/windows/posix/include -Wno-format
299 endif
300
301 ifdef cmdprio_SRCS
302   SOURCE += $(cmdprio_SRCS)
303 endif
304
305 ifdef CONFIG_DYNAMIC_ENGINES
306  DYNAMIC_ENGS := $(ENGINES)
307 define engine_template =
308 $(1)_OBJS := $$($(1)_SRCS:.c=.o)
309 $$($(1)_OBJS): CFLAGS := -fPIC $$($(1)_CFLAGS) $(CFLAGS)
310 engines/fio-$(1).so: $$($(1)_OBJS)
311         $$(QUIET_LINK)$(CC) $(LDFLAGS) -shared -rdynamic -fPIC -Wl,-soname,fio-$(1).so.1 -o $$@ $$< $$($(1)_LIBS)
312 ENGS_OBJS += engines/fio-$(1).so
313 endef
314 else # !CONFIG_DYNAMIC_ENGINES
315 define engine_template =
316 SOURCE += $$($(1)_SRCS)
317 LIBS += $$($(1)_LIBS)
318 override CFLAGS += $$($(1)_CFLAGS)
319 endef
320 endif
321
322 FIO-VERSION-FILE: FORCE
323         @$(SHELL) $(SRCDIR)/FIO-VERSION-GEN
324 -include FIO-VERSION-FILE
325
326 override CFLAGS := -DFIO_VERSION='"$(FIO_VERSION)"' $(FIO_CFLAGS) $(CFLAGS)
327
328 $(foreach eng,$(ENGINES),$(eval $(call engine_template,$(eng))))
329
330 OBJS := $(SOURCE:.c=.o)
331
332 FIO_OBJS = $(OBJS) fio.o
333
334 GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
335                         gclient.o gcompat.o cairo_text_helpers.o printing.o
336
337 ifdef CONFIG_ARITHMETIC
338 FIO_OBJS += lex.yy.o y.tab.o
339 GFIO_OBJS += lex.yy.o y.tab.o
340 endif
341
342 -include $(OBJS:.o=.d)
343
344 T_SMALLOC_OBJS = t/stest.o
345 T_SMALLOC_OBJS += gettime.o fio_sem.o pshared.o smalloc.o t/log.o t/debug.o \
346                   t/arch.o
347 T_SMALLOC_PROGS = t/stest
348
349 T_IEEE_OBJS = t/ieee754.o
350 T_IEEE_OBJS += lib/ieee754.o
351 T_IEEE_PROGS = t/ieee754
352
353 T_ZIPF_OBS = t/genzipf.o
354 T_ZIPF_OBJS += t/log.o lib/ieee754.o lib/rand.o lib/pattern.o lib/zipf.o \
355                 lib/strntol.o lib/gauss.o t/genzipf.o oslib/strcasestr.o \
356                 oslib/strndup.o
357 T_ZIPF_PROGS = t/fio-genzipf
358
359 T_AXMAP_OBJS = t/axmap.o
360 T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
361 T_AXMAP_PROGS = t/axmap
362
363 T_LFSR_TEST_OBJS = t/lfsr-test.o
364 T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o fio_sem.o pshared.o \
365                     t/log.o t/debug.o t/arch.o
366 T_LFSR_TEST_PROGS = t/lfsr-test
367
368 T_GEN_RAND_OBJS = t/gen-rand.o
369 T_GEN_RAND_OBJS += t/log.o t/debug.o lib/rand.o lib/pattern.o lib/strntol.o \
370                         oslib/strcasestr.o oslib/strndup.o
371 T_GEN_RAND_PROGS = t/gen-rand
372
373 ifeq ($(CONFIG_TARGET_OS), Linux)
374 T_BTRACE_FIO_OBJS = t/btrace2fio.o
375 T_BTRACE_FIO_OBJS += fifo.o lib/flist_sort.o t/log.o oslib/linux-dev-lookup.o
376 T_BTRACE_FIO_PROGS = t/fio-btrace2fio
377 endif
378
379 T_DEDUPE_OBJS = t/dedupe.o
380 T_DEDUPE_OBJS += lib/rbtree.o t/log.o fio_sem.o pshared.o smalloc.o gettime.o \
381                 crc/md5.o lib/memalign.o lib/bloom.o t/debug.o crc/xxhash.o \
382                 t/arch.o crc/murmur3.o crc/crc32c.o crc/crc32c-intel.o \
383                 crc/crc32c-arm64.o crc/fnv.o
384 T_DEDUPE_PROGS = t/fio-dedupe
385
386 T_VS_OBJS = t/verify-state.o t/log.o crc/crc32c.o crc/crc32c-intel.o crc/crc32c-arm64.o t/debug.o
387 T_VS_PROGS = t/fio-verify-state
388
389 T_PIPE_ASYNC_OBJS = t/read-to-pipe-async.o
390 T_PIPE_ASYNC_PROGS = t/read-to-pipe-async
391
392 T_IOU_RING_OBJS = t/io_uring.o lib/rand.o lib/pattern.o lib/strntol.o
393 T_IOU_RING_PROGS = t/io_uring
394
395 T_MEMLOCK_OBJS = t/memlock.o
396 T_MEMLOCK_PROGS = t/memlock
397
398 T_TT_OBJS = t/time-test.o
399 T_TT_PROGS = t/time-test
400
401 ifneq (,$(findstring -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION,$(CFLAGS)))
402 T_FUZZ_OBJS = t/fuzz/fuzz_parseini.o
403 T_FUZZ_OBJS += $(OBJS)
404 ifdef CONFIG_ARITHMETIC
405 T_FUZZ_OBJS += lex.yy.o y.tab.o
406 endif
407 # For proper fio code teardown CFLAGS needs to include -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
408 # in case there is no fuzz driver defined by environment variable LIB_FUZZING_ENGINE, use a simple one
409 # For instance, with compiler clang, address sanitizer and libFuzzer as a fuzzing engine, you should define
410 # export CFLAGS="-fsanitize=address,fuzzer-no-link -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION"
411 # export LIB_FUZZING_ENGINE="-fsanitize=address"
412 # export CC=clang
413 # before running configure && make
414 # You can adapt this with different compilers, sanitizers, and fuzzing engines
415 ifndef LIB_FUZZING_ENGINE
416 T_FUZZ_OBJS += t/fuzz/onefile.o
417 endif
418 T_FUZZ_PROGS = t/fuzz/fuzz_parseini
419 else    # CFLAGS includes -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
420 T_FUZZ_OBJS =
421 T_FUZZ_PROGS =
422 endif
423
424 T_OBJS = $(T_SMALLOC_OBJS)
425 T_OBJS += $(T_IEEE_OBJS)
426 T_OBJS += $(T_ZIPF_OBJS)
427 T_OBJS += $(T_AXMAP_OBJS)
428 T_OBJS += $(T_LFSR_TEST_OBJS)
429 T_OBJS += $(T_GEN_RAND_OBJS)
430 T_OBJS += $(T_BTRACE_FIO_OBJS)
431 T_OBJS += $(T_DEDUPE_OBJS)
432 T_OBJS += $(T_VS_OBJS)
433 T_OBJS += $(T_PIPE_ASYNC_OBJS)
434 T_OBJS += $(T_MEMLOCK_OBJS)
435 T_OBJS += $(T_TT_OBJS)
436 T_OBJS += $(T_IOU_RING_OBJS)
437 T_OBJS += $(T_FUZZ_OBJS)
438
439 ifneq (,$(findstring CYGWIN,$(CONFIG_TARGET_OS)))
440     T_DEDUPE_OBJS += $(WINDOWS_OBJS)
441     T_SMALLOC_OBJS += $(WINDOWS_OBJS)
442     T_LFSR_TEST_OBJS += $(WINDOWS_OBJS)
443 endif
444
445 T_TEST_PROGS = $(T_SMALLOC_PROGS)
446 T_TEST_PROGS += $(T_IEEE_PROGS)
447 T_PROGS += $(T_ZIPF_PROGS)
448 T_TEST_PROGS += $(T_AXMAP_PROGS)
449 T_TEST_PROGS += $(T_LFSR_TEST_PROGS)
450 T_TEST_PROGS += $(T_GEN_RAND_PROGS)
451 T_PROGS += $(T_BTRACE_FIO_PROGS)
452 ifdef CONFIG_ZLIB
453 T_PROGS += $(T_DEDUPE_PROGS)
454 endif
455 T_PROGS += $(T_VS_PROGS)
456 T_TEST_PROGS += $(T_MEMLOCK_PROGS)
457 ifdef CONFIG_PREAD
458 T_TEST_PROGS += $(T_PIPE_ASYNC_PROGS)
459 endif
460 ifneq (,$(findstring Linux,$(CONFIG_TARGET_OS)))
461 T_TEST_PROGS += $(T_IOU_RING_PROGS)
462 endif
463 T_TEST_PROGS += $(T_FUZZ_PROGS)
464
465 PROGS += $(T_PROGS)
466
467 ifdef CONFIG_HAVE_CUNIT
468 UT_OBJS = unittests/unittest.o
469 UT_OBJS += unittests/lib/memalign.o
470 UT_OBJS += unittests/lib/num2str.o
471 UT_OBJS += unittests/lib/strntol.o
472 UT_OBJS += unittests/oslib/strlcat.o
473 UT_OBJS += unittests/oslib/strndup.o
474 UT_OBJS += unittests/oslib/strcasestr.o
475 UT_OBJS += unittests/oslib/strsep.o
476 UT_TARGET_OBJS = lib/memalign.o
477 UT_TARGET_OBJS += lib/num2str.o
478 UT_TARGET_OBJS += lib/strntol.o
479 UT_TARGET_OBJS += oslib/strlcat.o
480 UT_TARGET_OBJS += oslib/strndup.o
481 UT_TARGET_OBJS += oslib/strcasestr.o
482 UT_TARGET_OBJS += oslib/strsep.o
483 UT_PROGS = unittests/unittest
484 else
485 UT_OBJS =
486 UT_TARGET_OBJS =
487 UT_PROGS =
488 endif
489
490 ifneq ($(findstring $(MAKEFLAGS),s),s)
491 ifndef V
492         QUIET_CC        = @echo '   ' CC $@;
493         QUIET_LINK      = @echo ' ' LINK $@;
494         QUIET_DEP       = @echo '  ' DEP $@;
495         QUIET_YACC      = @echo ' ' YACC $@;
496         QUIET_LEX       = @echo '  ' LEX $@;
497 endif
498 endif
499
500 ifeq ($(CONFIG_TARGET_OS), SunOS)
501         INSTALL = ginstall
502 else
503         INSTALL = install
504 endif
505 prefix = $(INSTALL_PREFIX)
506 bindir = $(prefix)/bin
507 libdir = $(prefix)/lib/fio
508
509 ifeq ($(CONFIG_TARGET_OS), Darwin)
510 mandir = /usr/share/man
511 sharedir = /usr/share/fio
512 else
513 mandir = $(prefix)/man
514 sharedir = $(prefix)/share/fio
515 endif
516
517 all: $(PROGS) $(T_TEST_PROGS) $(UT_PROGS) $(SCRIPTS) $(ENGS_OBJS) FORCE
518
519 .PHONY: all install clean test
520 .PHONY: FORCE cscope
521
522 %.o : %.c
523         @mkdir -p $(dir $@)
524         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
525         @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
526         @mv -f $*.d $*.d.tmp
527         @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
528         @if type -p fmt >/dev/null 2>&1; then                           \
529                 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 |  \
530                 sed -e 's/^ *//' -e 's/$$/:/' >> $*.d;                  \
531         else                                                            \
532                 sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp |             \
533                 tr -cs "[:graph:]" "\n" |                               \
534                 sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d;     \
535         fi
536         @rm -f $*.d.tmp
537
538 ifdef CONFIG_ARITHMETIC
539 lex.yy.c: exp/expression-parser.l
540 ifdef CONFIG_LEX_USE_O
541         $(QUIET_LEX)$(LEX) -o $@ $<
542 else
543         $(QUIET_LEX)$(LEX) $<
544 endif
545
546 ifneq (,$(findstring -Wimplicit-fallthrough,$(CFLAGS)))
547 LEX_YY_CFLAGS := -Wno-implicit-fallthrough
548 endif
549
550 lex.yy.o: lex.yy.c y.tab.h
551         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(LEX_YY_CFLAGS) -c $<
552
553 y.tab.o: y.tab.c y.tab.h
554         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
555
556 y.tab.c: exp/expression-parser.y
557         $(QUIET_YACC)$(YACC) -o $@ -l -d -b y $<
558
559 y.tab.h: y.tab.c
560
561 lexer.h: lex.yy.c
562
563 exp/test-expression-parser.o: exp/test-expression-parser.c
564         $(QUIET_CC)$(CC) -o $@ $(CFLAGS) $(CPPFLAGS) -c $<
565 exp/test-expression-parser: exp/test-expression-parser.o
566         $(QUIET_LINK)$(CC) $(LDFLAGS) $< y.tab.o lex.yy.o -o $@ $(LIBS)
567
568 parse.o: lex.yy.o y.tab.o
569 endif
570
571 init.o: init.c FIO-VERSION-FILE
572
573 gcompat.o: gcompat.c gcompat.h
574         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
575
576 goptions.o: goptions.c goptions.h
577         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
578
579 ghelpers.o: ghelpers.c ghelpers.h
580         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
581
582 gerror.o: gerror.c gerror.h
583         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
584
585 gclient.o: gclient.c gclient.h
586         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
587
588 gfio.o: gfio.c ghelpers.c
589         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
590
591 graph.o: graph.c graph.h
592         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
593
594 cairo_text_helpers.o: cairo_text_helpers.c cairo_text_helpers.h
595         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
596
597 printing.o: printing.c printing.h
598         $(QUIET_CC)$(CC) $(CFLAGS) $(GTK_CFLAGS) $(CPPFLAGS) -c $<
599
600 t/io_uring.o: os/linux/io_uring.h
601 t/io_uring: $(T_IOU_RING_OBJS)
602         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IOU_RING_OBJS) $(LIBS)
603
604 t/read-to-pipe-async: $(T_PIPE_ASYNC_OBJS)
605         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_PIPE_ASYNC_OBJS) $(LIBS)
606
607 t/memlock: $(T_MEMLOCK_OBJS)
608         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_MEMLOCK_OBJS) $(LIBS)
609
610 t/stest: $(T_SMALLOC_OBJS)
611         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_SMALLOC_OBJS) $(LIBS)
612
613 t/ieee754: $(T_IEEE_OBJS)
614         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_IEEE_OBJS) $(LIBS)
615
616 fio: $(FIO_OBJS)
617         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(FIO_OBJS) $(LIBS) $(HDFSLIB)
618
619 t/fuzz/fuzz_parseini: $(T_FUZZ_OBJS)
620 ifndef LIB_FUZZING_ENGINE
621         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIBS) $(HDFSLIB)
622 else
623         $(QUIET_LINK)$(CXX) $(LDFLAGS) -o $@ $(T_FUZZ_OBJS) $(LIB_FUZZING_ENGINE) $(LIBS) $(HDFSLIB)
624 endif
625
626 gfio: $(GFIO_OBJS)
627         $(QUIET_LINK)$(CC) $(filter-out -static, $(LDFLAGS)) -o gfio $(GFIO_OBJS) $(LIBS) $(GFIO_LIBS) $(GTK_LDFLAGS) $(HDFSLIB)
628
629 t/fio-genzipf: $(T_ZIPF_OBJS)
630         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_ZIPF_OBJS) $(LIBS)
631
632 t/axmap: $(T_AXMAP_OBJS)
633         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_AXMAP_OBJS) $(LIBS)
634
635 t/lfsr-test: $(T_LFSR_TEST_OBJS)
636         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_LFSR_TEST_OBJS) $(LIBS)
637
638 t/gen-rand: $(T_GEN_RAND_OBJS)
639         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_GEN_RAND_OBJS) $(LIBS)
640
641 ifeq ($(CONFIG_TARGET_OS), Linux)
642 t/fio-btrace2fio: $(T_BTRACE_FIO_OBJS)
643         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_BTRACE_FIO_OBJS) $(LIBS)
644 endif
645
646 ifdef CONFIG_ZLIB
647 t/fio-dedupe: $(T_DEDUPE_OBJS)
648         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_DEDUPE_OBJS) $(LIBS)
649 endif
650
651 t/fio-verify-state: $(T_VS_OBJS)
652         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_VS_OBJS) $(LIBS)
653
654 t/time-test: $(T_TT_OBJS)
655         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(T_TT_OBJS) $(LIBS)
656
657 ifdef CONFIG_HAVE_CUNIT
658 unittests/unittest: $(UT_OBJS) $(UT_TARGET_OBJS)
659         $(QUIET_LINK)$(CC) $(LDFLAGS) -o $@ $(UT_OBJS) $(UT_TARGET_OBJS) -lcunit $(LIBS)
660 endif
661
662 clean: FORCE
663         @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
664         @rm -f t/fio-btrace2fio t/io_uring t/read-to-pipe-async
665         @rm -rf  doc/output
666
667 distclean: clean FORCE
668         @rm -f cscope.out fio.pdf fio_generate_plots.pdf fio2gnuplot.pdf fiologparser_hist.pdf
669
670 cscope:
671         @cscope -b -R
672
673 tools/plot/fio2gnuplot.1:
674         @cat tools/plot/fio2gnuplot.manpage | txt2man -t fio2gnuplot >  tools/plot/fio2gnuplot.1
675
676 doc: tools/plot/fio2gnuplot.1
677         @man -t ./fio.1 | ps2pdf - fio.pdf
678         @man -t tools/fio_generate_plots.1 | ps2pdf - fio_generate_plots.pdf
679         @man -t tools/plot/fio2gnuplot.1 | ps2pdf - fio2gnuplot.pdf
680         @man -t tools/hist/fiologparser_hist.py.1 | ps2pdf - fiologparser_hist.pdf
681
682 test: fio
683         ./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
684
685 fulltest:
686         sudo modprobe null_blk &&                                       \
687         if [ ! -e /usr/include/libzbc/zbc.h ]; then                     \
688           git clone https://github.com/westerndigitalcorporation/libzbc && \
689           (cd libzbc &&                                                 \
690            ./autogen.sh &&                                              \
691            ./configure --prefix=/usr &&                                 \
692            make -j &&                                                   \
693            sudo make install)                                           \
694         fi &&                                                           \
695         sudo t/zbd/run-tests-against-nullb -s 1 &&                      \
696         if [ -e /sys/module/null_blk/parameters/zoned ]; then           \
697                 sudo t/zbd/run-tests-against-nullb -s 2;                \
698                 sudo t/zbd/run-tests-against-nullb -s 4;                \
699         fi
700
701 install: $(PROGS) $(SCRIPTS) $(ENGS_OBJS) tools/plot/fio2gnuplot.1 FORCE
702         $(INSTALL) -m 755 -d $(DESTDIR)$(bindir)
703         $(INSTALL) $(PROGS) $(SCRIPTS) $(DESTDIR)$(bindir)
704 ifdef CONFIG_DYNAMIC_ENGINES
705         $(INSTALL) -m 755 -d $(DESTDIR)$(libdir)
706         $(INSTALL) -m 755 $(SRCDIR)/engines/*.so $(DESTDIR)$(libdir)
707 endif
708         $(INSTALL) -m 755 -d $(DESTDIR)$(mandir)/man1
709         $(INSTALL) -m 644 $(SRCDIR)/fio.1 $(DESTDIR)$(mandir)/man1
710         $(INSTALL) -m 644 $(SRCDIR)/tools/fio_generate_plots.1 $(DESTDIR)$(mandir)/man1
711         $(INSTALL) -m 644 $(SRCDIR)/tools/plot/fio2gnuplot.1 $(DESTDIR)$(mandir)/man1
712         $(INSTALL) -m 644 $(SRCDIR)/tools/hist/fiologparser_hist.py.1 $(DESTDIR)$(mandir)/man1
713         $(INSTALL) -m 755 -d $(DESTDIR)$(sharedir)
714         $(INSTALL) -m 644 $(SRCDIR)/tools/plot/*gpm $(DESTDIR)$(sharedir)/
715
716 .PHONY: test fulltest