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