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