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