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